Skip to content

Commit 6eff572

Browse files
committed
cxl/mem: Use sysfs_emit() for attribute show routines
While none the CXL sysfs attributes are threatening to overrun a PAGE_SIZE of output, it is good form to use the recommended helpers. Fixes: b39cb10 ("cxl/mem: Register CXL memX devices") Reported-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Ben Widawsky <ben.widawsky@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/161728759424.2474381.11231441014951343463.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent a38fd87 commit 6eff572

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/cxl/mem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ static ssize_t firmware_version_show(struct device *dev,
10661066
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
10671067
struct cxl_mem *cxlm = cxlmd->cxlm;
10681068

1069-
return sprintf(buf, "%.16s\n", cxlm->firmware_version);
1069+
return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version);
10701070
}
10711071
static DEVICE_ATTR_RO(firmware_version);
10721072

@@ -1076,7 +1076,7 @@ static ssize_t payload_max_show(struct device *dev,
10761076
struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
10771077
struct cxl_mem *cxlm = cxlmd->cxlm;
10781078

1079-
return sprintf(buf, "%zu\n", cxlm->payload_size);
1079+
return sysfs_emit(buf, "%zu\n", cxlm->payload_size);
10801080
}
10811081
static DEVICE_ATTR_RO(payload_max);
10821082

@@ -1087,7 +1087,7 @@ static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr,
10871087
struct cxl_mem *cxlm = cxlmd->cxlm;
10881088
unsigned long long len = range_len(&cxlm->ram_range);
10891089

1090-
return sprintf(buf, "%#llx\n", len);
1090+
return sysfs_emit(buf, "%#llx\n", len);
10911091
}
10921092

10931093
static struct device_attribute dev_attr_ram_size =
@@ -1100,7 +1100,7 @@ static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
11001100
struct cxl_mem *cxlm = cxlmd->cxlm;
11011101
unsigned long long len = range_len(&cxlm->pmem_range);
11021102

1103-
return sprintf(buf, "%#llx\n", len);
1103+
return sysfs_emit(buf, "%#llx\n", len);
11041104
}
11051105

11061106
static struct device_attribute dev_attr_pmem_size =

0 commit comments

Comments
 (0)