summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-03-03 08:42:50 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-03-20 10:07:16 +0100
commitabc68d30fb89c7b1d41179e24fa315f71d8ae540 (patch)
tree148de2e82eb88647c889c7188b44b8bb0f316d2d /drivers
parentc4dcbcd30f046d6411cb0d789ad94056b935f26b (diff)
downloadbarebox-abc68d30fb89c7b1d41179e24fa315f71d8ae540.tar.gz
barebox-abc68d30fb89c7b1d41179e24fa315f71d8ae540.tar.xz
usb: Assign dev_index once
dev->devnum is set once in usb_alloc_new_device(), set to 0 again later in usb_new_device() and then set back to the original value. This seems unnecessary, just set devnum once right before calling usb_set_address() on the device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/usb.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index b94f7978a3..ad1d78b8fb 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -301,15 +301,14 @@ static int usb_get_descriptor(struct usb_device *dev, unsigned char type,
}
/*
- * By the time we get here, the device has gotten a new device ID
- * and is in the default state. We need to identify the thing and
- * get the ball rolling..
+ * By the time we get here, the device is in the default state. We need to
+ * identify the thing and get the ball rolling..
*
* Returns 0 for success, != 0 for error.
*/
int usb_new_device(struct usb_device *dev)
{
- int addr, err;
+ int err;
int tmp;
void *buf;
struct usb_device_descriptor *desc;
@@ -326,10 +325,6 @@ int usb_new_device(struct usb_device *dev)
buf = dma_alloc(USB_BUFSIZ);
- /* We still haven't set the Address yet */
- addr = dev->devnum;
- dev->devnum = 0;
-
/* This is a Windows scheme of initialization sequence, with double
* reset of the device (Linux uses the same sequence)
* Some equipment is said to work only with such init sequence; this
@@ -377,7 +372,7 @@ int usb_new_device(struct usb_device *dev)
dev->maxpacketsize = PACKET_SIZE_64;
break;
}
- dev->devnum = addr;
+ dev->devnum = ++dev_index;
err = usb_set_address(dev); /* set address */
@@ -500,7 +495,6 @@ struct usb_device *usb_alloc_new_device(void)
{
struct usb_device *usbdev = xzalloc(sizeof (*usbdev));
- usbdev->devnum = ++dev_index;
usbdev->maxchild = 0;
usbdev->dev.bus = &usb_bus_type;
usbdev->setup_packet = dma_alloc(sizeof(*usbdev->setup_packet));