summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2018-07-03 16:34:44 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-07-10 13:00:55 +1000
commitbfe0549660d297809cda489c6b09db8132007ea0 (patch)
treef72f386313020d1eda87ff86322301cc9639e5d4 /discover/device-handler.c
parent6598baa0bd34db9a9c446500a940ec034375b523 (diff)
downloadtalos-petitboot-bfe0549660d297809cda489c6b09db8132007ea0.tar.gz
talos-petitboot-bfe0549660d297809cda489c6b09db8132007ea0.zip
discover/handler: Split autoboot matching into a new function
A future change will want to match autoboot option settings, so abstract this into its own function. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 42c95bb..d1fdffe 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -797,24 +797,31 @@ static bool ipmi_device_type_matches(enum ipmi_bootdev ipmi_type,
return false;
}
+static bool autoboot_option_matches(struct autoboot_option *opt,
+ struct discover_device *dev)
+{
+ if (opt->boot_type == BOOT_DEVICE_UUID)
+ if (!strcmp(opt->uuid, dev->uuid))
+ return true;
+
+ if (opt->boot_type == BOOT_DEVICE_TYPE)
+ if (opt->type == dev->device->type ||
+ opt->type == DEVICE_TYPE_ANY)
+ return true;
+
+ return false;
+}
+
static int autoboot_option_priority(const struct config *config,
struct discover_boot_option *opt)
{
- enum device_type type = opt->device->device->type;
- const char *uuid = opt->device->uuid;
struct autoboot_option *auto_opt;
unsigned int i;
for (i = 0; i < config->n_autoboot_opts; i++) {
auto_opt = &config->autoboot_opts[i];
- if (auto_opt->boot_type == BOOT_DEVICE_UUID)
- if (!strcmp(auto_opt->uuid, uuid))
- return DEFAULT_PRIORITY_LOCAL_FIRST + i;
-
- if (auto_opt->boot_type == BOOT_DEVICE_TYPE)
- if (auto_opt->type == type ||
- auto_opt->type == DEVICE_TYPE_ANY)
- return DEFAULT_PRIORITY_LOCAL_FIRST + i;
+ if (autoboot_option_matches(auto_opt, opt->device))
+ return DEFAULT_PRIORITY_LOCAL_FIRST + i;
}
return -1;
OpenPOWER on IntegriCloud