diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-11-14 16:08:08 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-11-20 04:48:04 -0500 |
commit | dfa0c5faf1b8964fa508373232b4cb597a5c226b (patch) | |
tree | a2ffa63bab70f89d01bdff92e6a50868afbea053 | |
parent | 406df15344cc54be9f6852917b19394c375c7b59 (diff) |
HID: core: use scnprintf in modalias_show()
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>
-rw-r--r-- | drivers/hid/hid-core.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index d5ddb7573691..3c1cfc6d9964 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -2217,12 +2217,9 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, | |||
2217 | char *buf) | 2217 | char *buf) |
2218 | { | 2218 | { |
2219 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 2219 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
2220 | int len; | ||
2221 | |||
2222 | len = snprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", | ||
2223 | hdev->bus, hdev->group, hdev->vendor, hdev->product); | ||
2224 | 2220 | ||
2225 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; | 2221 | return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", |
2222 | hdev->bus, hdev->group, hdev->vendor, hdev->product); | ||
2226 | } | 2223 | } |
2227 | static DEVICE_ATTR_RO(modalias); | 2224 | static DEVICE_ATTR_RO(modalias); |
2228 | 2225 | ||