-static int whitelist_search(struct sysfs_class_device *class_dev)
-{
- char *sysblock = "/sys/block";
- int i;
-
- static char *list[] = {
- "nb",
- "ram",
- "loop",
- "fd",
- "md",
- "dos_cd",
- "double",
- "flash",
- "msd",
- "rflash",
- "rom",
- "rrom",
- "sbpcd",
- "pcd",
- "pf",
- "scd",
- "ubd",
- NULL,
- };
-
- if (strncmp(class_dev->path, sysblock, strlen(sysblock)))
- return 0;
-
- for (i=0; list[i] != NULL; i++)
- if (!strncmp(class_dev->name, list[i], strlen(list[i])))
- return 1;
-
- return 0;
-}
-
-static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_dev)
-{
- struct sysfs_device *sysfs_device;
- struct sysfs_class_device *class_dev_parent;
- int loop;
-
- /* Figure out where the device symlink is at. For char devices this will
- * always be in the class_dev->path. But for block devices, it's different.
- * The main block device will have the device symlink in it's path, but
- * all partitions have the symlink in its parent directory.
- * But we need to watch out for block devices that do not have parents, yet
- * look like a partition (fd0, loop0, etc.) They all do not have a device
- * symlink yet. We do sit and spin on waiting for them right now unless
- * they happen to be in the whitelist in which case we exit.
- */
- class_dev_parent = sysfs_get_classdev_parent(class_dev);
- if (class_dev_parent != NULL)
- dbg("given class device has a parent, use this instead");
-
- loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
- while (loop--) {
- if (udev_sleep) {
- if (whitelist_search(class_dev)) {
- sysfs_device = NULL;
- goto exit;
- }
- usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
- }
-
- if (class_dev_parent)
- sysfs_device = sysfs_get_classdev_device(class_dev_parent);
- else
- sysfs_device = sysfs_get_classdev_device(class_dev);
- if (sysfs_device != NULL)
- goto device_found;
- }
- dbg("timed out waiting for device symlink, continuing on anyway...");
-
-device_found:
- /* We have another issue with just the wait above - the sysfs part of
- * the kernel may not be quick enough to have created the link to the
- * device under the "bus" subsystem. Due to this, the sysfs_device->bus
- * will not contain the actual bus name :(
- */
- if (sysfs_device) {
- if (sysfs_device->bus[0] != '\0')
- goto bus_found;
-
- while (loop--) {
- if (udev_sleep)
- usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
- sysfs_get_device_bus(sysfs_device);
-
- if (sysfs_device->bus[0] != '\0')
- goto bus_found;
- }
- dbg("timed out waiting to find the device bus, continuing on anyway");
- goto exit;
-bus_found:
- dbg("device %s is registered with bus '%s'",
- sysfs_device->name, sysfs_device->bus);
- }
-exit:
- return sysfs_device;
-}
-
-static int match_rule(struct config_device *dev, struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)