X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=namedev.c;h=59ec08c715e58bdc92a52f669ecc86b8845e6e1e;hb=5a42932b9a783670ae3406fb2c3462036bb16d32;hp=7984adfb31d87fc1d42ebcefe7e9d4576cdfba24;hpb=c5118442a16940fc6ba40fd94ab28061e0f0d43b;p=elogind.git diff --git a/namedev.c b/namedev.c index 7984adfb3..59ec08c71 100644 --- a/namedev.c +++ b/namedev.c @@ -313,6 +313,19 @@ exit: return; /* here to prevent compiler warning... */ } +static void fix_kernel_name(struct udevice *udev) +{ + char *temp = udev->kernel_name; + + while (*temp != 0x00) { + /* Some block devices have a ! in their name, + * we need to change that to / */ + if (*temp == '!') + *temp = '/'; + ++temp; + } +} + static int execute_program(char *path, char *value, int len) { int retval; @@ -456,32 +469,19 @@ 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, '/'); 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 (strstr(temp, dev->id) == NULL) 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) @@ -701,11 +701,12 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud dbg("sysfs_device->bus='%s'", sysfs_device->bus); strfieldcpy(udev->bus_id, sysfs_device->bus_id); wait_for_device_to_initialize(sysfs_device); - } else { - dbg("class_dev->name = '%s'", class_dev->name); } + dbg("class_dev->name = '%s'", class_dev->name); strfieldcpy(udev->kernel_name, class_dev->name); + fix_kernel_name(udev); + dbg("udev->kernel_name = '%s'", udev->kernel_name); /* get kernel number */ pos = class_dev->name + strlen(class_dev->name);