chiark / gitweb /
fix typo in man page
[elogind.git] / udev_rules.c
index f1bbfd854cac5734ea015aa5790d1a8a7ecee737..e9b32df1c66d85a838a311f160ae889955d0f90e 100644 (file)
@@ -348,14 +348,14 @@ static int wait_for_sysfs(struct udevice *udev, const char *file, int timeout)
 
        snprintf(filename, sizeof(filename), "%s%s/%s", sysfs_path, udev->dev->devpath, file);
        filename[sizeof(filename)-1] = '\0';
-       dbg("wait %i sec for '%s'", timeout, filename);
+       dbg("will wait %i sec for '%s'", timeout, filename);
 
        while (--loop) {
                if (stat(filename, &stats) == 0) {
                        info("file '%s' appeared after %i loops", filename, (timeout * WAIT_LOOP_PER_SECOND) - loop-1);
                        return 0;
                }
-               info("wait for %i mseconds", 1000 / WAIT_LOOP_PER_SECOND);
+               info("wait for '%s' for %i mseconds", filename, 1000 / WAIT_LOOP_PER_SECOND);
                usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
        }
        err("waiting for '%s' failed", filename);
@@ -733,19 +733,13 @@ static int match_rule(struct udevice *udev, struct udev_rule *rule)
        }
 
        if (rule->wait_for_sysfs.operation != KEY_OP_UNSET) {
-               int match;
+               int found;
 
-               match = (wait_for_sysfs(udev, key_val(rule, &rule->wait_for_sysfs), 3) == 0);
-               if (match && (rule->wait_for_sysfs.operation != KEY_OP_NOMATCH)) {
-                       dbg("WAIT_FOR_SYSFS is true (matching value)");
-                       return 0;
-               }
-               if (!match && (rule->wait_for_sysfs.operation == KEY_OP_NOMATCH)) {
-                       dbg("WAIT_FOR_SYSFS is true, (non matching value)");
-                       return 0;
+               found = (wait_for_sysfs(udev, key_val(rule, &rule->wait_for_sysfs), 3) == 0);
+               if (!found && (rule->wait_for_sysfs.operation != KEY_OP_NOMATCH)) {
+                       dbg("WAIT_FOR_SYSFS failed");
+                       goto nomatch;
                }
-               dbg("WAIT_FOR_SYSFS is false");
-               return -1;
        }
 
        /* walk up the chain of parent devices and find a match */
@@ -781,6 +775,8 @@ static int match_rule(struct udevice *udev, struct udev_rule *rule)
                                size_t len;
 
                                value = sysfs_attr_get_value(udev->dev_parent->devpath, key_name);
+                               if (value == NULL)
+                                       value = sysfs_attr_get_value(udev->dev->devpath, key_name);
                                if (value == NULL)
                                        goto try_parent;
                                strlcpy(val, value, sizeof(val));