mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH] fastboot net: add setter for global.fastboot.net.autostart
Date: Fri, 13 Aug 2021 10:38:28 +0200	[thread overview]
Message-ID: <ab106998-cb7b-16cc-ad30-29fd29831075@pengutronix.de> (raw)
In-Reply-To: <20210813083221.31763-1-m.felsch@pengutronix.de>

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


  reply	other threads:[~2021-08-13  8:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  8:32 Marco Felsch
2021-08-13  8:38 ` Ahmad Fatoum [this message]
2021-08-18  4:48 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab106998-cb7b-16cc-ad30-29fd29831075@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox