>From 390b8226481f7ea968512a368b7b6f41f94c8938 Mon Sep 17 00:00:00 2001 From: Oliver Neukum <oliver@xxxxxxxxxx> Date: Sun, 19 Dec 2010 21:30:06 +0100 Subject: [PATCH] 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@xxxxxxx> --- drivers/usb/core/usb.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index cd88220..fbb988a 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -124,6 +124,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; -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html