diff --git a/src/driver-etekcity.c b/src/driver-etekcity.c index efd6af51..e5d335bd 100644 --- a/src/driver-etekcity.c +++ b/src/driver-etekcity.c @@ -636,13 +636,8 @@ etekcity_probe(struct ratbag_device *device) int active_idx; rc = ratbag_open_hidraw(device); - if (rc) { - log_error(device->ratbag, - "Can't open corresponding hidraw node: '%s' (%d)\n", - strerror(-rc), - rc); - return -ENODEV; - } + if (rc) + return rc; if (!ratbag_hidraw_has_report(device, ETEKCITY_REPORT_ID_KEY_MAPPING)) { ratbag_close_hidraw(device); @@ -670,8 +665,8 @@ etekcity_probe(struct ratbag_device *device) if (active_idx < 0) { log_error(device->ratbag, "Can't talk to the mouse: '%s' (%d)\n", - strerror(-rc), - rc); + strerror(-active_idx), + active_idx); rc = -ENODEV; goto err; } diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 0dfd8afc..71e74590 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -504,16 +504,8 @@ hidpp10drv_probe(struct ratbag_device *device) int nread = 0; rc = ratbag_find_hidraw(device, hidpp10drv_test_hidraw); - if (rc == -ENODEV) { - return rc; - } else if (rc) { - log_error(device->ratbag, - "Can't open corresponding hidraw node: '%s' (%d)\n", - strerror(-rc), - rc); - rc = -ENODEV; + if (rc) goto err; - } drv_data = zalloc(sizeof(*drv_data)); hidpp_device_init(&base, device->hidraw.fd); diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index ba333cb2..66fdce04 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -782,15 +782,8 @@ hidpp20drv_probe(struct ratbag_device *device) struct hidpp20_device *dev; rc = ratbag_find_hidraw(device, hidpp20drv_test_hidraw); - if (rc == -ENODEV) { + if (rc) return rc; - } else if (rc) { - log_error(device->ratbag, - "Can't open corresponding hidraw node: '%s' (%d)\n", - strerror(-rc), - rc); - return -ENODEV; - } drv_data = zalloc(sizeof(*drv_data)); ratbag_set_drv_data(device, drv_data); diff --git a/src/driver-roccat.c b/src/driver-roccat.c index ec702a0e..4a9b6ca2 100644 --- a/src/driver-roccat.c +++ b/src/driver-roccat.c @@ -780,13 +780,8 @@ roccat_probe(struct ratbag_device *device) int active_idx; rc = ratbag_open_hidraw(device); - if (rc) { - log_error(device->ratbag, - "Can't open corresponding hidraw node: '%s' (%d)\n", - strerror(-rc), - rc); - return -ENODEV; - } + if (rc) + return rc; if (!ratbag_hidraw_has_report(device, ROCCAT_REPORT_ID_KEY_MAPPING)) { ratbag_close_hidraw(device); @@ -808,8 +803,8 @@ roccat_probe(struct ratbag_device *device) if (active_idx < 0) { log_error(device->ratbag, "Can't talk to the mouse: '%s' (%d)\n", - strerror(-rc), - rc); + strerror(-active_idx), + active_idx); rc = -ENODEV; goto err; } diff --git a/src/libratbag-hidraw.c b/src/libratbag-hidraw.c index 977a6825..fa9d178d 100644 --- a/src/libratbag-hidraw.c +++ b/src/libratbag-hidraw.c @@ -1424,7 +1424,6 @@ ratbag_find_hidraw_node(struct ratbag_device *device, skip: ratbag_close_hidraw(device); - rc = -ENODEV; } out: diff --git a/src/libratbag.c b/src/libratbag.c index 98cadb1e..65e18eea 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -329,8 +329,9 @@ ratbag_assign_driver(struct ratbag_device *device, device->driver = NULL; - if (rc == -ENODEV) - log_error(ratbag, "%s: no hidraw device found\n", device->name); + if (rc != -ENODEV) + log_error(ratbag, "%s: error opening hidraw node (%s)\n", + device->name, strerror(-rc)); return false; }