- /* Yup, this rule belongs to us! */
- info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
- udev_rules_filename, dev->config_line, udev->kernel_name, dev->name);
- strfieldcpy(udev->name, dev->name);
- strfieldcpy(udev->symlink, dev->symlink);
- goto found;
+}
+
+int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *udev)
+{
+ struct sysfs_device *sysfs_device = NULL;
+ struct config_device *dev;
+ struct perm_device *perm;
+ char *pos;
+
+ udev->mode = 0;
+
+ /* find the sysfs_device associated with this class device */
+ sysfs_device = get_sysfs_device(class_dev);
+ if (sysfs_device) {
+ dbg("sysfs_device->path='%s'", sysfs_device->path);
+ dbg("sysfs_device->bus_id='%s'", sysfs_device->bus_id);
+ dbg("sysfs_device->bus='%s'", sysfs_device->bus);
+ strfieldcpy(udev->bus_id, sysfs_device->bus_id);
+ wait_for_device_to_initialize(sysfs_device);
+ }
+ 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);
+ while (isdigit(*(pos-1)))
+ pos--;
+ strfieldcpy(udev->kernel_number, pos);
+ dbg("kernel_number='%s'", udev->kernel_number);
+
+ /* look for a matching rule to apply */
+ list_for_each_entry(dev, &config_device_list, node) {
+ dbg("process rule");
+ if (match_rule(dev, class_dev, udev, sysfs_device) == 0) {
+ if (dev->name[0] == '\0') {
+ info("configured rule in '%s' at line %i applied, '%s' is ignored",
+ udev_rules_filename, dev->config_line, udev->kernel_name);
+ return -1;
+ }
+
+ info("configured rule in '%s' at line %i applied, '%s' becomes '%s'",
+ udev_rules_filename, dev->config_line, udev->kernel_name, dev->name);
+ strfieldcpy(udev->name, dev->name);
+ strfieldcpy(udev->symlink, dev->symlink);
+ goto found;
+ }