summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-01-30 16:19:20 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-01-30 21:59:10 +0800
commitaa530148044a7c6d7ec7b6a32672cc69d53979b2 (patch)
tree09e9ef7bb4a1f0c6976657c581553bb00ea5c40f /discover/device-handler.c
parenta984595cfb4910ba6f464c69c316f1613f10f894 (diff)
downloadtalos-petitboot-aa530148044a7c6d7ec7b6a32672cc69d53979b2.tar.gz
talos-petitboot-aa530148044a7c6d7ec7b6a32672cc69d53979b2.zip
discover: Make boot_priorities more flexible
Rather than rely on the ordering of the boot_priorities array to define which device types have a higher "default boot" priority, this change introduces a slightly more flexible way of priority lookups, by adding a separate priority field to struct boot_priority. This means we can have an unordered array, change priorities without re-writing the array, and implementing a disable mechanism. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index c57b7b6..a271390 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -386,28 +386,36 @@ static int default_option_priority(struct discover_boot_option *opt)
for (i = 0; i < config->n_boot_priorities; i++) {
prio = &config->boot_priorities[i];
if (priority_match(prio, opt))
- break;
+ return prio->priority;
}
- return i;
+ return 0;
}
static void set_default(struct device_handler *handler,
struct discover_boot_option *opt)
{
+ int new_prio;
+
if (!handler->autoboot_enabled)
return;
+ new_prio = default_option_priority(opt);
+
+ /* A negative priority indicates that we don't want to boot this device
+ * by default */
+ if (new_prio < 0)
+ return;
+
/* Resolve any conflicts: if we have a new default option, it only
* replaces the current if it has a higher priority. */
if (handler->default_boot_option) {
- int new_prio, cur_prio;
+ int cur_prio;
- new_prio = default_option_priority(opt);
cur_prio = default_option_priority(
handler->default_boot_option);
- if (new_prio < cur_prio) {
+ if (new_prio > cur_prio) {
handler->default_boot_option = opt;
/* extend the timeout a little, so the user sees some
* indication of the change */
OpenPOWER on IntegriCloud