[RFC] device probe order

Sascha Hauer s.hauer at pengutronix.de
Mon Jan 4 00:56:11 PST 2016


On Thu, Dec 24, 2015 at 04:42:25PM +0300, Peter Mamonov wrote:
> On Thu, 24 Dec 2015 12:48:37 +0300
> Peter Mamonov <pmamonov at gmail.com> wrote:
> 
> > On Wed, 23 Dec 2015 18:04:43 +0100
> > Alexander Aring <alex.aring at gmail.com> wrote:
> > 
> > > On Wed, Dec 23, 2015 at 07:56:44PM +0300, Peter Mamonov wrote:
> > > > On Wed, 23 Dec 2015 17:35:51 +0100
> > > > Alexander Aring <alex.aring at gmail.com> wrote:
> > > > 
> > > > > On Wed, Dec 23, 2015 at 07:10:58PM +0300, Peter Mamonov wrote:
> > > > > > Dear All,
> > > > > > 
> > > > > > I've ported an UHCI driver from the u-boot to the barebox
> > > > > > (WIP). To interoperate with the EHCI driver, the UHCI driver
> > > > > > should be probed ater the EHCI driver. Both drivers are binded
> > > > > > via the device tree mechanism. How can i achieve the correct
> > > > > > probe order?
> > > > > > 
> > > > > 
> > > > > Normally this should done by returning "-EPROBE_DEFER" inside
> > > > > the probe function. There was some RFC last years for supporting
> > > > > EPROBE_DEFER [0] and it seems these are mainline.
> > > > > 
> > > > > However you need some bool which indicates that the EHCI driver
> > > > > is probed.
> > > > 
> > > > Thanks, Alex. As i understand, this is the linux-way solution.
> > > > 
> > > > Sasha, is it ok to add a global variable to indicate the EHCI
> > > > presence? Or should we follow the way proposed by the mentioned
> > > > RFCs, i.e. introduce dependencies between drivers?
> > > > 
> > > 
> > > mhhh, maybe a simple "get_device_by_name" works here.
> > > 
> > > If returning NULL then return -EPROBE_DEFER. Don't know if this is a
> > > good solution, name need to be unique then.
> > > 
> > > 
> > > btw:
> > > Just found that "of_find_device_by_node" returns -EPROBE_DEFER when
> > > nothing was found. This was introduced by the patch series.
> > 
> > I like this approach better, than introducing a global variable.
> > Will look further into it.
> 
> Unfortunately of_find_device_by_node() returns a valid pointer to
> the device before the device probe function is called. I guess
> get_device_by_name() behaves in the same way.

This looks buggy. There should be a way to tell if a device has been
probed or not before working with the device returned by
of_find_device_by_node() or get_device_by_name(). The easiest way is
probably to check for dev->driver. This is not enough though to tell if
the device probe has failed, not yet executed, or deferred. Maybe we
could store the probe status of a device in struct device_d itself.

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 |



More information about the barebox mailing list