All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] drivers property: When no children in primary, try secondary
@ 2020-05-20 10:29 Andy Shevchenko
  2020-05-20 10:34 ` Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-05-20 10:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel,
	Sakari Ailus, Heikki Krogerus
  Cc: Andy Shevchenko

Software firmware nodes can provide a child node to its parent.
Since software node can be secondary, we need a mechanism to access
the children. The idea is to list children of the primary node first
and when they are finished, continue with secondary node if available.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/property.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 5f35c0ccf5e0..1e6d75e65938 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -708,14 +708,23 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
 						 struct fwnode_handle *child)
 {
 	struct acpi_device *adev = ACPI_COMPANION(dev);
-	struct fwnode_handle *fwnode = NULL;
+	struct fwnode_handle *fwnode = NULL, *next;
 
 	if (dev->of_node)
 		fwnode = &dev->of_node->fwnode;
 	else if (adev)
 		fwnode = acpi_fwnode_handle(adev);
 
-	return fwnode_get_next_child_node(fwnode, child);
+	/* Try to find a child in primary fwnode */
+	next = fwnode_get_next_child_node(fwnode, child);
+	if (next)
+		return next;
+
+	/* When no more children in primary, continue with secondary */
+	if (!IS_ERR_OR_NULL(fwnode->secondary))
+		next = fwnode_get_next_child_node(fwnode->secondary, child);
+
+	return next;
 }
 EXPORT_SYMBOL_GPL(device_get_next_child_node);
 
-- 
2.26.2


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

* Re: [PATCH v1] drivers property: When no children in primary, try secondary
  2020-05-20 10:29 [PATCH v1] drivers property: When no children in primary, try secondary Andy Shevchenko
@ 2020-05-20 10:34 ` Rafael J. Wysocki
  2020-05-20 10:48   ` Greg Kroah-Hartman
  2020-05-20 10:36 ` Sakari Ailus
  2020-05-20 10:39 ` Heikki Krogerus
  2 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2020-05-20 10:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linux Kernel Mailing List,
	Sakari Ailus, Heikki Krogerus

On Wed, May 20, 2020 at 12:30 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Software firmware nodes can provide a child node to its parent.
> Since software node can be secondary, we need a mechanism to access
> the children. The idea is to list children of the primary node first
> and when they are finished, continue with secondary node if available.

Makes sense.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Greg, do you want me to apply it?

If you'd rather take it yourself, please feel free to add

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/base/property.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 5f35c0ccf5e0..1e6d75e65938 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -708,14 +708,23 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
>                                                  struct fwnode_handle *child)
>  {
>         struct acpi_device *adev = ACPI_COMPANION(dev);
> -       struct fwnode_handle *fwnode = NULL;
> +       struct fwnode_handle *fwnode = NULL, *next;
>
>         if (dev->of_node)
>                 fwnode = &dev->of_node->fwnode;
>         else if (adev)
>                 fwnode = acpi_fwnode_handle(adev);
>
> -       return fwnode_get_next_child_node(fwnode, child);
> +       /* Try to find a child in primary fwnode */
> +       next = fwnode_get_next_child_node(fwnode, child);
> +       if (next)
> +               return next;
> +
> +       /* When no more children in primary, continue with secondary */
> +       if (!IS_ERR_OR_NULL(fwnode->secondary))
> +               next = fwnode_get_next_child_node(fwnode->secondary, child);
> +
> +       return next;
>  }
>  EXPORT_SYMBOL_GPL(device_get_next_child_node);
>
> --
> 2.26.2
>

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

* Re: [PATCH v1] drivers property: When no children in primary, try secondary
  2020-05-20 10:29 [PATCH v1] drivers property: When no children in primary, try secondary Andy Shevchenko
  2020-05-20 10:34 ` Rafael J. Wysocki
@ 2020-05-20 10:36 ` Sakari Ailus
  2020-05-20 10:39 ` Heikki Krogerus
  2 siblings, 0 replies; 5+ messages in thread
From: Sakari Ailus @ 2020-05-20 10:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, Heikki Krogerus

Thanks, Andy!

On Wed, May 20, 2020 at 01:29:59PM +0300, Andy Shevchenko wrote:
> Software firmware nodes can provide a child node to its parent.
> Since software node can be secondary, we need a mechanism to access
> the children. The idea is to list children of the primary node first
> and when they are finished, continue with secondary node if available.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus

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

* Re: [PATCH v1] drivers property: When no children in primary, try secondary
  2020-05-20 10:29 [PATCH v1] drivers property: When no children in primary, try secondary Andy Shevchenko
  2020-05-20 10:34 ` Rafael J. Wysocki
  2020-05-20 10:36 ` Sakari Ailus
@ 2020-05-20 10:39 ` Heikki Krogerus
  2 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2020-05-20 10:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, Sakari Ailus

On Wed, May 20, 2020 at 01:29:59PM +0300, Andy Shevchenko wrote:
> Software firmware nodes can provide a child node to its parent.
> Since software node can be secondary, we need a mechanism to access
> the children. The idea is to list children of the primary node first
> and when they are finished, continue with secondary node if available.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/base/property.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 5f35c0ccf5e0..1e6d75e65938 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -708,14 +708,23 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
>  						 struct fwnode_handle *child)
>  {
>  	struct acpi_device *adev = ACPI_COMPANION(dev);
> -	struct fwnode_handle *fwnode = NULL;
> +	struct fwnode_handle *fwnode = NULL, *next;
>  
>  	if (dev->of_node)
>  		fwnode = &dev->of_node->fwnode;
>  	else if (adev)
>  		fwnode = acpi_fwnode_handle(adev);
>  
> -	return fwnode_get_next_child_node(fwnode, child);
> +	/* Try to find a child in primary fwnode */
> +	next = fwnode_get_next_child_node(fwnode, child);
> +	if (next)
> +		return next;
> +
> +	/* When no more children in primary, continue with secondary */
> +	if (!IS_ERR_OR_NULL(fwnode->secondary))
> +		next = fwnode_get_next_child_node(fwnode->secondary, child);
> +
> +	return next;
>  }
>  EXPORT_SYMBOL_GPL(device_get_next_child_node);

Thanks Andy,

-- 
heikki

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

* Re: [PATCH v1] drivers property: When no children in primary, try secondary
  2020-05-20 10:34 ` Rafael J. Wysocki
@ 2020-05-20 10:48   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-20 10:48 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, Linux Kernel Mailing List, Sakari Ailus,
	Heikki Krogerus

On Wed, May 20, 2020 at 12:34:06PM +0200, Rafael J. Wysocki wrote:
> On Wed, May 20, 2020 at 12:30 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > Software firmware nodes can provide a child node to its parent.
> > Since software node can be secondary, we need a mechanism to access
> > the children. The idea is to list children of the primary node first
> > and when they are finished, continue with secondary node if available.
> 
> Makes sense.
> 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Greg, do you want me to apply it?
> 
> If you'd rather take it yourself, please feel free to add
> 
> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

I can take it, there's other driver core patches in my tree already :)

thanks,

greg k-h

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

end of thread, other threads:[~2020-05-20 10:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 10:29 [PATCH v1] drivers property: When no children in primary, try secondary Andy Shevchenko
2020-05-20 10:34 ` Rafael J. Wysocki
2020-05-20 10:48   ` Greg Kroah-Hartman
2020-05-20 10:36 ` Sakari Ailus
2020-05-20 10:39 ` Heikki Krogerus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.