driver core & device property: clean up APIs
Subsystems (3)
Andy Shevchenko
reviewerv2 cover driver core & device property: clean up APIs
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(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH v2 1/4 driver core: Drop unneeded 'extern' keyword in fwnode.h
We do not use 'extern' keyword with functions. Remove the last one mistakenly added to fwnode.h.
--- include/linux/fwnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/fwnode.h +1 -1
@@ -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
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH v2 2/4 driver core: Move fw_devlink stuff to where it belongs
In reply to Andy ShevchenkoA 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.
--- 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(-)
drivers/base/core.c +58 -0
@@ -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.
drivers/base/property.c +0 -56
68 lines not on this page · raw message
include/linux/fwnode.h +0 -1
@@ -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)
include/linux/property.h +0 -2
@@ -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(
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Rafael J. Wysocki
maintainerRe: [PATCH v2 2/4] driver core: Move fw_devlink stuff to where it belongs
Quoted 2 lines · Andy Shevchenko
A few APIs that belong specifically to the
fw_devlinkAPIs
It would be better to say which functions specifically you mean here.
Quoted 1 line
- 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?
Quoted 1 line
- prevents device property code to be cleaned up in the future
This is completely unclear to me.
Quoted 2 lines
Resolve this mess by moving
fw_devlinkcode 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.
Andy Shevchenko
reviewerPATCH v2 3/4 device property: Move enum dev_dma_attr to fwnode.h
In reply to Andy ShevchenkoThe 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.
--- include/linux/fwnode.h | 6 ++++++ include/linux/property.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/fwnode.h +6 -0
@@ -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 ;
include/linux/property.h +0 -6
@@ -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) \
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Andy Shevchenko
reviewerPATCH v2 4/4 device property: Don't use "proxy" headers
In reply to Andy ShevchenkoUpdate header inclusions to follow IWYU (Include What You Use) principle.
--- 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(-)
drivers/base/property.c +6 -5
@@ -7,15 +7,16 @@* Mika Westerberg <[email protected]> */ -#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) {
drivers/base/swnode.c +12 -1
@@ -6,10 +6,21 @@* Author: Heikki Krogerus <[email protected]> */ +#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"
include/linux/fwnode.h +2 -2
@@ -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,
include/linux/property.h +1 -0
@@ -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>
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Quoted 15 lines · Andy Shevchenko
There are two, but dependent pair of patches that:
- hides unused devlink APIs
- removes 'proxy' header usev2:
- 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 infwnode.hdriver core: Movefw_devlinkstuff to where it belongs device property: Move enumdev_dma_attrtofwnode.hdevice property: Don't use "proxy" headers
Quoted 8 lines
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
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.