mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* barebox state alias with same name as node doesn't work
@ 2019-01-17 16:16 Ian Abbott
  2019-01-17 21:10 ` Andrey Smirnov
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Abbott @ 2019-01-17 16:16 UTC (permalink / raw)
  To: Barebox List

Hi,

All the examples of "barebox,state" compatible nodes I can find in 
Barebox seem to follow this basic pattern:

/ {
   /* ... */
   aliases {
     /* ... */
     state = &state;
   };
   /* ... */
   state: state {
     magic = <0xdeadbeef>; /* or whatever */
     compatible = "barebox,state";
     /* ... */
   };
   /* ... */
};

Note that the alias name is the same as the node name in the above example.

However, when I try to follow that pattern for my own board, I get an 
error (-EINVAL):

ERROR: register_device: already registered state

This is because the node "state" has been already registered as a device 
called "state" by of_platform_device_create() (via of_probe() and 
of_arm_init()).  Later, the state device driver is initialized and 
state_probe() is called on the device that was previously registered. 
state_probe() calls state_new_from_node() which calls of_alias_get() to 
get the name of the alias for this device (the alias is also called 
"state" in this example), and calls state_new() with this alias name. 
state_new() allocates a struct state with an embedded struct device_d, 
sets the device name to the alias name it was called with ("state"), and 
calls register_device() to register this embedded struct device_d.  The 
call to register_device() fails with return value -EINVAL because the 
name is not unique.

I'm wondering if this has ever worked or whether there is a regression 
bug.  I fixed it on my board by renaming node to "state_nor", keeping 
the alias name as "state".

I'm currently using Barebox 2018.12.0, but I don't see any relevant 
changes in Barebox 2019.01.0 or barebox-next.

Best regards,
Ian Abbott.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

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

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

* Re: barebox state alias with same name as node doesn't work
  2019-01-17 16:16 barebox state alias with same name as node doesn't work Ian Abbott
@ 2019-01-17 21:10 ` Andrey Smirnov
  2019-01-18  7:02   ` Sascha Hauer
  2019-01-18 15:58   ` Ian Abbott
  0 siblings, 2 replies; 4+ messages in thread
From: Andrey Smirnov @ 2019-01-17 21:10 UTC (permalink / raw)
  To: Ian Abbott; +Cc: Barebox List

On Thu, Jan 17, 2019 at 8:16 AM Ian Abbott <abbotti@mev.co.uk> wrote:
>
> Hi,
>
> All the examples of "barebox,state" compatible nodes I can find in
> Barebox seem to follow this basic pattern:
>
> / {
>    /* ... */
>    aliases {
>      /* ... */
>      state = &state;
>    };
>    /* ... */
>    state: state {
>      magic = <0xdeadbeef>; /* or whatever */
>      compatible = "barebox,state";
>      /* ... */
>    };
>    /* ... */
> };
>
> Note that the alias name is the same as the node name in the above example.
>
> However, when I try to follow that pattern for my own board, I get an
> error (-EINVAL):
>
> ERROR: register_device: already registered state
>
> This is because the node "state" has been already registered as a device
> called "state" by of_platform_device_create() (via of_probe() and
> of_arm_init()).  Later, the state device driver is initialized and
> state_probe() is called on the device that was previously registered.
> state_probe() calls state_new_from_node() which calls of_alias_get() to
> get the name of the alias for this device (the alias is also called
> "state" in this example), and calls state_new() with this alias name.
> state_new() allocates a struct state with an embedded struct device_d,
> sets the device name to the alias name it was called with ("state"), and
> calls register_device() to register this embedded struct device_d.  The
> call to register_device() fails with return value -EINVAL because the
> name is not unique.
>
> I'm wondering if this has ever worked or whether there is a regression
> bug.  I fixed it on my board by renaming node to "state_nor", keeping
> the alias name as "state".
>
> I'm currently using Barebox 2018.12.0, but I don't see any relevant
> changes in Barebox 2019.01.0 or barebox-next.
>

This should be fixed by:
http://lists.infradead.org/pipermail/barebox/2018-November/035432.html
I don't think it is a part of 2018.12.0, though

Thanks,
Andrey Smirnov

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

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

* Re: barebox state alias with same name as node doesn't work
  2019-01-17 21:10 ` Andrey Smirnov
@ 2019-01-18  7:02   ` Sascha Hauer
  2019-01-18 15:58   ` Ian Abbott
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2019-01-18  7:02 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List, Ian Abbott

On Thu, Jan 17, 2019 at 01:10:46PM -0800, Andrey Smirnov wrote:
> On Thu, Jan 17, 2019 at 8:16 AM Ian Abbott <abbotti@mev.co.uk> wrote:
> >
> >
> > I'm currently using Barebox 2018.12.0, but I don't see any relevant
> > changes in Barebox 2019.01.0 or barebox-next.
> >
> 
> This should be fixed by:
> http://lists.infradead.org/pipermail/barebox/2018-November/035432.html
> I don't think it is a part of 2018.12.0, though


Indeed not, but it should have been :(
Sorry, I missed that one.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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: barebox state alias with same name as node doesn't work
  2019-01-17 21:10 ` Andrey Smirnov
  2019-01-18  7:02   ` Sascha Hauer
@ 2019-01-18 15:58   ` Ian Abbott
  1 sibling, 0 replies; 4+ messages in thread
From: Ian Abbott @ 2019-01-18 15:58 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

On 17/01/2019 21:10, Andrey Smirnov wrote:
> On Thu, Jan 17, 2019 at 8:16 AM Ian Abbott <abbotti@mev.co.uk> wrote:
>>
>> Hi,
>>
>> All the examples of "barebox,state" compatible nodes I can find in
>> Barebox seem to follow this basic pattern:
>>
>> / {
>>     /* ... */
>>     aliases {
>>       /* ... */
>>       state = &state;
>>     };
>>     /* ... */
>>     state: state {
>>       magic = <0xdeadbeef>; /* or whatever */
>>       compatible = "barebox,state";
>>       /* ... */
>>     };
>>     /* ... */
>> };
>>
>> Note that the alias name is the same as the node name in the above example.
>>
>> However, when I try to follow that pattern for my own board, I get an
>> error (-EINVAL):
>>
>> ERROR: register_device: already registered state
[snip]
>> I'm currently using Barebox 2018.12.0, but I don't see any relevant
>> changes in Barebox 2019.01.0 or barebox-next.
>>
> 
> This should be fixed by:
> http://lists.infradead.org/pipermail/barebox/2018-November/035432.html
> I don't think it is a part of 2018.12.0, though

That explains it!  I've now updated to 2019.01.0 to pick up the change 
and it seems to work now.  Thanks for the help.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

_______________________________________________
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:[~2019-01-18 15:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 16:16 barebox state alias with same name as node doesn't work Ian Abbott
2019-01-17 21:10 ` Andrey Smirnov
2019-01-18  7:02   ` Sascha Hauer
2019-01-18 15:58   ` Ian Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox