This patch exposes the serial number & firmware version in sysfs, which will be used by ndctl in userspace to help users identify the device.
Signed-off-by: Alastair D'Silva <alast...@d-silva.org> --- drivers/nvdimm/ocxl/main.c | 42 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/ocxl/main.c b/drivers/nvdimm/ocxl/main.c index 92b4389e8cbb..1f422f0d51ef 100644 --- a/drivers/nvdimm/ocxl/main.c +++ b/drivers/nvdimm/ocxl/main.c @@ -235,6 +235,43 @@ static int reserve_metadata(struct ocxlpmem *ocxlpmem, return 0; } +static ssize_t serial_show(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct nvdimm *nvdimm = to_nvdimm(device); + struct ocxlpmem *ocxlpmem = nvdimm_provider_data(nvdimm); + const struct ocxl_fn_config *fn_config = ocxl_function_config(ocxlpmem->ocxl_fn); + + return scnprintf(buf, PAGE_SIZE, "%llu\n", fn_config->serial); +} +static DEVICE_ATTR_RO(serial); + +static ssize_t fw_version_show(struct device *device, + struct device_attribute *attr, char *buf) +{ + struct nvdimm *nvdimm = to_nvdimm(device); + struct ocxlpmem *ocxlpmem = nvdimm_provider_data(nvdimm); + + return scnprintf(buf, PAGE_SIZE, "%s\n", ocxlpmem->fw_version); +} +static DEVICE_ATTR_RO(fw_version); + +static struct attribute *ocxl_pmem_attrs[] = { + &dev_attr_serial.attr, + &dev_attr_fw_version.attr, + NULL, +}; + +static const struct attribute_group ocxl_pmem_attribute_group = { + .name = "ocxlpmem", + .attrs = ocxl_pmem_attrs, +}; + +static const struct attribute_group *ocxl_pmem_dimm_attribute_groups[] = { + &ocxl_pmem_attribute_group, + NULL, +}; + /** * register_lpc_mem() - Discover persistent memory on a device and register it with the NVDIMM subsystem * @ocxlpmem: the device metadata @@ -291,8 +328,9 @@ static int register_lpc_mem(struct ocxlpmem *ocxlpmem) snprintf(serial, sizeof(serial), "%llx", fn_config->serial); nd_mapping_desc.nvdimm = nvdimm_create(ocxlpmem->nvdimm_bus, ocxlpmem, - NULL, nvdimm_flags, - nvdimm_cmd_mask, 0, NULL); + ocxl_pmem_dimm_attribute_groups, + nvdimm_flags, nvdimm_cmd_mask, 0, + NULL); if (!nd_mapping_desc.nvdimm) return -ENOMEM; -- 2.24.1 _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-le...@lists.01.org