All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor
@ 2021-05-10  9:56 Andy Shevchenko
  2021-05-10  9:56 ` [PATCH v1 2/2] device property: Don't check for NULL twice in the loops Andy Shevchenko
  2021-05-10 14:57 ` [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Rafael J. Wysocki
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2021-05-10  9:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, linux-kernel; +Cc: Rafael J. Wysocki

OF provides a specific accessor to retrieve fwnode handle.
Use it instead of direct dereferencing.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/base/property.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 1421e9548857..dd98759d688b 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -21,7 +21,7 @@
 struct fwnode_handle *dev_fwnode(struct device *dev)
 {
 	return IS_ENABLED(CONFIG_OF) && dev->of_node ?
-		&dev->of_node->fwnode : dev->fwnode;
+		of_fwnode_handle(dev->of_node) : dev->fwnode;
 }
 EXPORT_SYMBOL_GPL(dev_fwnode);
 
@@ -763,7 +763,7 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
 	struct fwnode_handle *fwnode = NULL, *next;
 
 	if (dev->of_node)
-		fwnode = &dev->of_node->fwnode;
+		fwnode = of_fwnode_handle(dev->of_node);
 	else if (adev)
 		fwnode = acpi_fwnode_handle(adev);
 
-- 
2.31.1


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

* [PATCH v1 2/2] device property: Don't check for NULL twice in the loops
  2021-05-10  9:56 [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Andy Shevchenko
@ 2021-05-10  9:56 ` Andy Shevchenko
  2021-05-10 14:53   ` Rafael J. Wysocki
  2021-05-10 14:57 ` [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Rafael J. Wysocki
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-05-10  9:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, linux-kernel; +Cc: Rafael J. Wysocki

In fwnode_get_next_available_child_node() we check next_child for NULL
twice. All the same in fwnode_get_next_parent_dev() we may avoid checking
fwnode for NULL twice.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/base/property.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index dd98759d688b..62285f1b79e3 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -632,9 +632,10 @@ struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode)
 	fwnode_handle_get(fwnode);
 	do {
 		fwnode = fwnode_get_next_parent(fwnode);
-		if (fwnode)
-			dev = get_dev_from_fwnode(fwnode);
-	} while (fwnode && !dev);
+		if (!fwnode)
+			break;
+		dev = get_dev_from_fwnode(fwnode);
+	} while (!dev);
 	fwnode_handle_put(fwnode);
 	return dev;
 }
@@ -742,10 +743,9 @@ fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
 
 	do {
 		next_child = fwnode_get_next_child_node(fwnode, next_child);
-
-		if (!next_child || fwnode_device_is_available(next_child))
+		if (!next_child)
 			break;
-	} while (next_child);
+	} while (!fwnode_device_is_available(next_child));
 
 	return next_child;
 }
-- 
2.31.1


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

* Re: [PATCH v1 2/2] device property: Don't check for NULL twice in the loops
  2021-05-10  9:56 ` [PATCH v1 2/2] device property: Don't check for NULL twice in the loops Andy Shevchenko
@ 2021-05-10 14:53   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-05-10 14:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Rafael J. Wysocki

On Mon, May 10, 2021 at 11:57 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> In fwnode_get_next_available_child_node() we check next_child for NULL
> twice. All the same in fwnode_get_next_parent_dev() we may avoid checking
> fwnode for NULL twice.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
>  drivers/base/property.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index dd98759d688b..62285f1b79e3 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -632,9 +632,10 @@ struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode)
>         fwnode_handle_get(fwnode);
>         do {
>                 fwnode = fwnode_get_next_parent(fwnode);
> -               if (fwnode)
> -                       dev = get_dev_from_fwnode(fwnode);
> -       } while (fwnode && !dev);
> +               if (!fwnode)
> +                       break;

I would return NULL from here right away.

> +               dev = get_dev_from_fwnode(fwnode);
> +       } while (!dev);
>         fwnode_handle_put(fwnode);
>         return dev;
>  }
> @@ -742,10 +743,9 @@ fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
>
>         do {
>                 next_child = fwnode_get_next_child_node(fwnode, next_child);
> -
> -               if (!next_child || fwnode_device_is_available(next_child))
> +               if (!next_child)
>                         break;

And from here too.

> -       } while (next_child);
> +       } while (!fwnode_device_is_available(next_child));
>
>         return next_child;
>  }
> --
> 2.31.1
>

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

* Re: [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor
  2021-05-10  9:56 [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Andy Shevchenko
  2021-05-10  9:56 ` [PATCH v1 2/2] device property: Don't check for NULL twice in the loops Andy Shevchenko
@ 2021-05-10 14:57 ` Rafael J. Wysocki
  1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-05-10 14:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Rafael J. Wysocki

On Mon, May 10, 2021 at 11:57 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> OF provides a specific accessor to retrieve fwnode handle.
> Use it instead of direct dereferencing.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
>  drivers/base/property.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 1421e9548857..dd98759d688b 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -21,7 +21,7 @@
>  struct fwnode_handle *dev_fwnode(struct device *dev)
>  {
>         return IS_ENABLED(CONFIG_OF) && dev->of_node ?
> -               &dev->of_node->fwnode : dev->fwnode;
> +               of_fwnode_handle(dev->of_node) : dev->fwnode;
>  }
>  EXPORT_SYMBOL_GPL(dev_fwnode);
>
> @@ -763,7 +763,7 @@ struct fwnode_handle *device_get_next_child_node(struct device *dev,
>         struct fwnode_handle *fwnode = NULL, *next;
>
>         if (dev->of_node)
> -               fwnode = &dev->of_node->fwnode;
> +               fwnode = of_fwnode_handle(dev->of_node);
>         else if (adev)
>                 fwnode = acpi_fwnode_handle(adev);
>
> --

Applied as 5.14 material, thanks!

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

end of thread, other threads:[~2021-05-10 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  9:56 [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Andy Shevchenko
2021-05-10  9:56 ` [PATCH v1 2/2] device property: Don't check for NULL twice in the loops Andy Shevchenko
2021-05-10 14:53   ` Rafael J. Wysocki
2021-05-10 14:57 ` [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Rafael J. Wysocki

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.