discover: Add DEVICE_TYPE_ANY for matching any device
authorJeremy Kerr <jk@ozlabs.org>
Thu, 30 Jan 2014 08:32:21 +0000 (16:32 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 30 Jan 2014 13:59:10 +0000 (21:59 +0800)
Currently, If we want disable all but a specific device type from
default boot, we need to add a negative priority for all other devices.

This change adds a DEVICE_TYPE_ANY definition, to allow a simpler way to
express "only boot a specific type" by default behaviour.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/device-handler.c
lib/types/types.h
ui/test/discover-test.c

index a2713904f01f4f85e30547c5a63ff643b0e46bf6..b083af4d0c6cdc0d406e9f609bcd7b387d4f6cbe 100644 (file)
@@ -372,7 +372,8 @@ static int default_timeout(void *arg)
 static bool priority_match(struct boot_priority *prio,
                struct discover_boot_option *opt)
 {
-       return prio->type == opt->device->device->type;
+       return prio->type == opt->device->device->type ||
+               prio->type == DEVICE_TYPE_ANY;
 }
 
 static int default_option_priority(struct discover_boot_option *opt)
index a1065eee62e24efe974dde1eaae11e0ba0dc5658..129319309cc0882ee36f3c7775fe56e780e1afd1 100644 (file)
@@ -9,6 +9,7 @@ enum device_type {
        DEVICE_TYPE_NETWORK,
        DEVICE_TYPE_DISK,
        DEVICE_TYPE_OPTICAL,
+       DEVICE_TYPE_ANY,
        DEVICE_TYPE_UNKNOWN,
 };
 
index 576f293f6b92881f2944baca4681cbcfc288a307..363a28978f810561ddd00991c96683ce9edd9f9a 100644 (file)
@@ -12,6 +12,8 @@ static const char *device_type_string(enum device_type type)
                return "network";
        case DEVICE_TYPE_OPTICAL:
                return "optical";
+       case DEVICE_TYPE_ANY:
+               return "any";
        case DEVICE_TYPE_UNKNOWN:
                return "unknown";
        }