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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2016-03-16 09:48:25 +10:00
parent 9f544cbe1c
commit b1d99a744b
6 changed files with 8 additions and 33 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -1424,7 +1424,6 @@ ratbag_find_hidraw_node(struct ratbag_device *device,
skip:
ratbag_close_hidraw(device);
rc = -ENODEV;
}
out:

View File

@@ -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;
}