From 3d380af3a8c255c537c3a74a67a60e5a79cd8f05 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 12 Oct 2015 17:26:05 -0400 Subject: [PATCH] prevent error to be shouted when the .probe() returns -ENODEV Seen on the second input node of the Roccat Kone XTD: "ratbag error: ROCCAT Kone XTD: driver specified in hwdb not found: roccat With the new hwdb matching, we should not try any other driver not having the right id, so simplify the for loop to find the driver only. Fixes #32 Signed-off-by: Benjamin Tissoires --- src/libratbag.c | 53 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/libratbag.c b/src/libratbag.c index 4ad3aa99..0fdc28cb 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -303,33 +303,38 @@ ratbag_find_driver(struct ratbag_device *device, } list_for_each(driver, &ratbag->drivers, link) { - if (!streq(driver->id, driver_name)) - continue; - - device->driver = driver; - - if (test_device) - rc = driver->__test_probe(device, test_device); - else - rc = driver->probe(device); - if (rc == 0) { - if (!ratbag_sanity_check_device(device)) { - return NULL; - } else { - log_debug(ratbag, "driver match found: %s\n", driver->name); - return driver; - } - } - - device->driver = NULL; - - if (rc != -ENODEV) { - log_error(ratbag, "%s: no hidraw device found", device->name); - return NULL; + if (streq(driver->id, driver_name)) { + device->driver = driver; + break; } } - log_error(ratbag, "%s: driver specified in hwdb not found: %s\n", device->name, driver_name); + if (!device->driver) { + log_error(ratbag, "%s: driver specified in hwdb not found: %s\n", + device->name, driver_name); + return NULL; + } + + if (test_device) + rc = device->driver->__test_probe(device, test_device); + else + rc = device->driver->probe(device); + if (rc == 0) { + if (!ratbag_sanity_check_device(device)) { + return NULL; + } else { + log_debug(ratbag, "driver match found: %s\n", driver->name); + return device->driver; + } + } + + device->driver = NULL; + + if (rc != -ENODEV) { + log_error(ratbag, "%s: no hidraw device found", device->name); + return NULL; + } + return NULL; }