public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] driver core & device property: clean up APIs
@ 2024-02-23 15:54 Andy Shevchenko
  2024-02-23 15:54 ` [PATCH v2 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-23 15:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, Christophe JAILLET,
	Sakari Ailus, linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown

There are two, but dependent pair of patches that:
- hides unused devlink APIs
- removes 'proxy' header use

v2:
- most of the patches were sent separately as v1, thus this series is v2
- harvested tags from that patches (Sakari, Saravana)

Andy Shevchenko (4):
  driver core: Drop unneeded 'extern' keyword in fwnode.h
  driver core: Move fw_devlink stuff to where it belongs
  device property: Move enum dev_dma_attr to fwnode.h
  device property: Don't use "proxy" headers

 drivers/base/core.c      | 58 ++++++++++++++++++++++++++++++++++
 drivers/base/property.c  | 67 ++++------------------------------------
 drivers/base/swnode.c    | 13 +++++++-
 include/linux/fwnode.h   | 13 +++++---
 include/linux/property.h |  9 +-----
 5 files changed, 86 insertions(+), 74 deletions(-)

-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h
  2024-02-23 15:54 [PATCH v2 0/4] driver core & device property: clean up APIs Andy Shevchenko
@ 2024-02-23 15:54 ` Andy Shevchenko
  2024-02-23 15:54 ` [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-23 15:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, Christophe JAILLET,
	Sakari Ailus, linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown,
	Saravana Kannan

We do not use 'extern' keyword with functions. Remove the last one
mistakenly added to fwnode.h.

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/fwnode.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 2a72f55d26eb..2d23a14857c7 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -209,9 +209,9 @@ static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode,
 		fwnode->flags &= ~FWNODE_FLAG_INITIALIZED;
 }
 
-extern bool fw_devlink_is_strict(void);
 int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup);
 void fwnode_links_purge(struct fwnode_handle *fwnode);
 void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
+bool fw_devlink_is_strict(void);
 
 #endif
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs
  2024-02-23 15:54 [PATCH v2 0/4] driver core & device property: clean up APIs Andy Shevchenko
  2024-02-23 15:54 ` [PATCH v2 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h Andy Shevchenko
@ 2024-02-23 15:54 ` Andy Shevchenko
  2024-02-28 21:14   ` Rafael J. Wysocki
  2024-02-23 15:54 ` [PATCH v2 3/4] device property: Move enum dev_dma_attr to fwnode.h Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-23 15:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, Christophe JAILLET,
	Sakari Ailus, linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown

A few APIs that belong specifically to the fw_devlink APIs
- are exposed to others without need
- prevents device property code to be cleaned up in the future

Resolve this mess by moving fw_devlink code to where it belongs
and hide from others.

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/core.c      | 58 ++++++++++++++++++++++++++++++++++++++++
 drivers/base/property.c  | 56 --------------------------------------
 include/linux/fwnode.h   |  1 -
 include/linux/property.h |  2 --
 4 files changed, 58 insertions(+), 59 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 9828da9b933c..35ccd8bb2c9b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1871,6 +1871,7 @@ static void fw_devlink_unblock_consumers(struct device *dev)
 	device_links_write_unlock();
 }
 
+#define get_dev_from_fwnode(fwnode)	get_device((fwnode)->dev)
 
 static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
 {
@@ -1901,6 +1902,63 @@ static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode)
 	return false;
 }
 
+/**
+ * fwnode_is_ancestor_of - Test if @ancestor is ancestor of @child
+ * @ancestor: Firmware which is tested for being an ancestor
+ * @child: Firmware which is tested for being the child
+ *
+ * A node is considered an ancestor of itself too.
+ *
+ * Return: true if @ancestor is an ancestor of @child. Otherwise, returns false.
+ */
+static bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor,
+				  const struct fwnode_handle *child)
+{
+	struct fwnode_handle *parent;
+
+	if (IS_ERR_OR_NULL(ancestor))
+		return false;
+
+	if (child == ancestor)
+		return true;
+
+	fwnode_for_each_parent_node(child, parent) {
+		if (parent == ancestor) {
+			fwnode_handle_put(parent);
+			return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * fwnode_get_next_parent_dev - Find device of closest ancestor fwnode
+ * @fwnode: firmware node
+ *
+ * Given a firmware node (@fwnode), this function finds its closest ancestor
+ * firmware node that has a corresponding struct device and returns that struct
+ * device.
+ *
+ * The caller is responsible for calling put_device() on the returned device
+ * pointer.
+ *
+ * Return: a pointer to the device of the @fwnode's closest ancestor.
+ */
+static struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode)
+{
+	struct fwnode_handle *parent;
+	struct device *dev;
+
+	fwnode_for_each_parent_node(fwnode, parent) {
+		dev = get_dev_from_fwnode(parent);
+		if (dev) {
+			fwnode_handle_put(parent);
+			return dev;
+		}
+	}
+	return NULL;
+}
+
 /**
  * __fw_devlink_relax_cycles - Relax and mark dependency cycles.
  * @con: Potential consumer device.
diff --git a/drivers/base/property.c b/drivers/base/property.c
index a1b01ab42052..afa1bf2b3c5a 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -699,34 +699,6 @@ struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode)
 }
 EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
 
-/**
- * fwnode_get_next_parent_dev - Find device of closest ancestor fwnode
- * @fwnode: firmware node
- *
- * Given a firmware node (@fwnode), this function finds its closest ancestor
- * firmware node that has a corresponding struct device and returns that struct
- * device.
- *
- * The caller is responsible for calling put_device() on the returned device
- * pointer.
- *
- * Return: a pointer to the device of the @fwnode's closest ancestor.
- */
-struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode)
-{
-	struct fwnode_handle *parent;
-	struct device *dev;
-
-	fwnode_for_each_parent_node(fwnode, parent) {
-		dev = get_dev_from_fwnode(parent);
-		if (dev) {
-			fwnode_handle_put(parent);
-			return dev;
-		}
-	}
-	return NULL;
-}
-
 /**
  * fwnode_count_parents - Return the number of parents a node has
  * @fwnode: The node the parents of which are to be counted
@@ -773,34 +745,6 @@ struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL_GPL(fwnode_get_nth_parent);
 
-/**
- * fwnode_is_ancestor_of - Test if @ancestor is ancestor of @child
- * @ancestor: Firmware which is tested for being an ancestor
- * @child: Firmware which is tested for being the child
- *
- * A node is considered an ancestor of itself too.
- *
- * Return: true if @ancestor is an ancestor of @child. Otherwise, returns false.
- */
-bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor, const struct fwnode_handle *child)
-{
-	struct fwnode_handle *parent;
-
-	if (IS_ERR_OR_NULL(ancestor))
-		return false;
-
-	if (child == ancestor)
-		return true;
-
-	fwnode_for_each_parent_node(child, parent) {
-		if (parent == ancestor) {
-			fwnode_handle_put(parent);
-			return true;
-		}
-	}
-	return false;
-}
-
 /**
  * fwnode_get_next_child_node - Return the next child node handle for a node
  * @fwnode: Firmware node to find the next child node for.
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 2d23a14857c7..416cbe72f0c7 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -187,7 +187,6 @@ struct fwnode_operations {
 		if (fwnode_has_op(fwnode, op))				\
 			(fwnode)->ops->op(fwnode, ## __VA_ARGS__);	\
 	} while (false)
-#define get_dev_from_fwnode(fwnode)	get_device((fwnode)->dev)
 
 static inline void fwnode_init(struct fwnode_handle *fwnode,
 			       const struct fwnode_operations *ops)
diff --git a/include/linux/property.h b/include/linux/property.h
index e6516d0b7d52..284ff79ebf03 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -156,11 +156,9 @@ struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
 	for (parent = fwnode_get_parent(fwnode); parent;	\
 	     parent = fwnode_get_next_parent(parent))
 
-struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode);
 unsigned int fwnode_count_parents(const struct fwnode_handle *fwn);
 struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn,
 					    unsigned int depth);
-bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor, const struct fwnode_handle *child);
 struct fwnode_handle *fwnode_get_next_child_node(
 	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
 struct fwnode_handle *fwnode_get_next_available_child_node(
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 3/4] device property: Move enum dev_dma_attr to fwnode.h
  2024-02-23 15:54 [PATCH v2 0/4] driver core & device property: clean up APIs Andy Shevchenko
  2024-02-23 15:54 ` [PATCH v2 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h Andy Shevchenko
  2024-02-23 15:54 ` [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs Andy Shevchenko
@ 2024-02-23 15:54 ` Andy Shevchenko
  2024-02-23 15:54 ` [PATCH v2 4/4] device property: Don't use "proxy" headers Andy Shevchenko
  2024-02-28 21:01 ` [PATCH v2 0/4] driver core & device property: clean up APIs Rafael J. Wysocki
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-23 15:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, Christophe JAILLET,
	Sakari Ailus, linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown

The struct fwnode_operations defines one of the callback to return
enum dev_dma_attr. But this currently is defined in property.h.
Move it to the correct location.

Fixes: 8c756a0a2de1 ("device property: Convert device_{dma_supported,get_dma_attr} to fwnode")
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/fwnode.h   | 6 ++++++
 include/linux/property.h | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 416cbe72f0c7..4228c45d5ccc 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -14,6 +14,12 @@
 #include <linux/bits.h>
 #include <linux/err.h>
 
+enum dev_dma_attr {
+	DEV_DMA_NOT_SUPPORTED,
+	DEV_DMA_NON_COHERENT,
+	DEV_DMA_COHERENT,
+};
+
 struct fwnode_operations;
 struct device;
 
diff --git a/include/linux/property.h b/include/linux/property.h
index 284ff79ebf03..1f0135e24d00 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -27,12 +27,6 @@ enum dev_prop_type {
 	DEV_PROP_REF,
 };
 
-enum dev_dma_attr {
-	DEV_DMA_NOT_SUPPORTED,
-	DEV_DMA_NON_COHERENT,
-	DEV_DMA_COHERENT,
-};
-
 const struct fwnode_handle *__dev_fwnode_const(const struct device *dev);
 struct fwnode_handle *__dev_fwnode(struct device *dev);
 #define dev_fwnode(dev)							\
-- 
2.43.0.rc1.1.gbec44491f096


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

* [PATCH v2 4/4] device property: Don't use "proxy" headers
  2024-02-23 15:54 [PATCH v2 0/4] driver core & device property: clean up APIs Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-02-23 15:54 ` [PATCH v2 3/4] device property: Move enum dev_dma_attr to fwnode.h Andy Shevchenko
@ 2024-02-23 15:54 ` Andy Shevchenko
  2024-02-28 21:01 ` [PATCH v2 0/4] driver core & device property: clean up APIs Rafael J. Wysocki
  4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-23 15:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andy Shevchenko, Christophe JAILLET,
	Sakari Ailus, linux-kernel, linux-acpi
  Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown

Update header inclusions to follow IWYU (Include What You Use)
principle.

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/property.c  | 11 ++++++-----
 drivers/base/swnode.c    | 13 ++++++++++++-
 include/linux/fwnode.h   |  4 ++--
 include/linux/property.h |  1 +
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index afa1bf2b3c5a..7324a704a9a1 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -7,15 +7,16 @@
  *          Mika Westerberg <mika.westerberg@linux.intel.com>
  */
 
-#include <linux/acpi.h>
+#include <linux/device.h>
+#include <linux/err.h>
 #include <linux/export.h>
-#include <linux/kernel.h>
+#include <linux/kconfig.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_graph.h>
-#include <linux/of_irq.h>
 #include <linux/property.h>
 #include <linux/phy.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/types.h>
 
 struct fwnode_handle *__dev_fwnode(struct device *dev)
 {
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 36512fb75a20..eb6eb25b343b 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -6,10 +6,21 @@
  * Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
  */
 
+#include <linux/container_of.h>
 #include <linux/device.h>
-#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/export.h>
+#include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/kstrtox.h>
+#include <linux/list.h>
 #include <linux/property.h>
 #include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
 
 #include "base.h"
 
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 4228c45d5ccc..80f3cd91b471 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -9,10 +9,10 @@
 #ifndef _LINUX_FWNODE_H_
 #define _LINUX_FWNODE_H_
 
-#include <linux/types.h>
-#include <linux/list.h>
 #include <linux/bits.h>
 #include <linux/err.h>
+#include <linux/list.h>
+#include <linux/types.h>
 
 enum dev_dma_attr {
 	DEV_DMA_NOT_SUPPORTED,
diff --git a/include/linux/property.h b/include/linux/property.h
index 1f0135e24d00..3a1045eb786c 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -11,6 +11,7 @@
 #define _LINUX_PROPERTY_H_
 
 #include <linux/args.h>
+#include <linux/array_size.h>
 #include <linux/bits.h>
 #include <linux/fwnode.h>
 #include <linux/stddef.h>
-- 
2.43.0.rc1.1.gbec44491f096


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

* Re: [PATCH v2 0/4] driver core & device property: clean up APIs
  2024-02-23 15:54 [PATCH v2 0/4] driver core & device property: clean up APIs Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-02-23 15:54 ` [PATCH v2 4/4] device property: Don't use "proxy" headers Andy Shevchenko
@ 2024-02-28 21:01 ` Rafael J. Wysocki
  4 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-02-28 21:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Christophe JAILLET, Sakari Ailus,
	linux-kernel, linux-acpi, Rafael J. Wysocki, Daniel Scally,
	Heikki Krogerus, Len Brown

On Fri, Feb 23, 2024 at 4:58 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> There are two, but dependent pair of patches that:
> - hides unused devlink APIs
> - removes 'proxy' header use
>
> v2:
> - most of the patches were sent separately as v1, thus this series is v2
> - harvested tags from that patches (Sakari, Saravana)
>
> Andy Shevchenko (4):
>   driver core: Drop unneeded 'extern' keyword in fwnode.h
>   driver core: Move fw_devlink stuff to where it belongs
>   device property: Move enum dev_dma_attr to fwnode.h
>   device property: Don't use "proxy" headers
>
>  drivers/base/core.c      | 58 ++++++++++++++++++++++++++++++++++
>  drivers/base/property.c  | 67 ++++------------------------------------
>  drivers/base/swnode.c    | 13 +++++++-
>  include/linux/fwnode.h   | 13 +++++---
>  include/linux/property.h |  9 +-----
>  5 files changed, 86 insertions(+), 74 deletions(-)
>
> --

All of the code changes in the series look good to me, so

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

for all of the patches.

The changelog of patch [2/4] could be a bit more to the point IMV, but
let me reply to it directly.

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

* Re: [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs
  2024-02-23 15:54 ` [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs Andy Shevchenko
@ 2024-02-28 21:14   ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2024-02-28 21:14 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Christophe JAILLET, Sakari Ailus,
	linux-kernel, linux-acpi, Rafael J. Wysocki, Daniel Scally,
	Heikki Krogerus, Len Brown

On Fri, Feb 23, 2024 at 4:57 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> A few APIs that belong specifically to the fw_devlink APIs

It would be better to say which functions specifically you mean here.

> - are exposed to others without need

This is not particularly precise.  I guess you mean that they could be
static and are not, which is fair enough, but why not just say that?

> - prevents device property code to be cleaned up in the future

This is completely unclear to me.

> Resolve this mess by moving fw_devlink code to where it belongs
> and hide from others.

This could be more precise.

Also I think that the patch is not expected to introduce functional
changes, which could be mentioned here.

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

end of thread, other threads:[~2024-02-28 21:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 15:54 [PATCH v2 0/4] driver core & device property: clean up APIs Andy Shevchenko
2024-02-23 15:54 ` [PATCH v2 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h Andy Shevchenko
2024-02-23 15:54 ` [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs Andy Shevchenko
2024-02-28 21:14   ` Rafael J. Wysocki
2024-02-23 15:54 ` [PATCH v2 3/4] device property: Move enum dev_dma_attr to fwnode.h Andy Shevchenko
2024-02-23 15:54 ` [PATCH v2 4/4] device property: Don't use "proxy" headers Andy Shevchenko
2024-02-28 21:01 ` [PATCH v2 0/4] driver core & device property: clean up APIs Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox