diff options
author | Jiri Kosina <jkosina@suse.cz> | 2008-11-12 16:14:08 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2009-01-04 01:00:51 +0100 |
commit | 9188e79ec3fd43a0a605274324aecfb731baa88b (patch) | |
tree | 631c3098389942df8301ce8dd1340165a47e6696 /drivers/hid | |
parent | 6bbe586fd4d94439f3960e200056ff057f7db5c6 (diff) | |
download | linux-stable-9188e79ec3fd43a0a605274324aecfb731baa88b.tar.gz linux-stable-9188e79ec3fd43a0a605274324aecfb731baa88b.tar.bz2 linux-stable-9188e79ec3fd43a0a605274324aecfb731baa88b.zip |
HID: add phys and name ioctls to hidraw
The hiddev interface provides ioctl() calls which can be used
to obtain phys and raw name of the underlying device.
Add the corresponding support also into hidraw.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hidraw.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 7685ae6808c4..975edd88a3db 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, break; } default: + { + struct hid_device *hid = dev->hid; + if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) + return -EINVAL; + + if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWNAME(0))) { + int len; + if (!hid->name) + return 0; + len = strlen(hid->name) + 1; + if (len > _IOC_SIZE(cmd)) + len = _IOC_SIZE(cmd); + return copy_to_user(user_arg, hid->name, len) ? + -EFAULT : len; + } + + if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWPHYS(0))) { + int len; + if (!hid->phys) + return 0; + len = strlen(hid->phys) + 1; + if (len > _IOC_SIZE(cmd)) + len = _IOC_SIZE(cmd); + return copy_to_user(user_arg, hid->phys, len) ? + -EFAULT : len; + } + } + ret = -ENOTTY; } unlock_kernel(); |