Skip to content

Commit 2f48865

Browse files
holtmannJiri Kosina
authored andcommitted
HID: hidraw: add support uniq ioctl
Add support for reading out the uniq information from the underlying HID device. This might be the iSerialNumber in case of USB or the BD_ADDR in case of Bluetooth. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent d004701 commit 2f48865

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/hid/hidraw.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
450450
-EFAULT : len;
451451
break;
452452
}
453+
454+
if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWUNIQ(0))) {
455+
int len = strlen(hid->uniq) + 1;
456+
if (len > _IOC_SIZE(cmd))
457+
len = _IOC_SIZE(cmd);
458+
ret = copy_to_user(user_arg, hid->uniq, len) ?
459+
-EFAULT : len;
460+
break;
461+
}
453462
}
454463

455464
ret = -ENOTTY;

include/uapi/linux/hidraw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct hidraw_devinfo {
3939
/* The first byte of SFEATURE and GFEATURE is the report number */
4040
#define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
4141
#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
42+
#define HIDIOCGRAWUNIQ(len) _IOC(_IOC_READ, 'H', 0x08, len)
4243

4344
#define HIDRAW_FIRST_MINOR 0
4445
#define HIDRAW_MAX_DEVICES 64

0 commit comments

Comments
 (0)