Skip to content

Commit a09ac40

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.6/hidraw' into for-linus
- support for uniq ioctl()
2 parents 9e635c2 + 2f48865 commit a09ac40

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
@@ -451,6 +451,15 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
451451
-EFAULT : len;
452452
break;
453453
}
454+
455+
if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGRAWUNIQ(0))) {
456+
int len = strlen(hid->uniq) + 1;
457+
if (len > _IOC_SIZE(cmd))
458+
len = _IOC_SIZE(cmd);
459+
ret = copy_to_user(user_arg, hid->uniq, len) ?
460+
-EFAULT : len;
461+
break;
462+
}
454463
}
455464

456465
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)