+
+int udev_rules_get_run(struct udevice *udev, struct sysfs_device *sysfs_device)
+{
+ struct udev_rule *rule;
+
+ /* look for a matching rule to apply */
+ list_for_each_entry(rule, &udev_rule_list, node) {
+ dbg("process rule");
+
+ if (rule->run_operation == KEY_OP_UNSET)
+ continue;
+
+ if (rule->name_operation != KEY_OP_UNSET || rule->symlink_operation != KEY_OP_UNSET ||
+ rule->mode != 0000 || rule->owner[0] != '\0' || rule->group[0] != '\0') {
+ dbg("skip rule that names a device");
+ continue;
+ }
+
+ if (match_rule(udev, rule, NULL, sysfs_device) == 0) {
+ if (rule->ignore_device) {
+ info("configured rule in '%s[%i]' applied, '%s' is ignored",
+ rule->config_file, rule->config_line, udev->kernel_name);
+ udev->ignore_device = 1;
+ return 0;
+ }
+
+ if (!udev->run_final && rule->run_operation != KEY_OP_UNSET) {
+ char program[PATH_SIZE];
+
+ if (rule->run_operation == KEY_OP_ASSIGN || rule->run_operation == KEY_OP_ASSIGN_FINAL) {
+ struct name_entry *name_loop;
+ struct name_entry *temp_loop;
+
+ info("reset run list");
+ list_for_each_entry_safe(name_loop, temp_loop, &udev->run_list, node) {
+ list_del(&name_loop->node);
+ free(name_loop);
+ }
+ }
+ if (rule->run[0] != '\0') {
+ strlcpy(program, rule->run, sizeof(program));
+ apply_format(udev, program, sizeof(program), NULL, NULL);
+ dbg("add run '%s'", program);
+ name_list_add(&udev->run_list, program, 0);
+ }
+ if (rule->run_operation == KEY_OP_ASSIGN_FINAL)
+ break;
+ }
+
+ if (rule->last_rule) {
+ dbg("last rule to be applied");
+ break;
+ }
+ }
+ }
+
+ return 0;
+}