mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-29 04:09:39 +00:00
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>
This commit is contained in:
parent
1bae4ce27c
commit
60678b60d7
1 changed files with 13 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue