Skip to content

Commit 6ebed00

Browse files
stellarhopperakpm00
authored andcommitted
dax/bus.c: replace several sprintf() with sysfs_emit()
There were several places where drivers/dax/bus.c uses 'sprintf' to print sysfs data. Since a sysfs_emit() helper is available specifically for this purpose, replace all the sprintf() usage for sysfs with sysfs_emit() in this file. Link: https://lkml.kernel.org/r/20240124-vv-dax_abi-v7-2-20d16cb8d23d@intel.com Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Dave Jiang <dave.jiang@intel.com> Cc: David Hildenbrand <david@redhat.com> Cc: Huang Ying <ying.huang@intel.com> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Li Zhijian <lizhijian@fujitsu.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Oscar Salvador <osalvador@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent c05ae9d commit 6ebed00

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

drivers/dax/bus.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static ssize_t id_show(struct device *dev,
269269
{
270270
struct dax_region *dax_region = dev_get_drvdata(dev);
271271

272-
return sprintf(buf, "%d\n", dax_region->id);
272+
return sysfs_emit(buf, "%d\n", dax_region->id);
273273
}
274274
static DEVICE_ATTR_RO(id);
275275

@@ -278,8 +278,8 @@ static ssize_t region_size_show(struct device *dev,
278278
{
279279
struct dax_region *dax_region = dev_get_drvdata(dev);
280280

281-
return sprintf(buf, "%llu\n", (unsigned long long)
282-
resource_size(&dax_region->res));
281+
return sysfs_emit(buf, "%llu\n",
282+
(unsigned long long)resource_size(&dax_region->res));
283283
}
284284
static struct device_attribute dev_attr_region_size = __ATTR(size, 0444,
285285
region_size_show, NULL);
@@ -289,7 +289,7 @@ static ssize_t region_align_show(struct device *dev,
289289
{
290290
struct dax_region *dax_region = dev_get_drvdata(dev);
291291

292-
return sprintf(buf, "%u\n", dax_region->align);
292+
return sysfs_emit(buf, "%u\n", dax_region->align);
293293
}
294294
static struct device_attribute dev_attr_region_align =
295295
__ATTR(align, 0400, region_align_show, NULL);
@@ -322,7 +322,7 @@ static ssize_t available_size_show(struct device *dev,
322322
size = dax_region_avail_size(dax_region);
323323
up_read(&dax_region_rwsem);
324324

325-
return sprintf(buf, "%llu\n", size);
325+
return sysfs_emit(buf, "%llu\n", size);
326326
}
327327
static DEVICE_ATTR_RO(available_size);
328328

@@ -340,7 +340,7 @@ static ssize_t seed_show(struct device *dev,
340340
if (rc)
341341
return rc;
342342
seed = dax_region->seed;
343-
rc = sprintf(buf, "%s\n", seed ? dev_name(seed) : "");
343+
rc = sysfs_emit(buf, "%s\n", seed ? dev_name(seed) : "");
344344
up_read(&dax_region_rwsem);
345345

346346
return rc;
@@ -361,7 +361,7 @@ static ssize_t create_show(struct device *dev,
361361
if (rc)
362362
return rc;
363363
youngest = dax_region->youngest;
364-
rc = sprintf(buf, "%s\n", youngest ? dev_name(youngest) : "");
364+
rc = sysfs_emit(buf, "%s\n", youngest ? dev_name(youngest) : "");
365365
up_read(&dax_region_rwsem);
366366

367367
return rc;
@@ -763,7 +763,7 @@ static ssize_t start_show(struct device *dev,
763763
dax_range = get_dax_range(dev);
764764
if (!dax_range)
765765
return -ENXIO;
766-
rc = sprintf(buf, "%#llx\n", dax_range->range.start);
766+
rc = sysfs_emit(buf, "%#llx\n", dax_range->range.start);
767767
put_dax_range();
768768

769769
return rc;
@@ -779,7 +779,7 @@ static ssize_t end_show(struct device *dev,
779779
dax_range = get_dax_range(dev);
780780
if (!dax_range)
781781
return -ENXIO;
782-
rc = sprintf(buf, "%#llx\n", dax_range->range.end);
782+
rc = sysfs_emit(buf, "%#llx\n", dax_range->range.end);
783783
put_dax_range();
784784

785785
return rc;
@@ -795,7 +795,7 @@ static ssize_t pgoff_show(struct device *dev,
795795
dax_range = get_dax_range(dev);
796796
if (!dax_range)
797797
return -ENXIO;
798-
rc = sprintf(buf, "%#lx\n", dax_range->pgoff);
798+
rc = sysfs_emit(buf, "%#lx\n", dax_range->pgoff);
799799
put_dax_range();
800800

801801
return rc;
@@ -969,7 +969,7 @@ static ssize_t size_show(struct device *dev,
969969
size = dev_dax_size(dev_dax);
970970
up_write(&dax_dev_rwsem);
971971

972-
return sprintf(buf, "%llu\n", size);
972+
return sysfs_emit(buf, "%llu\n", size);
973973
}
974974

975975
static bool alloc_is_aligned(struct dev_dax *dev_dax, resource_size_t size)
@@ -1233,7 +1233,7 @@ static ssize_t align_show(struct device *dev,
12331233
{
12341234
struct dev_dax *dev_dax = to_dev_dax(dev);
12351235

1236-
return sprintf(buf, "%d\n", dev_dax->align);
1236+
return sysfs_emit(buf, "%d\n", dev_dax->align);
12371237
}
12381238

12391239
static ssize_t dev_dax_validate_align(struct dev_dax *dev_dax)
@@ -1311,7 +1311,7 @@ static ssize_t target_node_show(struct device *dev,
13111311
{
13121312
struct dev_dax *dev_dax = to_dev_dax(dev);
13131313

1314-
return sprintf(buf, "%d\n", dev_dax_target_node(dev_dax));
1314+
return sysfs_emit(buf, "%d\n", dev_dax_target_node(dev_dax));
13151315
}
13161316
static DEVICE_ATTR_RO(target_node);
13171317

@@ -1327,7 +1327,7 @@ static ssize_t resource_show(struct device *dev,
13271327
else
13281328
start = dev_dax->ranges[0].range.start;
13291329

1330-
return sprintf(buf, "%#llx\n", start);
1330+
return sysfs_emit(buf, "%#llx\n", start);
13311331
}
13321332
static DEVICE_ATTR(resource, 0400, resource_show, NULL);
13331333

@@ -1338,14 +1338,14 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
13381338
* We only ever expect to handle device-dax instances, i.e. the
13391339
* @type argument to MODULE_ALIAS_DAX_DEVICE() is always zero
13401340
*/
1341-
return sprintf(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
1341+
return sysfs_emit(buf, DAX_DEVICE_MODALIAS_FMT "\n", 0);
13421342
}
13431343
static DEVICE_ATTR_RO(modalias);
13441344

13451345
static ssize_t numa_node_show(struct device *dev,
13461346
struct device_attribute *attr, char *buf)
13471347
{
1348-
return sprintf(buf, "%d\n", dev_to_node(dev));
1348+
return sysfs_emit(buf, "%d\n", dev_to_node(dev));
13491349
}
13501350
static DEVICE_ATTR_RO(numa_node);
13511351

0 commit comments

Comments
 (0)