Skip to contentSkip to conversation

Preparation for further fwnode property cleanup

PATCH In review Sakari Ailus 3 participants 7 messages May 24, 2017 – Jun 7, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v6 cover Preparation for further fwnode property cleanup

Hi Rob, Frank, others,

Here's the 6th version of what used to be a single patch to prepare for fwnode property cleanup.

Beyond this, I have a couple of other patchsets I'll post in the near future:

- fwnode property cleanup (for linux-pm) which moves the property API implementation to FW specific locations; depends on these patches,

- V4L2 fwnode patches (for media_tree, no unmerged dependencies, pull request sent) and

- fwnode const patchset which allows making the fwnode argument for the property API functions const. It depends on both of the previous sets. Might be for linux-pm.

since v5:

- Add "pr_fmt" macro missed when splitting base.c (1st patch).

- Add a missing newline (1st patch).

- Use parentheses around macro aguments (2nd and 3rd patch).

since v4:

- Add patch "of: Support const and non-const use for to_of_node()" to the set.

- Make nop is_of_node() and to_of_node() const-correct if OF is disabled. (since v4.1)

since v3:

- Rebase the first patch (no conflicts),

- Add another patch for to make of_fwnode_handle() handle NULL argument gracefully.

Sakari Ailus (3):
of: Move OF property and graph API from base.c to property.c
of: Make of_fwnode_handle() safer
of: Support const and non-const use for to_of_node()

 drivers/of/Makefile   |   2 +-
 drivers/of/base.c     | 733 ------------------------------------------------
 drivers/of/property.c | 763 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of.h    |  30 +-
 4 files changed, 784 insertions(+), 744 deletions(-)
 create mode 100644 drivers/of/property.c
Signature · 24 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


*** BLURB HERE ***

Sakari Ailus (3):
  of: Move OF property and graph API from base.c to property.c
  of: Make of_fwnode_handle() safer
  of: Support const and non-const use for to_of_node()

 drivers/of/Makefile   |   2 +-
 drivers/of/base.c     | 733 -----------------------------------------------
 drivers/of/property.c | 766 ++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of.h    |  30 +-
 4 files changed, 787 insertions(+), 744 deletions(-)
 create mode 100644 drivers/of/property.c

-- 
2.7.4
#1 lore raw

PATCH v6 1/3 of: Move OF property and graph API from base.c to property.c

base.c contains both core OF functions and increasingly other functionality such as accessing properties and graphs, including convenience functions. In the near future this would also include OF specific implementation of the fwnode property and graph APIs.

Create driver/of/property.c to contain procedures for accessing and interpreting device tree properties. The procedures are moved from drivers/of/base.c, with no changes other than copying only the includes required by the moved procedures.

---
 drivers/of/Makefile   |   2 +-
 drivers/of/base.c     | 733 -----------------------------------------------
 drivers/of/property.c | 766 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 767 insertions(+), 734 deletions(-)
 create mode 100644 drivers/of/property.c
drivers/of/Makefile +1 -1
index d7efd9d..97dc01c 100644
@@ -1,4 +1,4 @@
-obj-y = base.o device.o platform.o
+obj-y = base.o device.o platform.o property.o
 obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
 obj-$(CONFIG_OF_FLATTREE) += fdt.o
 obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o
drivers/of/base.c +0 -733

748 lines not on this page · raw message

drivers/of/property.c new file +766 -0

766 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH v6 2/3 of: Make of_fwnode_handle() safer

In reply to Sakari Ailus

On the expense of a little bit more complexity in the of_fwnode_handle() macro, make the macro result in NULL in case its argument is NULL while still referencing it only once.

---
 include/linux/of.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/of.h +7 -1
index 50fcdb5..f05c87f 100644
@@ -159,7 +159,13 @@ static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
 		container_of(fwnode, struct device_node, fwnode) : NULL;
 }
 
-#define of_fwnode_handle(node) (&(node)->fwnode)
+#define of_fwnode_handle(node)						\
+	({								\
+		typeof(node) __of_fwnode_handle_node = (node);		\
+									\
+		__of_fwnode_handle_node ?				\
+			&__of_fwnode_handle_node->fwnode : NULL;	\
+	})
 
 static inline bool of_have_populated_dt(void)
 {
Signature · 1 line
2.7.4
#3 lore raw

PATCH v6 3/3 of: Support const and non-const use for to_of_node()

In reply to Sakari Ailus

Turn to_of_node() into a macro in order to support both const and non-const use. Additionally make the fwnode argument to is_of_node() const as well.

---
 include/linux/of.h | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
include/linux/of.h +12 -8
index f05c87f..29b7b738b 100644
@@ -148,16 +148,20 @@ extern raw_spinlock_t devtree_lock;
 #ifdef CONFIG_OF
 void of_core_init(void);
 
-static inline bool is_of_node(struct fwnode_handle *fwnode)
+static inline bool is_of_node(const struct fwnode_handle *fwnode)
 {
 	return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF;
 }
 
-static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
-{
-	return is_of_node(fwnode) ?
-		container_of(fwnode, struct device_node, fwnode) : NULL;
-}
+#define to_of_node(__fwnode)						\
+	({								\
+		typeof(__fwnode) __to_of_node_fwnode = (__fwnode);	\
+									\
+		is_of_node(__to_of_node_fwnode) ?			\
+			container_of(__to_of_node_fwnode,		\
+				     struct device_node, fwnode) :	\
+			NULL;						\
+	})
 
 #define of_fwnode_handle(node)						\
 	({								\
@@ -539,12 +543,12 @@ static inline void of_core_init(void)
 {
 }
 
-static inline bool is_of_node(struct fwnode_handle *fwnode)
+static inline bool is_of_node(const struct fwnode_handle *fwnode)
 {
 	return false;
 }
 
-static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
+static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode)
 {
 	return NULL;
 }
Signature · 1 line
2.7.4
#4 lore raw
In reply to Sakari Ailus

Hi Rob,

Quoted 11 lines · Sakari Ailus

Hi Rob, Frank, others,

Here's the 6th version of what used to be a single patch to prepare for fwnode property cleanup.

Beyond this, I have a couple of other patchsets I'll post in the near future:

- fwnode property cleanup (for linux-pm) which moves the property API implementation to FW specific locations; depends on these patches,

Quoted 6 lines

- V4L2 fwnode patches (for media_tree, no unmerged dependencies, pull request sent) and

- fwnode const patchset which allows making the fwnode argument for the property API functions const. It depends on both of the previous sets. Might be for linux-pm.

I figured out that others are starting to have patches that depend on my other patchsets getting merged. Those patches are for the fwnode property API that most likely should go through the linux-pm tree as well as for the media tree.

<URL:http://www.spinics.net/lists/linux-media/msg115893.html>

I have hopes of being able to get the fwnode cleanup patchset (which the aforementioned patches depend on) in within this merge window --- assuming I could have your ack on the OF portions.

Would it be possible to have an immutable branch for these or would you accept a pull request on v4.12-rc1?

Thanks.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
maintainer
#5 lore raw
Quoted 26 lines · Sakari Ailus

Hi Rob,

Quoted 11 lines · Sakari Ailus

Hi Rob, Frank, others,

Here's the 6th version of what used to be a single patch to prepare for fwnode property cleanup.

Beyond this, I have a couple of other patchsets I'll post in the near future:

- fwnode property cleanup (for linux-pm) which moves the property API implementation to FW specific locations; depends on these patches,

Quoted 6 lines

- V4L2 fwnode patches (for media_tree, no unmerged dependencies, pull request sent) and

- fwnode const patchset which allows making the fwnode argument for the property API functions const. It depends on both of the previous sets. Might be for linux-pm.

I figured out that others are starting to have patches that depend on my other patchsets getting merged. Those patches are for the fwnode property API that most likely should go through the linux-pm tree as well as for the media tree.

Quoted 8 lines

<URL:http://www.spinics.net/lists/linux-media/msg115893.html>

I have hopes of being able to get the fwnode cleanup patchset (which the aforementioned patches depend on) in within this merge window --- assuming I could have your ack on the OF portions.

Would it be possible to have an immutable branch for these or would you accept a pull request on v4.12-rc1?

I've applied this series. The stable branch is here:

git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git dt/property-move

Rob

#6 lore raw

Hi Rob / Frank,

Quoted 11 lines · Rob Herring
Quoted 11 lines

I figured out that others are starting to have patches that depend on my other patchsets getting merged. Those patches are for the fwnode property API that most likely should go through the linux-pm tree as well as for the media tree.

<URL:http://www.spinics.net/lists/linux-media/msg115893.html>

I have hopes of being able to get the fwnode cleanup patchset (which the aforementioned patches depend on) in within this merge window --- assuming I could have your ack on the OF portions.

Quoted 6 lines
Quoted 2 lines

Would it be possible to have an immutable branch for these or would you accept a pull request on v4.12-rc1?

I've applied this series. The stable branch is here:

git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git dt/property-move

Thanks you!

Could I still have yours / Frank's ack on the fwnode cleanup set patches 2--4 that touch the OF framework, please (naturally assuming you're fine with them)?

<URL:http://www.spinics.net/lists/devicetree/msg179939.html>

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]