mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fastboot net: add global.fastboot.net.autostart early
@ 2021-08-11 17:25 Marco Felsch
  2021-08-11 18:22 ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Felsch @ 2021-08-11 17:25 UTC (permalink / raw)
  To: barebox

Split adding the fastboot.net.autostart to the global device and make
use of it. With this change it is possible to set it e.g. during
environment_initcall() and the later on followed fastboot_on_boot() can
use it to start fastboot it automatically during boot.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 net/fastboot.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/net/fastboot.c b/net/fastboot.c
index df388adc89..a5a7caf526 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -547,12 +547,16 @@ 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_globalvars_init(void)
 {
-	struct fastboot_net *fbn;
-
 	globalvar_add_simple_bool("fastboot.net.autostart",
 				  &fastboot_net_autostart);
+	return 0;
+}
+
+static int fastboot_on_boot(void)
+{
+	struct fastboot_net *fbn;
 
 	if (!fastboot_net_autostart)
 		return 0;
@@ -573,6 +577,7 @@ static void fastboot_net_exit(void)
 		fastboot_net_free(fastboot_net_obj);
 }
 
+device_initcall(fastboot_net_globalvars_init);
 postenvironment_initcall(fastboot_on_boot);
 predevshutdown_exitcall(fastboot_net_exit);
 
-- 
2.30.2


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


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

* Re: [PATCH] fastboot net: add global.fastboot.net.autostart early
  2021-08-11 17:25 [PATCH] fastboot net: add global.fastboot.net.autostart early Marco Felsch
@ 2021-08-11 18:22 ` Ahmad Fatoum
  2021-08-12  7:35   ` Marco Felsch
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2021-08-11 18:22 UTC (permalink / raw)
  To: Marco Felsch, barebox

On 11.08.21 19:25, Marco Felsch wrote:
> Split adding the fastboot.net.autostart to the global device and make
> use of it. With this change it is possible to set it e.g. during
> environment_initcall() and the later on followed fastboot_on_boot() can
> use it to start fastboot it automatically during boot.

So what you fix here is use of global fastboot.net.autostart from within
init scripts, or what is your use case?

> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  net/fastboot.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/net/fastboot.c b/net/fastboot.c
> index df388adc89..a5a7caf526 100644
> --- a/net/fastboot.c
> +++ b/net/fastboot.c
> @@ -547,12 +547,16 @@ 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_globalvars_init(void)
>  {
> -	struct fastboot_net *fbn;
> -
>  	globalvar_add_simple_bool("fastboot.net.autostart",
>  				  &fastboot_net_autostart);
> +	return 0;
> +}
> +
> +static int fastboot_on_boot(void)
> +{
> +	struct fastboot_net *fbn;
>  
>  	if (!fastboot_net_autostart)
>  		return 0;
> @@ -573,6 +577,7 @@ static void fastboot_net_exit(void)
>  		fastboot_net_free(fastboot_net_obj);
>  }
>  
> +device_initcall(fastboot_net_globalvars_init);
>  postenvironment_initcall(fastboot_on_boot);
>  predevshutdown_exitcall(fastboot_net_exit);
>  
> 


-- 
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] 4+ messages in thread

* Re: [PATCH] fastboot net: add global.fastboot.net.autostart early
  2021-08-11 18:22 ` Ahmad Fatoum
@ 2021-08-12  7:35   ` Marco Felsch
  2021-08-12  8:54     ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Marco Felsch @ 2021-08-12  7:35 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

Hi Ahmad,

On 21-08-11 20:22, Ahmad Fatoum wrote:
> On 11.08.21 19:25, Marco Felsch wrote:
> > Split adding the fastboot.net.autostart to the global device and make
> > use of it. With this change it is possible to set it e.g. during
> > environment_initcall() and the later on followed fastboot_on_boot() can
> > use it to start fastboot it automatically during boot.
> 
> So what you fix here is use of global fastboot.net.autostart from within
> init scripts, or what is your use case?

Yes something like this. I have a custom board which calls
sentenv("global.fastboot.net.autostart", "1") during the
environment_initcall step.

But also I didn't get the logic behind: adding a global var in the same
function which checks that var to start the network interface.

Regards,
  Marco

> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> >  net/fastboot.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/net/fastboot.c b/net/fastboot.c
> > index df388adc89..a5a7caf526 100644
> > --- a/net/fastboot.c
> > +++ b/net/fastboot.c
> > @@ -547,12 +547,16 @@ 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_globalvars_init(void)
> >  {
> > -	struct fastboot_net *fbn;
> > -
> >  	globalvar_add_simple_bool("fastboot.net.autostart",
> >  				  &fastboot_net_autostart);
> > +	return 0;
> > +}
> > +
> > +static int fastboot_on_boot(void)
> > +{
> > +	struct fastboot_net *fbn;
> >  
> >  	if (!fastboot_net_autostart)
> >  		return 0;
> > @@ -573,6 +577,7 @@ static void fastboot_net_exit(void)
> >  		fastboot_net_free(fastboot_net_obj);
> >  }
> >  
> > +device_initcall(fastboot_net_globalvars_init);
> >  postenvironment_initcall(fastboot_on_boot);
> >  predevshutdown_exitcall(fastboot_net_exit);
> >  
> > 
> 
> 
> -- 
> 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 |
> 

-- 
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] 4+ messages in thread

* Re: [PATCH] fastboot net: add global.fastboot.net.autostart early
  2021-08-12  7:35   ` Marco Felsch
@ 2021-08-12  8:54     ` Ahmad Fatoum
  0 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2021-08-12  8:54 UTC (permalink / raw)
  To: Marco Felsch; +Cc: barebox

Hello Marco,

On 12.08.21 09:35, Marco Felsch wrote:
> Hi Ahmad,
> 
> On 21-08-11 20:22, Ahmad Fatoum wrote:
>> On 11.08.21 19:25, Marco Felsch wrote:
>>> Split adding the fastboot.net.autostart to the global device and make
>>> use of it. With this change it is possible to set it e.g. during
>>> environment_initcall() and the later on followed fastboot_on_boot() can
>>> use it to start fastboot it automatically during boot.
>>
>> So what you fix here is use of global fastboot.net.autostart from within
>> init scripts, or what is your use case?
> 
> Yes something like this. I have a custom board which calls
> sentenv("global.fastboot.net.autostart", "1") during the
> environment_initcall step.
> 
> But also I didn't get the logic behind: adding a global var in the same
> function which checks that var to start the network interface.

Global variables are synced with nv on creation, so they can be
added postenvironment and still have a different value from
the default.

I was asking because I had earlier moved global.usbgadget.autostart in
common/usbgadget.c to postenvironment, so I wondered what use case that
might have broken. To recap:

 - nv works with and without your change, because sync happens
   at globalvar add time

 - setting the variable from an environment_initcall won't work,
   without your change, as they are not registered yet that early

 - init scripts setting won't work with or without your change,

   because no one cares about fastboot_net_autostart after the

   initcalls are over


I think you should turn fastboot.net.autostart into a non
simple globalvar and enable it in the setter, just like is done
for global.usbgadget.autostart.

This allows you to set it an arbitrary time after postenvironment
and it would work. You can use it from late_initcall, in an init
script depending on whether a variable is set or from the
interactive shell.

(Maybe you could even turn the conditional in your board code into
 an init script that way)

Cheers,
Ahmad


> 
> Regards,
>   Marco
> 
>>> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
>>> ---
>>>  net/fastboot.c | 11 ++++++++---
>>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/net/fastboot.c b/net/fastboot.c
>>> index df388adc89..a5a7caf526 100644
>>> --- a/net/fastboot.c
>>> +++ b/net/fastboot.c
>>> @@ -547,12 +547,16 @@ 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_globalvars_init(void)
>>>  {
>>> -	struct fastboot_net *fbn;
>>> -
>>>  	globalvar_add_simple_bool("fastboot.net.autostart",
>>>  				  &fastboot_net_autostart);
>>> +	return 0;
>>> +}
>>> +
>>> +static int fastboot_on_boot(void)
>>> +{
>>> +	struct fastboot_net *fbn;
>>>  
>>>  	if (!fastboot_net_autostart)
>>>  		return 0;
>>> @@ -573,6 +577,7 @@ static void fastboot_net_exit(void)
>>>  		fastboot_net_free(fastboot_net_obj);
>>>  }
>>>  
>>> +device_initcall(fastboot_net_globalvars_init);
>>>  postenvironment_initcall(fastboot_on_boot);
>>>  predevshutdown_exitcall(fastboot_net_exit);
>>>  
>>>
>>
>>
>> -- 
>> 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 |
>>
> 


-- 
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] 4+ messages in thread

end of thread, other threads:[~2021-08-12  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 17:25 [PATCH] fastboot net: add global.fastboot.net.autostart early Marco Felsch
2021-08-11 18:22 ` Ahmad Fatoum
2021-08-12  7:35   ` Marco Felsch
2021-08-12  8:54     ` Ahmad Fatoum

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