dimm_devs.c 874 B

123456789101112131415161718192021222324252627282930
  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>
  6. #include <linux/nd.h>
  7. #include "pmem.h"
  8. #include "pfn.h"
  9. #include "nd.h"
  10. #include "nd-core.h"
  11. ssize_t security_show(struct device *dev,
  12. struct device_attribute *attr, char *buf)
  13. {
  14. struct nvdimm *nvdimm = to_nvdimm(dev);
  15. /*
  16. * For the test version we need to poll the "hardware" in order
  17. * to get the updated status for unlock testing.
  18. */
  19. nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
  20. if (test_bit(NVDIMM_SECURITY_DISABLED, &nvdimm->sec.flags))
  21. return sprintf(buf, "disabled\n");
  22. if (test_bit(NVDIMM_SECURITY_UNLOCKED, &nvdimm->sec.flags))
  23. return sprintf(buf, "unlocked\n");
  24. if (test_bit(NVDIMM_SECURITY_LOCKED, &nvdimm->sec.flags))
  25. return sprintf(buf, "locked\n");
  26. return -ENOTTY;
  27. }