Skip to content

Commit

Permalink
HID: core: use scnprintf in modalias_show()
Browse files Browse the repository at this point in the history
scnprintf() exists to provide these semantics, so we might as well use
it.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Rasmus Villemoes authored and Jiri Kosina committed Nov 20, 2015
1 parent 406df15 commit dfa0c5f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2217,12 +2217,9 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
char *buf)
{
struct hid_device *hdev = container_of(dev, struct hid_device, dev);
int len;

len = snprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n",
hdev->bus, hdev->group, hdev->vendor, hdev->product);

return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n",
hdev->bus, hdev->group, hdev->vendor, hdev->product);
}
static DEVICE_ATTR_RO(modalias);

Expand Down

0 comments on commit dfa0c5f

Please sign in to comment.