summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2021-08-13 10:32:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-08-23 16:09:26 +0200
commit0d0060b2380afc029bb0d91186ac340f7ac1023f (patch)
tree6f1606224ac3d50a32ef18d4bc6eb34eefd95261 /net
parent688773c64c99f9a718daef5bfca541df48bb2098 (diff)
downloadbarebox-0d0060b2380afc029bb0d91186ac340f7ac1023f.tar.gz
barebox-0d0060b2380afc029bb0d91186ac340f7ac1023f.tar.xz
fastboot net: add setter for global.fastboot.net.autostart
Without this change the only possible way to start the fastboot.net.autostart mechanism is by using the nv storage. Split fastboot_on_boot() into two functions: - a globalvar setter fastboot_net_autostart_set() and - a the globalvar init function fastboot_net_init_globalvar(). This allows init scripts to start the autostart mechanism as well. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210813083221.31763-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r--net/fastboot.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/net/fastboot.c b/net/fastboot.c
index df388adc89..aa483f57a7 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -547,14 +547,12 @@ fail_generic_init:
static struct fastboot_net *fastboot_net_obj;
static int fastboot_net_autostart;
-static int fastboot_on_boot(void)
+static int fastboot_net_autostart_set(struct param_d *p, void * priv)
{
struct fastboot_net *fbn;
+ static bool started;
- globalvar_add_simple_bool("fastboot.net.autostart",
- &fastboot_net_autostart);
-
- if (!fastboot_net_autostart)
+ if (!fastboot_net_autostart || started)
return 0;
ifup_all(0);
@@ -564,16 +562,25 @@ static int fastboot_on_boot(void)
return PTR_ERR(fbn);
fastboot_net_obj = fbn;
+ started = true;
+
return 0;
}
+static int fastboot_net_init_globalvar(void)
+{
+ return globalvar_add_bool("fastboot.net.autostart",
+ fastboot_net_autostart_set,
+ &fastboot_net_autostart, NULL);
+}
+
static void fastboot_net_exit(void)
{
if (fastboot_net_obj)
fastboot_net_free(fastboot_net_obj);
}
-postenvironment_initcall(fastboot_on_boot);
+postenvironment_initcall(fastboot_net_init_globalvar);
predevshutdown_exitcall(fastboot_net_exit);
BAREBOX_MAGICVAR(global.fastboot.net.autostart,