mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fastboot net: add setter for global.fastboot.net.autostart
@ 2021-08-13  8:32 Marco Felsch
  2021-08-13  8:38 ` Ahmad Fatoum
  2021-08-18  4:48 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Marco Felsch @ 2021-08-13  8:32 UTC (permalink / raw)
  To: barebox

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>
---
 net/fastboot.c | 19 +++++++++++++------
 1 file 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,
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fastboot net: add setter for global.fastboot.net.autostart
  2021-08-13  8:32 [PATCH] fastboot net: add setter for global.fastboot.net.autostart Marco Felsch
@ 2021-08-13  8:38 ` Ahmad Fatoum
  2021-08-18  4:48 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-08-13  8:38 UTC (permalink / raw)
  To: Marco Felsch, barebox

On 13.08.21 10:32, Marco Felsch wrote:
> 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>

> ---
>  net/fastboot.c | 19 +++++++++++++------
>  1 file 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,
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fastboot net: add setter for global.fastboot.net.autostart
  2021-08-13  8:32 [PATCH] fastboot net: add setter for global.fastboot.net.autostart Marco Felsch
  2021-08-13  8:38 ` Ahmad Fatoum
@ 2021-08-18  4:48 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-08-18  4:48 UTC (permalink / raw)
  To: Marco Felsch; +Cc: barebox

On Fri, Aug 13, 2021 at 10:32:21AM +0200, Marco Felsch wrote:
> 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>
> ---
>  net/fastboot.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-18  4:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13  8:32 [PATCH] fastboot net: add setter for global.fastboot.net.autostart Marco Felsch
2021-08-13  8:38 ` Ahmad Fatoum
2021-08-18  4:48 ` Sascha Hauer

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git