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:
Benjamin Tissoires
2015-10-07 16:46:28 -04:00
parent 4538d03b36
commit abde78e6c4

View File

@@ -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 */