mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-08 07:33:53 +01:00
hidraw: check if the hidraw node corresponds to the ratbag device
We were retrieving the hidraw information but did not use them. Now the debug output "foo is device 'bar'" is only shown when there is a match. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -147,11 +147,6 @@ ratbag_open_hidraw(struct ratbag_device *device)
|
||||
if (!hidraw_udev)
|
||||
return -ENODEV;
|
||||
|
||||
log_debug(device->ratbag,
|
||||
"%s is device '%s'.\n",
|
||||
device->name,
|
||||
udev_device_get_devnode(hidraw_udev));
|
||||
|
||||
devnode = udev_device_get_devnode(hidraw_udev);
|
||||
fd = ratbag_open_path(device, devnode, O_RDWR);
|
||||
if (fd < 0)
|
||||
@@ -165,6 +160,19 @@ ratbag_open_hidraw(struct ratbag_device *device)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* check basic matching between the hidraw node and the ratbag device */
|
||||
if (info.bustype != device->ids.bustype ||
|
||||
(info.vendor & 0xFFFF )!= device->ids.vendor ||
|
||||
(info.product & 0xFFFF) != device->ids.product) {
|
||||
errno = ENODEV;
|
||||
goto err;
|
||||
}
|
||||
|
||||
log_debug(device->ratbag,
|
||||
"%s is device '%s'.\n",
|
||||
device->name,
|
||||
udev_device_get_devnode(hidraw_udev));
|
||||
|
||||
device->hidraw.fd = fd;
|
||||
|
||||
/* parse first to count the number of reports */
|
||||
|
||||
Reference in New Issue
Block a user