Re: [PATCH 2/3] usbtouchscreen: Implement runtime power management

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Dienstag, 8. Juni 2010 10:37:51 schrieb Dmitry Torokhov:
> On Mon, Jun 07, 2010 at 10:47:33PM +0200, Oliver Neukum wrote:
>
> > Then I'd say the other drivers are wrong. We cannot leak USB specific
> > codes. Maybe we should pass -ENOMEM and -ENODEV, but the others
> > really don't mean anything as generic codes.
> > 
> 
> No, I'd say that usb_autopm_get_interface() is wrong - since it is
> supposed to be used by drivers who are not concerned about USB-specific
> codes these functions should not leak them to the callers but rather
> provide ones suitable for reporting upstream.

How about a wrapper like this?

	Regards
		Oliver

>From f4c742fa1ec8a368bbaeb129fb502aecb9cf9208 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@xxxxxxxxxx>
Date: Tue, 8 Jun 2010 16:02:51 +0200
Subject: [PATCH] usb: add helper for error code conversion

USB uses error codes in a particular manner. Such codes must
not be passed to user space as that violates POSIX. This helper
maps the error codes to error codes that may be passed to
user space

Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
---
 drivers/usb/core/usb.h |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index cd88220..b070549 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -124,6 +124,18 @@ 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.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux