summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-07-26 17:24:40 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-28 07:31:18 +0200
commit8938752dd883b03003701264fcb2bf96522e728f (patch)
treef1127d68ab94dc83919bf90445c03c81b35eab5d
parent422cd55ca880786a013244dd61ca7a7b978e7d22 (diff)
downloadbarebox-8938752dd883b03003701264fcb2bf96522e728f.tar.gz
USB: Count detected USB devices independent of dev_index
Adding a usb device increases dev_index every time a new device is allocated. Removing a usb device does not decrease again, of course. As we print the number of detected usb devices after each usb bus scan based on dev_index, we cannot trust dev_index here. Keep track of the correct number of (currently) detected usb devices by introducing an independent dev_count that gets increased on detect and decreased on remove. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/usb/core/usb.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 201b84e..7307a6f 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -65,6 +65,7 @@
#define USB_BUFSIZ 512
+static int dev_count;
static int dev_index;
static int asynch_allowed;
@@ -447,6 +448,7 @@ int usb_new_device(struct usb_device *dev)
dev_add_param_int_ro(&dev->dev, "idProduct",
le16_to_cpu(dev->descriptor->idProduct), "%04x");
list_add_tail(&dev->list, &usb_device_list);
+ dev_count++;
err = 0;
@@ -473,6 +475,7 @@ void usb_remove_device(struct usb_device *usbdev)
usbdev->parent->children[usbdev->portnr - 1] = NULL;
list_del(&usbdev->list);
free(usbdev);
+ dev_count--;
}
struct usb_device *usb_alloc_new_device(void)
@@ -526,7 +529,7 @@ void usb_rescan(void)
continue;
}
- pr_info("%d USB Device(s) found\n", dev_index);
+ pr_info("%d USB Device(s) found\n", dev_count);
}
/*