Skip to content

Commit 212886f

Browse files
zhijianli88gregkh
authored andcommitted
intel_th: Convert sprintf/snprintf to sysfs_emit
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). sprintf() will be converted as weel if they have. Generally, this patch is generated by make coccicheck M=<path/to/file> MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended Signed-off-by: Li Zhijian <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8dc0b2d commit 212886f

File tree

1 file changed

+4
-4
lines changed
  • drivers/hwtracing/intel_th

1 file changed

+4
-4
lines changed

drivers/hwtracing/intel_th/gth.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ static ssize_t master_attr_show(struct device *dev,
154154
spin_unlock(&gth->gth_lock);
155155

156156
if (port >= 0)
157-
count = snprintf(buf, PAGE_SIZE, "%x\n", port);
157+
count = sysfs_emit(buf, "%x\n", port);
158158
else
159-
count = snprintf(buf, PAGE_SIZE, "disabled\n");
159+
count = sysfs_emit(buf, "disabled\n");
160160

161161
return count;
162162
}
@@ -332,8 +332,8 @@ static ssize_t output_attr_show(struct device *dev,
332332
pm_runtime_get_sync(dev);
333333

334334
spin_lock(&gth->gth_lock);
335-
count = snprintf(buf, PAGE_SIZE, "%x\n",
336-
gth_output_parm_get(gth, oa->port, oa->parm));
335+
count = sysfs_emit(buf, "%x\n",
336+
gth_output_parm_get(gth, oa->port, oa->parm));
337337
spin_unlock(&gth->gth_lock);
338338

339339
pm_runtime_put(dev);

0 commit comments

Comments
 (0)