+static int do_label(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
+{
+ struct sysfs_attribute *tmpattr = NULL;
+ struct config_device *dev;
+ struct list_head *tmp;
+
+ list_for_each(tmp, &config_device_list) {
+ dev = list_entry(tmp, struct config_device, node);
+ if (dev->type != LABEL)
+ continue;
+
+ dbg_parse("LABEL: match file '%s' with value '%s'",
+ dev->sysfs_file, dev->sysfs_value);
+ /* try to find the attribute in the class device directory */
+ tmpattr = sysfs_get_classdev_attr(class_dev, dev->sysfs_file);
+ if (tmpattr)
+ goto label_found;
+
+ /* look in the class device directory if present */
+ if (sysfs_device) {
+ tmpattr = sysfs_get_device_attr(sysfs_device, dev->sysfs_file);
+ if (tmpattr)
+ goto label_found;
+ }
+
+ continue;
+
+label_found:
+ tmpattr->value[strlen(tmpattr->value)-1] = 0x00;
+ dbg_parse("file '%s' found with value '%s' compare with '%s'", dev->sysfs_file, tmpattr->value, dev->sysfs_value);
+ if (strcmp(dev->sysfs_value, tmpattr->value) != 0)
+ continue;
+
+ strfieldcpy(udev->name, dev->name);
+ if (dev->mode != 0) {
+ udev->mode = dev->mode;
+ strfieldcpy(udev->owner, dev->owner);
+ strfieldcpy(udev->group, dev->group);
+ }
+ dbg_parse("file '%s' with value '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dev->sysfs_file, dev->sysfs_value, udev->name,
+ dev->owner, dev->group, dev->mode);
+
+ return 0;
+ }
+ return -ENODEV;
+}
+
+static int do_number(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
+{
+ struct config_device *dev;
+ struct list_head *tmp;
+ char path[SYSFS_PATH_MAX];
+ int found;
+ char *temp = NULL;
+
+ /* we have to have a sysfs device for NUMBER to work */
+ if (!sysfs_device)
+ return -ENODEV;
+
+ list_for_each(tmp, &config_device_list) {
+ dev = list_entry(tmp, struct config_device, node);
+ if (dev->type != NUMBER)
+ continue;
+
+ found = 0;
+ strfieldcpy(path, sysfs_device->path);
+ temp = strrchr(path, '/');
+ dbg_parse("NUMBER path = '%s'", path);
+ dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id);
+ if (strstr(temp, dev->id) != NULL) {
+ found = 1;
+ } else {
+ *temp = 0x00;
+ temp = strrchr(path, '/');
+ dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id);
+ if (strstr(temp, dev->id) != NULL)
+ found = 1;
+ }
+ if (!found)
+ continue;
+ strfieldcpy(udev->name, dev->name);
+ if (dev->mode != 0) {
+ udev->mode = dev->mode;
+ strfieldcpy(udev->owner, dev->owner);
+ strfieldcpy(udev->group, dev->group);
+ }
+ dbg_parse("device id '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dev->id, udev->name,
+ dev->owner, dev->group, dev->mode);
+ return 0;
+ }
+ return -ENODEV;
+}
+
+