Skip to content

Commit 37a9acb

Browse files
ChelsyRatnawatJiri Kosina
authored andcommitted
HID: replace scnprintf() with sysfs_emit()
Documentation/filesystems/sysfs.rst mentions that show() should only use sysfs_emit() or sysfs_emit_at() when formating the value to be returned to user space. So replace scnprintf() with sysfs_emit(). Signed-off-by: Chelsy Ratnawat <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent d3db1ce commit 37a9acb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/hid/hid-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
27972797
{
27982798
struct hid_device *hdev = container_of(dev, struct hid_device, dev);
27992799

2800-
return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n",
2800+
return sysfs_emit(buf, "hid:b%04Xg%04Xv%08Xp%08X\n",
28012801
hdev->bus, hdev->group, hdev->vendor, hdev->product);
28022802
}
28032803
static DEVICE_ATTR_RO(modalias);

drivers/hid/hid-lg4ff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ static ssize_t lg4ff_combine_show(struct device *dev, struct device_attribute *a
956956
return 0;
957957
}
958958

959-
count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.combine);
959+
count = sysfs_emit(buf, "%u\n", entry->wdata.combine);
960960
return count;
961961
}
962962

@@ -1009,7 +1009,7 @@ static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *att
10091009
return 0;
10101010
}
10111011

1012-
count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.range);
1012+
count = sysfs_emit(buf, "%u\n", entry->wdata.range);
10131013
return count;
10141014
}
10151015

@@ -1073,7 +1073,7 @@ static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *a
10731073
return 0;
10741074
}
10751075

1076-
count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name);
1076+
count = sysfs_emit(buf, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name);
10771077
return count;
10781078
}
10791079

0 commit comments

Comments
 (0)