]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
USB: allow libusb to talk to unauthenticated WUSB devices
authorDavid Vrabel <david.vrabel@csr.com>
Wed, 18 Feb 2009 14:43:47 +0000 (14:43 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Mar 2009 23:20:35 +0000 (16:20 -0700)
To permit a userspace application to associate with WUSB devices
using numeric association, control transfers to unauthenticated WUSB
devices must be allowed.

This requires that wusbcore correctly sets the device state to
UNAUTHENTICATED, DEFAULT and ADDRESS and that control transfers can be
performed to UNAUTHENTICATED devices.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/devio.c
drivers/usb/core/hub.c
drivers/usb/core/urb.c
drivers/usb/wusbcore/devconnect.c
drivers/usb/wusbcore/security.c
include/linux/usb/ch9.h

index 6585f527e3817a7eca61726b76e7af22d683b535..8f022af2fd7ad8410ba7933cf382d8807e00d0d2 100644 (file)
@@ -525,7 +525,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
 {
        int ret = 0;
 
-       if (ps->dev->state != USB_STATE_ADDRESS
+       if (ps->dev->state != USB_STATE_UNAUTHENTICATED
+        && ps->dev->state != USB_STATE_ADDRESS
         && ps->dev->state != USB_STATE_CONFIGURED)
                return -EHOSTUNREACH;
        if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
index 7e33d63ab92f744987645ec68fdbafd84c916dc1..f17d9ebc44af1660d266636172eb76d0dd4ca587 100644 (file)
@@ -1305,6 +1305,7 @@ void usb_set_device_state(struct usb_device *udev,
                recursively_mark_NOTATTACHED(udev);
        spin_unlock_irqrestore(&device_state_lock, flags);
 }
+EXPORT_SYMBOL_GPL(usb_set_device_state);
 
 /*
  * WUSB devices are simple: they have no hubs behind, so the mapping
index 58bc5e3c25603dcaf2cf073c85012006b61b6545..7025d801f23a71640197bc6b640110f51b8361d8 100644 (file)
@@ -295,7 +295,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
        if (!urb || urb->hcpriv || !urb->complete)
                return -EINVAL;
        dev = urb->dev;
-       if ((!dev) || (dev->state < USB_STATE_DEFAULT))
+       if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED))
                return -ENODEV;
 
        /* For now, get the endpoint from the pipe.  Eventually drivers
index 8e18141bb2e08d550351f3f8b1b0b91b6f2409db..f0aac0cf315a5cdabcadfa2831a52377ff030b14 100644 (file)
@@ -889,6 +889,8 @@ static void wusb_dev_add_ncb(struct usb_device *usb_dev)
        if (usb_dev->wusb == 0 || usb_dev->devnum == 1)
                return;         /* skip non wusb and wusb RHs */
 
+       usb_set_device_state(usb_dev, USB_STATE_UNAUTHENTICATED);
+
        wusbhc = wusbhc_get_by_usb_dev(usb_dev);
        if (wusbhc == NULL)
                goto error_nodev;
index f4aa28eca70d445af8c7fb9493b120c6d0f670d0..8118db7f1d8ddd230b8f5e6c2dcc116d2eb64d89 100644 (file)
@@ -312,6 +312,7 @@ int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
        result = wusb_set_dev_addr(wusbhc, wusb_dev, 0);
        if (result < 0)
                goto error_addr0;
+       usb_set_device_state(usb_dev, USB_STATE_DEFAULT);
        usb_ep0_reinit(usb_dev);
 
        /* Set new (authenticated) address. */
@@ -327,6 +328,7 @@ int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
        result = wusb_set_dev_addr(wusbhc, wusb_dev, new_address);
        if (result < 0)
                goto error_addr;
+       usb_set_device_state(usb_dev, USB_STATE_ADDRESS);
        usb_ep0_reinit(usb_dev);
        usb_dev->authenticated = 1;
 error_addr:
index fa777db7f7eb719603b38257c621f653d6ead1a9..d9d54803dbcb8babadd8ae66aaadaeaa36aa871e 100644 (file)
@@ -763,8 +763,8 @@ enum usb_device_state {
        /* chapter 9 and authentication (wireless) device states */
        USB_STATE_ATTACHED,
        USB_STATE_POWERED,                      /* wired */
-       USB_STATE_UNAUTHENTICATED,              /* auth */
        USB_STATE_RECONNECTING,                 /* auth */
+       USB_STATE_UNAUTHENTICATED,              /* auth */
        USB_STATE_DEFAULT,                      /* limited function */
        USB_STATE_ADDRESS,
        USB_STATE_CONFIGURED,                   /* most functions */