summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2010-12-19 23:54:48 +0300
committerGreg Kroah-Hartman <gregkh@suse.de>2011-01-23 06:35:38 +0300
commit60678b60d78cd268a3aed3044dfbbb85760b2c54 (patch)
tree878df8903a37092318d0a1987c98a538c16fb044
parent1bae4ce27c9c90344f23c65ea6966c50ffeae2f5 (diff)
downloadlinux-60678b60d78cd268a3aed3044dfbbb85760b2c54.tar.xz
USB: add helper to convert USB error codes
This converts error codes specific to USB to generic error codes that can be returned to user space. Tests showed that it is so small that it is better inlined. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/core/usb.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index b975450f403e..a9cf484ecae4 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -122,6 +122,19 @@ static inline int is_usb_device_driver(struct device_driver *drv)
for_devices;
}
+/* translate USB error codes to codes user space understands */
+static inline int usb_translate_errors(int error_code)
+{
+ switch (error_code) {
+ case 0:
+ case -ENOMEM:
+ case -ENODEV:
+ return error_code;
+ default:
+ return -EIO;
+ }
+}
+
/* for labeling diagnostics */
extern const char *usbcore_name;