mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 2/7] driver: Add rescan hook to struct device
Date: Thu, 9 Mar 2023 13:54:24 +0100	[thread overview]
Message-ID: <8c6d39c0-1295-8593-03ba-bdd771691da7@pengutronix.de> (raw)
In-Reply-To: <20230309115208.973893-3-s.hauer@pengutronix.de>

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@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@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);
> -	}
> +	if (!np->dev && parent->dev)
> +		device_rescan(parent->dev);
>  
>  	if (!np->dev)
>  		pr_debug("Creating device for %s\n", np->full_name);
> diff --git a/include/driver.h b/include/driver.h
> index f53668711b..91e1f01974 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -91,6 +91,7 @@ struct device {
>  	 * when the driver should actually detect client devices
>  	 */
>  	int     (*detect) (struct device *);
> +	void	(*rescan) (struct device *);
>  
>  	/*
>  	 * if a driver probe is deferred, this stores the last error
> @@ -158,7 +159,12 @@ static inline void put_device(struct device *dev) {}
>  void free_device_res(struct device *dev);
>  void free_device(struct device *dev);
>  
> +static inline void device_rescan(struct device *dev)
> +{
> +	if (dev->rescan)
> +		dev->rescan(dev);
>  
> +}
>  /* Iterate over a devices children
>   */
>  #define device_for_each_child(dev, child) \

-- 
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 |




  reply	other threads:[~2023-03-09 12:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 11:52 [PATCH v2 0/7] support overlays to the barebox live tree Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 1/7] kbuild: Add target to build dtb overlay files Sascha Hauer
2023-03-09 13:24   ` Ahmad Fatoum
2023-03-09 15:28     ` Sascha Hauer
2023-03-09 15:33       ` Ahmad Fatoum
2023-03-09 15:35         ` Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 2/7] driver: Add rescan hook to struct device Sascha Hauer
2023-03-09 12:54   ` Ahmad Fatoum [this message]
2023-03-09 13:39     ` Ahmad Fatoum
2023-03-09 13:08   ` Ahmad Fatoum
2023-03-09 15:41     ` Sascha Hauer
2023-03-10  8:37       ` Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 3/7] i2c: implement rescan Sascha Hauer
2023-03-09 13:02   ` Ahmad Fatoum
2023-03-09 15:54     ` Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 4/7] spi: Directly register SPI device Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 5/7] spi: reduce scope of 'chip' Sascha Hauer
2023-03-09 11:52 ` [PATCH v2 6/7] spi: implement rescan Sascha Hauer
2023-03-09 13:03   ` Ahmad Fatoum
2023-03-09 11:52 ` [PATCH v2 7/7] of_overlay: Add option to apply overlay to live tree Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c6d39c0-1295-8593-03ba-bdd771691da7@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox