1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright Intel Corp. 2018 */
3 #include <linux/init.h>
4 #include <linux/module.h>
5 #include <linux/moduleparam.h>
12 ssize_t security_show(struct device *dev,
13 struct device_attribute *attr, char *buf)
15 struct nvdimm *nvdimm = to_nvdimm(dev);
18 * For the test version we need to poll the "hardware" in order
19 * to get the updated status for unlock testing.
21 nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
22 nvdimm->sec.ext_state = nvdimm_security_state(nvdimm, NVDIMM_MASTER);
24 switch (nvdimm->sec.state) {
25 case NVDIMM_SECURITY_DISABLED:
26 return sprintf(buf, "disabled\n");
27 case NVDIMM_SECURITY_UNLOCKED:
28 return sprintf(buf, "unlocked\n");
29 case NVDIMM_SECURITY_LOCKED:
30 return sprintf(buf, "locked\n");
31 case NVDIMM_SECURITY_FROZEN:
32 return sprintf(buf, "frozen\n");
33 case NVDIMM_SECURITY_OVERWRITE:
34 return sprintf(buf, "overwrite\n");