This introduces /sys/class/usb_host/*/authorized_default; it dictates what is going to be the default authorization state for devices connected to the host. User space can set that using the sysfs file.
By default it is set to be 'authorized' (!0) for normal, wired USB devices and 'unauthorized' (0) for Wireless USB devices. Signed-off-by: Inaky Perez-Gonzalez <[EMAIL PROTECTED]> --- drivers/usb/core/hcd.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++- drivers/usb/core/hcd.h | 9 +++++++- 2 files changed, 60 insertions(+), 2 deletions(-) Index: linux.hg/drivers/usb/core/hcd.c =================================================================== --- linux.hg.orig/drivers/usb/core/hcd.c 2007-05-23 19:53:07.000000000 -0700 +++ linux.hg/drivers/usb/core/hcd.c 2007-05-23 19:55:05.000000000 -0700 @@ -663,6 +663,57 @@ return 0; } + + +/* + * Show & store the current value of authorized_default + */ +static +ssize_t usb_host_authorized_default_show(struct class_device *dev, char *buf) +{ + struct usb_bus *usb_bus = class_get_devdata(dev); + struct usb_hcd *usb_hcd = container_of(usb_bus, struct usb_hcd, self); + return snprintf(buf, PAGE_SIZE, "%u\n", usb_hcd->authorized_default); +} + +static +ssize_t usb_host_authorized_default_store(struct class_device *dev, + const char *buf, size_t size) +{ + ssize_t result; + struct usb_bus *usb_bus = class_get_devdata(dev); + struct usb_hcd *usb_hcd = container_of(usb_bus, struct usb_hcd, self); + unsigned val; + result = sscanf(buf, "%u\n", &val); + if (result == 1) { + usb_hcd->authorized_default = val? 1 : 0; + result = size; + } + else + result = -EINVAL; + return result; +} + +CLASS_DEVICE_ATTR(authorized_default, 0644, + usb_host_authorized_default_show, + usb_host_authorized_default_store); + + +/* Group all the USB bus attributes */ +static +struct attribute *usb_bus_attrs[] = { + &class_device_attr_authorized_default.attr, + NULL, +}; + +static +struct attribute_group usb_bus_attr_group = { + .name = NULL, /* we want them in the same directory */ + .attrs = usb_bus_attrs, +}; + + + /*-------------------------------------------------------------------------*/ static struct class *usb_host_class; @@ -1504,7 +1555,7 @@ hcd->driver = driver; hcd->product_desc = (driver->product_desc) ? driver->product_desc : "USB Host Controller"; - + hcd->authorized_default = hcd->wireless? 0 : 1; return hcd; } EXPORT_SYMBOL (usb_create_hcd); Index: linux.hg/drivers/usb/core/hcd.h =================================================================== --- linux.hg.orig/drivers/usb/core/hcd.h 2007-05-23 19:53:07.000000000 -0700 +++ linux.hg/drivers/usb/core/hcd.h 2007-05-23 19:54:39.000000000 -0700 @@ -51,6 +51,12 @@ * * Since "struct usb_bus" is so thin, you can't share much code in it. * This framework is a layer over that, and should be more sharable. + * + * @authorized_default: Specifies if new devices are authorized to + * connect by default or they require explicit + * user space authorization; this bit is settable + * through /sys/class/usb_host/X/authorized_default. + * For the rest is RO, so we don't lock to r/w it. */ /*-------------------------------------------------------------------------*/ @@ -87,7 +93,8 @@ unsigned poll_rh:1; /* poll for rh status? */ unsigned poll_pending:1; /* status has changed? */ unsigned wireless:1; /* Wireless USB HCD */ - + unsigned authorized_default:1; + int irq; /* irq allocated */ void __iomem *regs; /* device memory/io */ u64 rsrc_start; /* memory/io resource start */ -- Inaky ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel