]> err.no Git - systemd/commitdiff
[PATCH] read %s{}-sysfs values at any device in the chain
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Mon, 28 Mar 2005 09:22:17 +0000 (11:22 +0200)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:55:00 +0000 (23:55 -0700)
test/udev-test.pl
udev_rules.c

index 5d7c5e5b8169c2910a451785b38de694196398d8..ed94629dd1a5437d9b6c413d5f145c215eb32ca6 100644 (file)
@@ -1222,6 +1222,15 @@ EOF
                exp_name        => "sane",
                rules           => <<EOF
 BUS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e name; (/sbin/badprogram)", RESULT="name_ _/sbin/badprogram_", NAME="sane"
+EOF
+       },
+       {
+               desc            => "read sysfs value from device down in the chain",
+               subsys          => "block",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "serial-0000:00:09.0",
+               rules           => <<EOF
+KERNEL=="ttyUSB*", NAME="serial-%s{serial}"
 EOF
        },
 );
index 2fca33d06338f06afa4ba78e9f05be3628ebb26e..00199a062fd844a137baeb4486f1b3bca814b5f8 100644 (file)
@@ -287,8 +287,18 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
                                break;
                        }
                        if (find_sysfs_attribute(class_dev, sysfs_device, attr, temp2, sizeof(temp2)) != 0) {
-                               dbg("sysfs attribute '%s' not found", attr);
-                               break;
+                               struct sysfs_device *parent_device;
+
+                               dbg("sysfs attribute '%s' not found, walk up the physical devices", attr);
+                               parent_device = sysfs_get_device_parent(sysfs_device);
+                               while (parent_device) {
+                                       dbg("looking at '%s'", parent_device->path);
+                                       if (find_sysfs_attribute(NULL, parent_device, attr, temp2, sizeof(temp2)) == 0)
+                                               break;
+                                       parent_device = sysfs_get_device_parent(parent_device);
+                               }
+                               if (!parent_device)
+                                       break;
                        }
                        /* strip trailing whitespace of sysfs value */
                        i = strlen(temp2);