* [PATCH v3 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h
2024-02-29 16:23 [PATCH v3 0/4] driver core & device property: clean up APIs Andy Shevchenko
@ 2024-02-29 16:23 ` Andy Shevchenko
2024-02-29 16:23 ` [PATCH v3 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-29 16:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Andy Shevchenko, Sakari Ailus, linux-kernel,
linux-acpi
Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown,
Jonathan Cameron, Lars-Peter Clausen, 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>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
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 v3 2/4] driver core: Move fw_devlink stuff to where it belongs
2024-02-29 16:23 [PATCH v3 0/4] driver core & device property: clean up APIs Andy Shevchenko
2024-02-29 16:23 ` [PATCH v3 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h Andy Shevchenko
@ 2024-02-29 16:23 ` Andy Shevchenko
2024-02-29 16:23 ` [PATCH v3 3/4] device property: Move enum dev_dma_attr to fwnode.h Andy Shevchenko
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-29 16:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Andy Shevchenko, Sakari Ailus, linux-kernel,
linux-acpi
Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown,
Jonathan Cameron, Lars-Peter Clausen
A few APIs, i.e. fwnode_is_ancestor_of(), fwnode_get_next_parent_dev(),
and get_dev_from_fwnode(), that belong specifically to the fw_devlink APIs,
may be static, but they are not.
Resolve this mess by moving them to the driver/base/core where the all
users are being resided and make static.
No functional changes intended.
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
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 53e42031c646..d983a4dea105 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 eefd662a2f9d..420420a1d8ad 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -157,11 +157,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 v3 3/4] device property: Move enum dev_dma_attr to fwnode.h
2024-02-29 16:23 [PATCH v3 0/4] driver core & device property: clean up APIs Andy Shevchenko
2024-02-29 16:23 ` [PATCH v3 1/4] driver core: Drop unneeded 'extern' keyword in fwnode.h Andy Shevchenko
2024-02-29 16:23 ` [PATCH v3 2/4] driver core: Move fw_devlink stuff to where it belongs Andy Shevchenko
@ 2024-02-29 16:23 ` Andy Shevchenko
2024-02-29 16:23 ` [PATCH v3 4/4] device property: Don't use "proxy" headers Andy Shevchenko
2024-02-29 18:46 ` [PATCH v3 0/4] driver core & device property: clean up APIs Greg Kroah-Hartman
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-29 16:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Andy Shevchenko, Sakari Ailus, linux-kernel,
linux-acpi
Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown,
Jonathan Cameron, Lars-Peter Clausen
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>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
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 420420a1d8ad..5761878d42c7 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -28,12 +28,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 v3 4/4] device property: Don't use "proxy" headers
2024-02-29 16:23 [PATCH v3 0/4] driver core & device property: clean up APIs Andy Shevchenko
` (2 preceding siblings ...)
2024-02-29 16:23 ` [PATCH v3 3/4] device property: Move enum dev_dma_attr to fwnode.h Andy Shevchenko
@ 2024-02-29 16:23 ` Andy Shevchenko
2024-02-29 18:46 ` [PATCH v3 0/4] driver core & device property: clean up APIs Greg Kroah-Hartman
4 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-02-29 16:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, Andy Shevchenko, Sakari Ailus, linux-kernel,
linux-acpi
Cc: Rafael J. Wysocki, Daniel Scally, Heikki Krogerus, Len Brown,
Jonathan Cameron, Lars-Peter Clausen
Update header inclusions to follow IWYU (Include What You Use)
principle.
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
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 d983a4dea105..6a3a434d0d6f 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 5761878d42c7..61fc20e5f81f 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/cleanup.h>
#include <linux/fwnode.h>
--
2.43.0.rc1.1.gbec44491f096
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v3 0/4] driver core & device property: clean up APIs
2024-02-29 16:23 [PATCH v3 0/4] driver core & device property: clean up APIs Andy Shevchenko
` (3 preceding siblings ...)
2024-02-29 16:23 ` [PATCH v3 4/4] device property: Don't use "proxy" headers Andy Shevchenko
@ 2024-02-29 18:46 ` Greg Kroah-Hartman
2024-03-01 17:57 ` Andy Shevchenko
4 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2024-02-29 18:46 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sakari Ailus, linux-kernel, linux-acpi, Rafael J. Wysocki,
Daniel Scally, Heikki Krogerus, Len Brown, Jonathan Cameron,
Lars-Peter Clausen
On Thu, Feb 29, 2024 at 06:23:42PM +0200, Andy Shevchenko wrote:
> There are two, but dependent pair of patches that:
> - makes some of devlink APIs static
> - removes 'proxy' header use
>
> This is rebased on top of latest patches from Jonathan as it has a minor
> conflict in property.h. The series can be applied directly to driver
> core tree with reduced context, but it may be better just to route it
> via IIO. Greg, which way do you prefer?
Why would IIO mess with driver core stuff?
I can just take it in my driver core tree, thanks.
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 0/4] driver core & device property: clean up APIs
2024-02-29 18:46 ` [PATCH v3 0/4] driver core & device property: clean up APIs Greg Kroah-Hartman
@ 2024-03-01 17:57 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-03-01 17:57 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Sakari Ailus, linux-kernel, linux-acpi, Rafael J. Wysocki,
Daniel Scally, Heikki Krogerus, Len Brown, Jonathan Cameron,
Lars-Peter Clausen
On Thu, Feb 29, 2024 at 07:46:15PM +0100, Greg Kroah-Hartman wrote:
> On Thu, Feb 29, 2024 at 06:23:42PM +0200, Andy Shevchenko wrote:
> > There are two, but dependent pair of patches that:
> > - makes some of devlink APIs static
> > - removes 'proxy' header use
> >
> > This is rebased on top of latest patches from Jonathan as it has a minor
> > conflict in property.h. The series can be applied directly to driver
> > core tree with reduced context, but it may be better just to route it
> > via IIO. Greg, which way do you prefer?
>
> Why would IIO mess with driver core stuff?
>
> I can just take it in my driver core tree, thanks.
Let me base on your driver-core-testing then.
Thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread