mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* How to handle more than one network device in barebox
@ 2011-02-17 10:57 Juergen Beisert
  2011-02-17 11:24 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Beisert @ 2011-02-17 10:57 UTC (permalink / raw)
  To: barebox

Hi,

due to the fact (all?) network device drivers in barebox are using xzalloc to 
allocate their "struct eth_device" the embedded "struct dev's" '.id' is 
always '0'. So the registration of a second network device fails always with

 register_device: already registered eth0

Currently there is no way to overwrite the network device's ID. If I init 
the "edev->dev.id" with '-1', it works. But it would be nice to define the 
network device ordering from inside the platform (and not only with the order 
I register the base devices). And copying the ".id" from the registered base 
device also does not work if the network devices are of different type, due 
to the framework starts with index 0 for different names.

Any ideas how to?

Regards,
Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |

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

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

* Re: How to handle more than one network device in barebox
  2011-02-17 10:57 How to handle more than one network device in barebox Juergen Beisert
@ 2011-02-17 11:24 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2011-02-17 11:24 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

On Thu, Feb 17, 2011 at 11:57:14AM +0100, Juergen Beisert wrote:
> Hi,
> 
> due to the fact (all?) network device drivers in barebox are using xzalloc to 
> allocate their "struct eth_device" the embedded "struct dev's" '.id' is 
> always '0'. So the registration of a second network device fails always with
> 
>  register_device: already registered eth0
> 
> Currently there is no way to overwrite the network device's ID. If I init 
> the "edev->dev.id" with '-1', it works. But it would be nice to define the 
> network device ordering from inside the platform (and not only with the order 
> I register the base devices). And copying the ".id" from the registered base 
> device also does not work if the network devices are of different type, due 
> to the framework starts with index 0 for different names.
> 
> Any ideas how to?

I stumbled upon this aswell.

I solved this with the following patch which I forgot to send to the
list. It still does not solve the issue that the order of network
devices is defined by the registration order, but at least it makes
multiple network devices work again.

Sascha

commit fe1864bdcf237a3ed0f5391e1cbd6cec13b518bc
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Thu Feb 3 13:07:57 2011 +0100

    network: initialize new net device id with -1
    
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

diff --git a/net/eth.c b/net/eth.c
index 8333d80..9eae17c 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -151,6 +151,7 @@ int eth_register(struct eth_device *edev)
 	}
 
 	strcpy(edev->dev.name, "eth");
+	edev->dev.id = -1;
 	register_device(&edev->dev);
 
 	dev->type_data = edev;

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

end of thread, other threads:[~2011-02-17 11:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-17 10:57 How to handle more than one network device in barebox Juergen Beisert
2011-02-17 11:24 ` Sascha Hauer

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