[PATCH v2 2/7] driver: Add rescan hook to struct device
Sascha Hauer
s.hauer at pengutronix.de
Thu Mar 9 07:41:05 PST 2023
On Thu, Mar 09, 2023 at 02:08:50PM +0100, Ahmad Fatoum wrote:
> On 09.03.23 12:52, Sascha Hauer wrote:
> > When devices are enabled with a device tree overlay the newly enabled
> > devices can be probed by doing a of_probe(). This works fine for the
> > regular platform devices, but doesn't work for devices which are not
> > probed by the core, but by the subsystem. Prominent examples are I2C or
> > SPI devices.
> >
> > This patch adds a struct device::rescan hook that subsystems can
> > implement to trigger rescanning the device nodes.
> >
> > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> > ---
> > drivers/of/platform.c | 11 +++++------
> > include/driver.h | 6 ++++++
> > 2 files changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> > index edb082b106..2e9abe32bc 100644
> > --- a/drivers/of/platform.c
> > +++ b/drivers/of/platform.c
> > @@ -153,8 +153,10 @@ struct device *of_platform_device_create(struct device_node *np,
> > * Linux uses the OF_POPULATED flag to skip already populated/created
> > * devices.
> > */
> > - if (np->dev)
> > + if (np->dev) {
> > + device_rescan(np->dev);
> > return np->dev;
> > + }
> >
> > /* count the io resources */
> > if (of_can_translate_address(np))
> > @@ -420,11 +422,8 @@ static struct device *of_device_create_on_demand(struct device_node *np)
> > if (!parent)
> > return NULL;
> >
> > - if (!np->dev && parent->dev) {
> > - ret = device_detect(parent->dev);
> > - if (ret && ret != -ENOSYS)
> > - return ERR_PTR(ret);
> > - }
>
> The int ret definition at the top of the function should be ok to be removed now.
No, it's still used.
Sascha
--
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 |
More information about the barebox
mailing list