summaryrefslogtreecommitdiff
path: root/namedev.c
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2004-02-12 19:48:07 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:32:27 -0700
commitbb051f66571121e2c9c97422b65aa89a37ec8feb (patch)
treefb9b21e472e0955ef3ede48534cdf741a202a408 /namedev.c
parentd026a35d747c0a993281408a9644ab843cf89fdd (diff)
[PATCH] fix problem where usb devices can be either the main device or the interface
This fixes the bug of a long delay for mouse devices
Diffstat (limited to 'namedev.c')
-rw-r--r--namedev.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/namedev.c b/namedev.c
index e4e585b5cd..68ca5dd306 100644
--- a/namedev.c
+++ b/namedev.c
@@ -260,12 +260,17 @@ static void apply_format(struct udevice *udev, unsigned char *string)
}
}
+/*
+ * Note, we can have multiple files for different busses in here due
+ * to the mess that USB has for its device tree...
+ */
static struct bus_file {
char *bus;
char *file;
} bus_files[] = {
{ .bus = "scsi", .file = "vendor" },
{ .bus = "usb", .file = "idVendor" },
+ { .bus = "usb", .file = "iInterface" },
{ .bus = "usb-serial", .file = "detach_state" },
{ .bus = "ide", .file = "detach_state" },
{ .bus = "pci", .file = "vendor" },
@@ -285,30 +290,35 @@ static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device)
*/
struct bus_file *b = &bus_files[0];
struct sysfs_attribute *tmpattr;
- int loop;
+ int found = 0;
+ int loop = SECONDS_TO_WAIT_FOR_FILE;
while (1) {
- if (b->bus == NULL)
- break;
+ if (b->bus == NULL) {
+ if (!found)
+ break;
+ /* sleep to give the kernel a chance to create the file */
+ sleep(1);
+ --loop;
+ if (loop == 0)
+ break;
+ b = &bus_files[0];
+ }
if (strcmp(sysfs_device->bus, b->bus) == 0) {
- tmpattr = NULL;
- loop = SECONDS_TO_WAIT_FOR_FILE;
- while (loop--) {
- dbg("looking for file '%s' on bus '%s'", b->file, b->bus);
- tmpattr = sysfs_get_device_attr(sysfs_device, b->file);
- if (tmpattr) {
- /* found it! */
- goto exit;
- }
- /* sleep to give the kernel a chance to create the file */
- sleep(1);
+ found = 1;
+ dbg("looking for file '%s' on bus '%s'", b->file, b->bus);
+ tmpattr = sysfs_get_device_attr(sysfs_device, b->file);
+ if (tmpattr) {
+ /* found it! */
+ goto exit;
}
- dbg("timed out waiting for '%s' file, continuing on anyway...", b->file);
- goto exit;
+ dbg("can't find '%s' file", b->file);
}
- b++;
+ ++b;
}
- dbg("did not find bus type '%s' on list of bus_id_files, contact greg@kroah.com", sysfs_device->bus);
+ if (!found)
+ dbg("did not find bus type '%s' on list of bus_id_files, "
+ "contact greg@kroah.com", sysfs_device->bus);
exit:
return; /* here to prevent compiler warning... */
}