Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6da9c990 authored by David Vrabel's avatar David Vrabel Committed by Greg Kroah-Hartman
Browse files

USB: allow libusb to talk to unauthenticated WUSB devices



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: default avatarDavid Vrabel <david.vrabel@csr.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4246b06a
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -525,7 +525,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
{
{
	int ret = 0;
	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)
	 && ps->dev->state != USB_STATE_CONFIGURED)
		return -EHOSTUNREACH;
		return -EHOSTUNREACH;
	if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
	if (USB_TYPE_VENDOR == (USB_TYPE_MASK & requesttype))
+1 −0
Original line number Original line Diff line number Diff line
@@ -1305,6 +1305,7 @@ void usb_set_device_state(struct usb_device *udev,
		recursively_mark_NOTATTACHED(udev);
		recursively_mark_NOTATTACHED(udev);
	spin_unlock_irqrestore(&device_state_lock, flags);
	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
 * WUSB devices are simple: they have no hubs behind, so the mapping
+1 −1
Original line number Original line Diff line number Diff line
@@ -295,7 +295,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
	if (!urb || urb->hcpriv || !urb->complete)
	if (!urb || urb->hcpriv || !urb->complete)
		return -EINVAL;
		return -EINVAL;
	dev = urb->dev;
	dev = urb->dev;
	if ((!dev) || (dev->state < USB_STATE_DEFAULT))
	if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED))
		return -ENODEV;
		return -ENODEV;


	/* For now, get the endpoint from the pipe.  Eventually drivers
	/* For now, get the endpoint from the pipe.  Eventually drivers
+2 −0
Original line number Original line Diff line number Diff line
@@ -889,6 +889,8 @@ static void wusb_dev_add_ncb(struct usb_device *usb_dev)
	if (usb_dev->wusb == 0 || usb_dev->devnum == 1)
	if (usb_dev->wusb == 0 || usb_dev->devnum == 1)
		return;		/* skip non wusb and wusb RHs */
		return;		/* skip non wusb and wusb RHs */


	usb_set_device_state(usb_dev, USB_STATE_UNAUTHENTICATED);

	wusbhc = wusbhc_get_by_usb_dev(usb_dev);
	wusbhc = wusbhc_get_by_usb_dev(usb_dev);
	if (wusbhc == NULL)
	if (wusbhc == NULL)
		goto error_nodev;
		goto error_nodev;
+2 −0
Original line number Original line Diff line number Diff line
@@ -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);
	result = wusb_set_dev_addr(wusbhc, wusb_dev, 0);
	if (result < 0)
	if (result < 0)
		goto error_addr0;
		goto error_addr0;
	usb_set_device_state(usb_dev, USB_STATE_DEFAULT);
	usb_ep0_reinit(usb_dev);
	usb_ep0_reinit(usb_dev);


	/* Set new (authenticated) address. */
	/* 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);
	result = wusb_set_dev_addr(wusbhc, wusb_dev, new_address);
	if (result < 0)
	if (result < 0)
		goto error_addr;
		goto error_addr;
	usb_set_device_state(usb_dev, USB_STATE_ADDRESS);
	usb_ep0_reinit(usb_dev);
	usb_ep0_reinit(usb_dev);
	usb_dev->authenticated = 1;
	usb_dev->authenticated = 1;
error_addr:
error_addr:
Loading