From 9f544cbe1cb43c3375893722ed1d393c23f2b2a8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 16 Mar 2016 09:45:41 +1000 Subject: [PATCH 1/3] Revert "Fix error message on ENODEV" We now get an error message for all devices that have duplicate event nodes because we use -ENODEV for 'device not found', 'device is a duplicates' and 'device doesn't have the hidraw report'. The original commit was triggered by a misunderstanding of the error message, will be fixed in a follow-up. This reverts commit 855a6bd831bc9892402663d3484da97780f28b37. Signed-off-by: Peter Hutterer --- src/libratbag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libratbag.c b/src/libratbag.c index 98cadb1e..f552504b 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -329,7 +329,7 @@ ratbag_assign_driver(struct ratbag_device *device, device->driver = NULL; - if (rc == -ENODEV) + if (rc != -ENODEV) log_error(ratbag, "%s: no hidraw device found\n", device->name); return false; From b1d99a744b6473d539abddf2e0ee39e0051535eb Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 16 Mar 2016 09:48:25 +1000 Subject: [PATCH 2/3] Standardize the error on device open failures No reason for the drivers to have their own printf each, just return the negative errno and let the common code print it. This now also means that we only return -ENODEV on something that's not really an error, for anything else we print the strerror. Signed-off-by: Peter Hutterer --- src/driver-etekcity.c | 9 ++------- src/driver-hidpp10.c | 10 +--------- src/driver-hidpp20.c | 9 +-------- src/driver-roccat.c | 9 ++------- src/libratbag-hidraw.c | 1 - src/libratbag.c | 3 ++- 6 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/driver-etekcity.c b/src/driver-etekcity.c index efd6af51..01cf54a5 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); 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..922ece9c 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); 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 f552504b..65e18eea 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -330,7 +330,8 @@ ratbag_assign_driver(struct ratbag_device *device, device->driver = NULL; if (rc != -ENODEV) - log_error(ratbag, "%s: no hidraw device found\n", device->name); + log_error(ratbag, "%s: error opening hidraw node (%s)\n", + device->name, strerror(-rc)); return false; } From 5c68164d48742bb21eff8a5e7f43a1cf2937b6f4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 16 Mar 2016 09:59:05 +1000 Subject: [PATCH 3/3] etekcity/roccat: fix error message when we can't talk to the mouse Signed-off-by: Peter Hutterer --- src/driver-etekcity.c | 4 ++-- src/driver-roccat.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/driver-etekcity.c b/src/driver-etekcity.c index 01cf54a5..e5d335bd 100644 --- a/src/driver-etekcity.c +++ b/src/driver-etekcity.c @@ -665,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-roccat.c b/src/driver-roccat.c index 922ece9c..4a9b6ca2 100644 --- a/src/driver-roccat.c +++ b/src/driver-roccat.c @@ -803,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; }