chiark / gitweb /
add $driver subtitution
authorHannes Reinecke <hare@suse.de>
Wed, 25 Jul 2007 13:24:58 +0000 (15:24 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 25 Jul 2007 13:24:58 +0000 (15:24 +0200)
udev.7
udev.xml
udev_rules.c

diff --git a/udev.7 b/udev.7
index d3ed4b71d680a794c4ff63d8064b4b50a42a611e..821a476aefe3eeb39f408e7ff97eeffe09672be4 100644 (file)
--- a/udev.7
+++ b/udev.7
@@ -335,6 +335,16 @@ and
 \fBATTRS\fR.
 .RE
 .PP
 \fBATTRS\fR.
 .RE
 .PP
+\fB$driver\fR, \fB%d\fR
+.RS 4
+The driver name of the device matched while searching the devpath upwards for
+\fBSUBSYSTEMS\fR,
+\fBKERNELS\fR,
+\fBDRIVERS\fR
+and
+\fBATTRS\fR.
+.RE
+.PP
 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
 .RS 4
 The value of a sysfs attribute found at the device, where all keys of the rule have matched. If the matching device does not have such an attribute, all devices along the chain of parents are searched for a matching attribute. If the attribute is a symlink, the last element of the symlink target is returned as the value.
 \fB$attr{\fR\fB\fIfile\fR\fR\fB}\fR, \fB%s{\fR\fB\fIfile\fR\fR\fB}\fR
 .RS 4
 The value of a sysfs attribute found at the device, where all keys of the rule have matched. If the matching device does not have such an attribute, all devices along the chain of parents are searched for a matching attribute. If the attribute is a symlink, the last element of the symlink target is returned as the value.
index 520c718c7a98a0e0d7a1e6575b05763020609e76..b43abb779bd47e55a07863e9206c74516e1587e4 100644 (file)
--- a/udev.xml
+++ b/udev.xml
               </listitem>
             </varlistentry>
 
               </listitem>
             </varlistentry>
 
+            <varlistentry>
+              <term><option>$driver</option>, <option>%d</option></term>
+              <listitem>
+                <para>The driver name of the device matched while searching the devpath upwards for
+                  <option>SUBSYSTEMS</option>, <option>KERNELS</option>, <option>DRIVERS</option> and <option>ATTRS</option>.
+                </para>
+              </listitem>
+            </varlistentry>
+
             <varlistentry>
               <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
               <listitem>
             <varlistentry>
               <term><option>$attr{<replaceable>file</replaceable>}</option>, <option>%s{<replaceable>file</replaceable>}</option></term>
               <listitem>
index daf3d7fff7992841ab766b10a0339712828dabf2..3674a27d636a71785793ac4087ed611fcb905b13 100644 (file)
@@ -597,6 +597,7 @@ void udev_rules_apply_format(struct udevice *udev, char *string, size_t maxsize)
                SUBST_KERNEL,
                SUBST_KERNEL_NUMBER,
                SUBST_ID,
                SUBST_KERNEL,
                SUBST_KERNEL_NUMBER,
                SUBST_ID,
+               SUBST_DRIVER,
                SUBST_MAJOR,
                SUBST_MINOR,
                SUBST_RESULT,
                SUBST_MAJOR,
                SUBST_MINOR,
                SUBST_RESULT,
@@ -616,6 +617,7 @@ void udev_rules_apply_format(struct udevice *udev, char *string, size_t maxsize)
                { .name = "number",     .fmt = 'n',     .type = SUBST_KERNEL_NUMBER },
                { .name = "kernel",     .fmt = 'k',     .type = SUBST_KERNEL },
                { .name = "id",         .fmt = 'b',     .type = SUBST_ID },
                { .name = "number",     .fmt = 'n',     .type = SUBST_KERNEL_NUMBER },
                { .name = "kernel",     .fmt = 'k',     .type = SUBST_KERNEL },
                { .name = "id",         .fmt = 'b',     .type = SUBST_ID },
+               { .name = "driver",     .fmt = 'd',     .type = SUBST_DRIVER },
                { .name = "major",      .fmt = 'M',     .type = SUBST_MAJOR },
                { .name = "minor",      .fmt = 'm',     .type = SUBST_MINOR },
                { .name = "result",     .fmt = 'c',     .type = SUBST_RESULT },
                { .name = "major",      .fmt = 'M',     .type = SUBST_MAJOR },
                { .name = "minor",      .fmt = 'm',     .type = SUBST_MINOR },
                { .name = "result",     .fmt = 'c',     .type = SUBST_RESULT },
@@ -707,6 +709,12 @@ found:
                                dbg("substitute id '%s'", udev->dev_parent->kernel);
                        }
                        break;
                                dbg("substitute id '%s'", udev->dev_parent->kernel);
                        }
                        break;
+               case SUBST_DRIVER:
+                       if (udev->dev_parent != NULL) {
+                               strlcat(string, udev->dev_parent->driver, maxsize);
+                               dbg("substitute driver '%s'", udev->dev_parent->driver);
+                       }
+                       break;
                case SUBST_MAJOR:
                        sprintf(temp2, "%d", major(udev->devt));
                        strlcat(string, temp2, maxsize);
                case SUBST_MAJOR:
                        sprintf(temp2, "%d", major(udev->devt));
                        strlcat(string, temp2, maxsize);