Though flags attribute provides enough information about the dimm, it is nice to export the read_only attribute if bit3 of NVDIMM state flag is set. If error is injected by BIOS, bit3 and bit1 are both set. If DIMM is set to read-only by BIOS, bit3 is set. Hence bit3 is good enough to tell whether the dimm is in read-only mode or not.
Signed-off-by: Lijun Pan <[email protected]> --- drivers/acpi/nfit/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index ebe0857ac346..f96e65aa29dd 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1480,6 +1480,16 @@ static ssize_t flags_show(struct device *dev, } static DEVICE_ATTR_RO(flags); +static ssize_t read_only_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + u16 flags = to_nfit_memdev(dev)->flags; + + return sprintf(buf, "%d\n", + flags & ACPI_NFIT_MEM_NOT_ARMED ? 1 : 0); +} +static DEVICE_ATTR_RO(read_only); + static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1512,6 +1522,7 @@ static struct attribute *acpi_nfit_dimm_attributes[] = { &dev_attr_format1.attr, &dev_attr_serial.attr, &dev_attr_flags.attr, + &dev_attr_read_only.attr, &dev_attr_id.attr, &dev_attr_family.attr, &dev_attr_dsm_mask.attr, -- 2.13.6 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
