diff options
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r-- | drivers/hid/hidraw.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 96ec1bacbbf3..732449628971 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -265,6 +265,34 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
265 | break; | 265 | break; |
266 | } | 266 | } |
267 | default: | 267 | default: |
268 | { | ||
269 | struct hid_device *hid = dev->hid; | ||
270 | if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) | ||
271 | return -EINVAL; | ||
272 | |||
273 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) { | ||
274 | int len; | ||
275 | if (!hid->name) | ||
276 | return 0; | ||
277 | len = strlen(hid->name) + 1; | ||
278 | if (len > _IOC_SIZE(cmd)) | ||
279 | len = _IOC_SIZE(cmd); | ||
280 | return copy_to_user(user_arg, hid->name, len) ? | ||
281 | -EFAULT : len; | ||
282 | } | ||
283 | |||
284 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) { | ||
285 | int len; | ||
286 | if (!hid->phys) | ||
287 | return 0; | ||
288 | len = strlen(hid->phys) + 1; | ||
289 | if (len > _IOC_SIZE(cmd)) | ||
290 | len = _IOC_SIZE(cmd); | ||
291 | return copy_to_user(user_arg, hid->phys, len) ? | ||
292 | -EFAULT : len; | ||
293 | } | ||
294 | } | ||
295 | |||
268 | ret = -ENOTTY; | 296 | ret = -ENOTTY; |
269 | } | 297 | } |
270 | unlock_kernel(); | 298 | unlock_kernel(); |
@@ -329,7 +357,7 @@ int hidraw_connect(struct hid_device *hid) | |||
329 | goto out; | 357 | goto out; |
330 | } | 358 | } |
331 | 359 | ||
332 | dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor), | 360 | dev->dev = device_create(hidraw_class, &hid->dev, MKDEV(hidraw_major, minor), |
333 | NULL, "%s%d", "hidraw", minor); | 361 | NULL, "%s%d", "hidraw", minor); |
334 | 362 | ||
335 | if (IS_ERR(dev->dev)) { | 363 | if (IS_ERR(dev->dev)) { |