X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=namedev.c;h=f138fe976955fe99bb3c24318acb132369619c1b;hp=3e2182ae7b8f7c3678bc66f966409f3b8ae24476;hb=58b030657ae7e3e7acf7af534c63f2b081576fbc;hpb=1b9410278e40850bdcedb2fdfc0f815361b1c303 diff --git a/namedev.c b/namedev.c index 3e2182ae7..f138fe976 100644 --- a/namedev.c +++ b/namedev.c @@ -112,7 +112,7 @@ int add_perm_dev(struct perm_device *new_dev) /* update the values if we already have the device */ list_for_each_entry(dev, &perm_device_list, node) { - if (strcmp_pattern(new_dev->name, dev->name)) + if (strcmp(new_dev->name, dev->name)) continue; copy_var(dev, new_dev, mode); copy_string(dev, new_dev, owner); @@ -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... */ } @@ -469,32 +479,20 @@ static int match_sysfs_pairs(struct config_device *dev, struct sysfs_class_devic static int match_id(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device) { char path[SYSFS_PATH_MAX]; - int found; char *temp = NULL; /* we have to have a sysfs device for ID to work */ if (!sysfs_device) return -ENODEV; - found = 0; strfieldcpy(path, sysfs_device->path); temp = strrchr(path, '/'); + temp++; dbg("search '%s' in '%s', path='%s'", dev->id, temp, path); - if (strstr(temp, dev->id) != NULL) { - found = 1; - } else { - *temp = 0x00; - temp = strrchr(path, '/'); - dbg("search '%s' in '%s', path='%s'", dev->id, temp, path); - if (strstr(temp, dev->id) != NULL) - found = 1; - } - if (!found) { - dbg("id doesn't match"); + if (strcmp_pattern(dev->id, temp) != 0) return -ENODEV; - } - - return 0; + else + return 0; } static int match_place(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device) @@ -747,7 +745,7 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud } /* no rule was found so we use the kernel name */ - strfieldcpy(udev->name, class_dev->name); + strfieldcpy(udev->name, udev->kernel_name); goto done; found: