lib/pb-config: Add autoboot timeout to configuration vars
authorJeremy Kerr <jk@ozlabs.org>
Wed, 18 Sep 2013 00:54:05 +0000 (08:54 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 18 Sep 2013 02:00:09 +0000 (10:00 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/device-handler.c
discover/device-handler.h
lib/pb-config/pb-config.c
lib/pb-config/pb-config.h

index ccc7cc3d01dc8ce0d5fa01f5dc885042461af0dc..a06dafc03c6f92808f6c0c35a28b9dfaed470e04 100644 (file)
@@ -419,7 +419,7 @@ static void set_default(struct device_handler *handler,
                return;
 
        handler->default_boot_option = opt;
-       handler->sec_to_boot = DEFAULT_BOOT_TIMEOUT_SEC;
+       handler->sec_to_boot = config_get()->autoboot_timeout_sec;
 
        pb_log("Boot option %s set as default, timeout %u sec.\n",
               opt->option->id, handler->sec_to_boot);
index 693f5e45a229e66a71cd069049e10486c536cdd7..0cd9c595fb535058e21da4a90fa4906de26fe7b8 100644 (file)
@@ -3,8 +3,6 @@
 
 #include <list/list.h>
 
-#define DEFAULT_BOOT_TIMEOUT_SEC       10
-
 struct device_handler;
 struct discover_device;
 struct discover_server;
index 315d9905659369ea8224f4ef8318de459138786e..53ed6d6e2b31ebab2df2abaf13e11bb7401f9909 100644 (file)
@@ -13,6 +13,7 @@ static struct config_storage  *storage;
 static void config_set_defaults(struct config *config)
 {
        config->autoboot_enabled = true;
+       config->autoboot_timeout_sec = 10;
        config->network.interfaces = NULL;
        config->network.n_interfaces = 0;
 }
@@ -23,8 +24,11 @@ static void dump_config(struct config *config)
 
        pb_log("configuration:\n");
 
-       pb_log(" autoboot: %s\n",
-                       config->autoboot_enabled ? "enabled" : "disabled");
+       if (config->autoboot_enabled)
+               pb_log(" autoboot: enabled, %d sec\n",
+                               config->autoboot_timeout_sec);
+       else
+               pb_log(" autoboot: disabled\n");
 
        if (config->network.n_interfaces || config->network.n_dns_servers)
                pb_log(" network configuration:\n");
index 6a64ef116670030783e685350b82313f24add494..c74fa1b530188410478e3414a2c8759a813fdfda 100644 (file)
@@ -32,6 +32,7 @@ struct network_config {
 
 struct config {
        bool                    autoboot_enabled;
+       int                     autoboot_timeout_sec;
        struct network_config   network;
 };