[<prev] [next>] [day] [month] [year] [list]
Message-ID: <c98b39a7195006fdd24590b8d11bb271a72a0c8a.1749453752.git.mazziesaccount@gmail.com>
Date: Mon, 9 Jun 2025 10:26:47 +0300
From: Matti Vaittinen <mazziesaccount@...il.com>
To: Matti Vaittinen <mazziesaccount@...il.com>,
Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Daniel Scally <djrscally@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>
Subject: [PATCH RESEND] device property: Use tidy for_each_named_* macros
Implementing if-conditions inside for_each_x() macros requires some
thinking to avoid side effects in the calling code. Resulting code
may look somewhat awkward, and there are couple of different ways it is
usually done.
Standardizing this to one way can help making it more obvious for a code
reader and writer. The newly added for_each_if() is a way to achieve this.
Use for_each_if() to make these macros look like many others which
should in the long run help reading the code.
Signed-off-by: Matti Vaittinen <mazziesaccount@...il.com>
Acked-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
I am pretty sure I forgot to re-spin this earlier. Well, better late
than never :) Link to previous mail:
https://lore.kernel.org/all/Z_ew4DN0z71nCX3C@mva-rohm/
I suppose this can now go through a proper tree, because prerequisite
patches were already merged to v6.16-rc1. (Assuming IIO is not the most
natural one for this.) CC'ing still Jonathan so things aren't left
hanging in the air for him :)
---
include/linux/property.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/linux/property.h b/include/linux/property.h
index f718dd4789e5..82f0cb3abd1e 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -17,6 +17,7 @@
#include <linux/fwnode.h>
#include <linux/stddef.h>
#include <linux/types.h>
+#include <linux/util_macros.h>
struct device;
@@ -169,7 +170,7 @@ struct fwnode_handle *fwnode_get_next_available_child_node(
#define fwnode_for_each_named_child_node(fwnode, child, name) \
fwnode_for_each_child_node(fwnode, child) \
- if (!fwnode_name_eq(child, name)) { } else
+ for_each_if(fwnode_name_eq(child, name))
#define fwnode_for_each_available_child_node(fwnode, child) \
for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
@@ -184,7 +185,7 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev,
#define device_for_each_named_child_node(dev, child, name) \
device_for_each_child_node(dev, child) \
- if (!fwnode_name_eq(child, name)) { } else
+ for_each_if(fwnode_name_eq(child, name))
#define device_for_each_child_node_scoped(dev, child) \
for (struct fwnode_handle *child __free(fwnode_handle) = \
@@ -193,7 +194,7 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev,
#define device_for_each_named_child_node_scoped(dev, child, name) \
device_for_each_child_node_scoped(dev, child) \
- if (!fwnode_name_eq(child, name)) { } else
+ for_each_if(fwnode_name_eq(child, name))
struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
const char *childname);
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
--
2.49.0
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists