diff options
author | Andy Shevchenko | 2022-10-04 12:21:25 +0300 |
---|---|---|
committer | Greg Kroah-Hartman | 2024-01-05 15:18:40 +0100 |
commit | 29cb16577189b1db9b39d4efce5e37a7c4acc183 (patch) | |
tree | da84cda71a20aaf6b2e8d137af4a129837e5c27a /drivers/base | |
parent | e7b04372179e2f4d1693787c8d06a4b8de5f0d0c (diff) |
device property: Allow const parameter to dev_fwnode()
commit b295d484b97081feba72b071ffcb72fb4638ccfd upstream.
It's not fully correct to take a const parameter pointer to a struct
and return a non-const pointer to a member of that struct.
Instead, introduce a const version of the dev_fwnode() API which takes
and returns const pointers and use it where it's applicable.
With this, convert dev_fwnode() to be a macro wrapper on top of const
and non-const APIs that chooses one based on the type.
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Fixes: aade55c86033 ("device property: Add const qualifier to device_get_match_data() parameter")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20221004092129.19412-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/property.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index b0c40d973484..eb9b01c2ff1d 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -17,12 +17,19 @@ #include <linux/property.h> #include <linux/phy.h> -struct fwnode_handle *dev_fwnode(const struct device *dev) +struct fwnode_handle *__dev_fwnode(struct device *dev) { return IS_ENABLED(CONFIG_OF) && dev->of_node ? of_fwnode_handle(dev->of_node) : dev->fwnode; } -EXPORT_SYMBOL_GPL(dev_fwnode); +EXPORT_SYMBOL_GPL(__dev_fwnode); + +const struct fwnode_handle *__dev_fwnode_const(const struct device *dev) +{ + return IS_ENABLED(CONFIG_OF) && dev->of_node ? + of_fwnode_handle(dev->of_node) : dev->fwnode; +} +EXPORT_SYMBOL_GPL(__dev_fwnode_const); /** * device_property_present - check if a property of a device is present |