+/* list of devices that we should run first due to any one of a number of reasons */
+static char *first_list[] = {
+ "/class/mem",
+ "/class/tty",
+ NULL,
+};
+
+static int add_device(const char *devpath)
+{
+ struct sysfs_device *dev;
+ struct udevice *udev;
+ int retval = 0;
+
+ /* clear and set environment for next event */
+ clearenv();
+ setenv("ACTION", "add", 1);
+ setenv("UDEV_START", "1", 1);
+ if (udev_log_str)
+ setenv("UDEV_LOG", udev_log_str, 1);
+ if (udev_run_str)
+ setenv("UDEV_RUN", udev_run_str, 1);
+
+ dev = sysfs_device_get(devpath);
+ if (dev == NULL)
+ return -1;
+
+ udev = udev_device_init(NULL);
+ if (udev == NULL)
+ return -1;
+
+ /* override built-in sysfs device */
+ udev->dev = dev;
+ strcpy(udev->action, "add");
+
+ if (strcmp(udev->dev->subsystem, "net") != 0) {
+ udev->devt = udev_device_get_devt(udev);
+ if (major(udev->devt) == 0)
+ return -1;
+ }
+
+ dbg("add '%s'", udev->dev->devpath);
+ setenv("DEVPATH", udev->dev->devpath, 1);
+ setenv("SUBSYSTEM", udev->dev->subsystem, 1);
+
+ udev_rules_get_name(&rules, udev);
+ if (udev->ignore_device) {
+ dbg("device event will be ignored");
+ goto exit;
+ }
+ if (udev->name[0] != '\0')
+ retval = udev_device_event(&rules, udev);
+ else
+ info("device node creation supressed");
+
+ if (retval == 0 && udev_run)
+ udev_rules_run(udev);
+
+exit:
+ udev_device_cleanup(udev);
+ return 0;
+}
+