linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate
@ 2022-09-27 14:28 Andy Shevchenko
  2022-09-27 14:28 ` [PATCH v1 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-09-27 14:28 UTC (permalink / raw)
  To: Andy Shevchenko, Prashant Malani, linux-acpi, linux-kernel, linux-usb
  Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

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.

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>
---
 drivers/base/property.c  | 11 +++++++++--
 include/linux/property.h |  3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 4d6278a84868..699f1b115e0a 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -17,13 +17,20 @@
 #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);
 
+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
  * @dev: Device whose property is being checked
@@ -1202,7 +1209,7 @@ EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
 
 const void *device_get_match_data(const struct device *dev)
 {
-	return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
+	return fwnode_call_ptr_op(dev_fwnode_const(dev), device_get_match_data, dev);
 }
 EXPORT_SYMBOL_GPL(device_get_match_data);
 
diff --git a/include/linux/property.h b/include/linux/property.h
index 117cc200c656..ae5d7f8eccf4 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -32,7 +32,8 @@ enum dev_dma_attr {
 	DEV_DMA_COHERENT,
 };
 
-struct fwnode_handle *dev_fwnode(const struct device *dev);
+struct fwnode_handle *dev_fwnode(struct device *dev);
+const struct fwnode_handle *dev_fwnode_const(const struct device *dev);
 
 bool device_property_present(struct device *dev, const char *propname);
 int device_property_read_u8_array(struct device *dev, const char *propname,
-- 
2.35.1


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

* [PATCH v1 2/5] device property: Constify fwnode connection match APIs
  2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
@ 2022-09-27 14:28 ` Andy Shevchenko
       [not found]   ` <202209280013.P9rEfc5m-lkp@intel.com>
  2022-09-27 14:28 ` [PATCH v1 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2022-09-27 14:28 UTC (permalink / raw)
  To: Andy Shevchenko, Prashant Malani, linux-acpi, linux-kernel, linux-usb
  Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

The fwnode and device parameters are not altered in the fwnode
connection match APIs, constify them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/property.c     |  8 ++++----
 drivers/usb/roles/class.c   |  2 +-
 drivers/usb/typec/retimer.c |  2 +-
 include/linux/property.h    | 10 +++++-----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 699f1b115e0a..1a1616c9b599 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1213,7 +1213,7 @@ const void *device_get_match_data(const struct device *dev)
 }
 EXPORT_SYMBOL_GPL(device_get_match_data);
 
-static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode,
+static unsigned int fwnode_graph_devcon_matches(const struct fwnode_handle *fwnode,
 						const char *con_id, void *data,
 						devcon_match_fn_t match,
 						void **matches,
@@ -1247,7 +1247,7 @@ static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode,
 	return count;
 }
 
-static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode,
+static unsigned int fwnode_devcon_matches(const struct fwnode_handle *fwnode,
 					  const char *con_id, void *data,
 					  devcon_match_fn_t match,
 					  void **matches,
@@ -1289,7 +1289,7 @@ static unsigned int fwnode_devcon_matches(struct fwnode_handle *fwnode,
  * device node. @match will be used to convert the connection description to
  * data the caller is expecting to be returned.
  */
-void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
+void *fwnode_connection_find_match(const struct fwnode_handle *fwnode,
 				   const char *con_id, void *data,
 				   devcon_match_fn_t match)
 {
@@ -1326,7 +1326,7 @@ EXPORT_SYMBOL_GPL(fwnode_connection_find_match);
  *
  * Return: Number of matches resolved, or negative errno.
  */
-int fwnode_connection_find_matches(struct fwnode_handle *fwnode,
+int fwnode_connection_find_matches(const struct fwnode_handle *fwnode,
 				   const char *con_id, void *data,
 				   devcon_match_fn_t match,
 				   void **matches, unsigned int matches_len)
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index dfaed7eee94f..a3575a5a18ce 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -87,7 +87,7 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
 }
 EXPORT_SYMBOL_GPL(usb_role_switch_get_role);
 
-static void *usb_role_switch_match(struct fwnode_handle *fwnode, const char *id,
+static void *usb_role_switch_match(const struct fwnode_handle *fwnode, const char *id,
 				   void *data)
 {
 	struct device *dev;
diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c
index 2003731f1bee..8edfdc709a28 100644
--- a/drivers/usb/typec/retimer.c
+++ b/drivers/usb/typec/retimer.c
@@ -34,7 +34,7 @@ static int retimer_fwnode_match(struct device *dev, const void *fwnode)
 	return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-retimer");
 }
 
-static void *typec_retimer_match(struct fwnode_handle *fwnode, const char *id, void *data)
+static void *typec_retimer_match(const struct fwnode_handle *fwnode, const char *id, void *data)
 {
 	struct device *dev;
 
diff --git a/include/linux/property.h b/include/linux/property.h
index ae5d7f8eccf4..6f9d6604edc3 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -438,21 +438,21 @@ unsigned int fwnode_graph_get_endpoint_count(struct fwnode_handle *fwnode,
 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 				struct fwnode_endpoint *endpoint);
 
-typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
+typedef void *(*devcon_match_fn_t)(const struct fwnode_handle *fwnode, const char *id,
 				   void *data);
 
-void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
+void *fwnode_connection_find_match(const struct fwnode_handle *fwnode,
 				   const char *con_id, void *data,
 				   devcon_match_fn_t match);
 
-static inline void *device_connection_find_match(struct device *dev,
+static inline void *device_connection_find_match(const struct device *dev,
 						 const char *con_id, void *data,
 						 devcon_match_fn_t match)
 {
-	return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
+	return fwnode_connection_find_match(dev_fwnode_const(dev), con_id, data, match);
 }
 
-int fwnode_connection_find_matches(struct fwnode_handle *fwnode,
+int fwnode_connection_find_matches(const struct fwnode_handle *fwnode,
 				   const char *con_id, void *data,
 				   devcon_match_fn_t match,
 				   void **matches, unsigned int matches_len);
-- 
2.35.1


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

* [PATCH v1 3/5] device property: Constify parameter in fwnode_graph_is_endpoint()
  2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
  2022-09-27 14:28 ` [PATCH v1 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
@ 2022-09-27 14:28 ` Andy Shevchenko
  2022-09-27 14:28 ` [PATCH v1 4/5] device property: Constify device child node APIs Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-09-27 14:28 UTC (permalink / raw)
  To: Andy Shevchenko, Prashant Malani, linux-acpi, linux-kernel, linux-usb
  Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

Constify parameter in fwnode_graph_is_endpoint() since it doesn't
alter anything related to it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/property.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/property.h b/include/linux/property.h
index 6f9d6604edc3..fe440211e529 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -406,7 +406,7 @@ struct fwnode_handle *fwnode_graph_get_remote_port(
 struct fwnode_handle *fwnode_graph_get_remote_endpoint(
 	const struct fwnode_handle *fwnode);
 
-static inline bool fwnode_graph_is_endpoint(struct fwnode_handle *fwnode)
+static inline bool fwnode_graph_is_endpoint(const struct fwnode_handle *fwnode)
 {
 	return fwnode_property_present(fwnode, "remote-endpoint");
 }
-- 
2.35.1


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

* [PATCH v1 4/5] device property: Constify device child node APIs
  2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
  2022-09-27 14:28 ` [PATCH v1 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
  2022-09-27 14:28 ` [PATCH v1 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Andy Shevchenko
@ 2022-09-27 14:28 ` Andy Shevchenko
  2022-09-27 14:28 ` [PATCH v1 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-09-27 14:28 UTC (permalink / raw)
  To: Andy Shevchenko, Prashant Malani, linux-acpi, linux-kernel, linux-usb
  Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

The device parameter is not altered in the device child node APIs,
constify them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/property.c  | 10 +++++-----
 include/linux/property.h | 12 ++++++------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 1a1616c9b599..04eb5e0ab407 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -763,10 +763,10 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node);
  * @dev: Device to find the next child node for.
  * @child: Handle to one of the device's child nodes or a null handle.
  */
-struct fwnode_handle *device_get_next_child_node(struct device *dev,
+struct fwnode_handle *device_get_next_child_node(const struct device *dev,
 						 struct fwnode_handle *child)
 {
-	const struct fwnode_handle *fwnode = dev_fwnode(dev);
+	const struct fwnode_handle *fwnode = dev_fwnode_const(dev);
 	struct fwnode_handle *next;
 
 	if (IS_ERR_OR_NULL(fwnode))
@@ -800,10 +800,10 @@ EXPORT_SYMBOL_GPL(fwnode_get_named_child_node);
  * @dev: Device to find the named child node for.
  * @childname: String to match child node name against.
  */
-struct fwnode_handle *device_get_named_child_node(struct device *dev,
+struct fwnode_handle *device_get_named_child_node(const struct device *dev,
 						  const char *childname)
 {
-	return fwnode_get_named_child_node(dev_fwnode(dev), childname);
+	return fwnode_get_named_child_node(dev_fwnode_const(dev), childname);
 }
 EXPORT_SYMBOL_GPL(device_get_named_child_node);
 
@@ -859,7 +859,7 @@ EXPORT_SYMBOL_GPL(fwnode_device_is_available);
  * device_get_child_node_count - return the number of child nodes for device
  * @dev: Device to cound the child nodes for
  */
-unsigned int device_get_child_node_count(struct device *dev)
+unsigned int device_get_child_node_count(const struct device *dev)
 {
 	struct fwnode_handle *child;
 	unsigned int count = 0;
diff --git a/include/linux/property.h b/include/linux/property.h
index fe440211e529..31dd6cbea9b0 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -110,16 +110,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node(
 	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
 	     child = fwnode_get_next_available_child_node(fwnode, child))
 
-struct fwnode_handle *device_get_next_child_node(
-	struct device *dev, struct fwnode_handle *child);
+struct fwnode_handle *device_get_next_child_node(const struct device *dev,
+						 struct fwnode_handle *child);
 
 #define device_for_each_child_node(dev, child)				\
 	for (child = device_get_next_child_node(dev, NULL); child;	\
 	     child = device_get_next_child_node(dev, child))
 
-struct fwnode_handle *fwnode_get_named_child_node(
-	const struct fwnode_handle *fwnode, const char *childname);
-struct fwnode_handle *device_get_named_child_node(struct device *dev,
+struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
+						  const char *childname);
+struct fwnode_handle *device_get_named_child_node(const struct device *dev,
 						  const char *childname);
 
 struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
@@ -128,7 +128,7 @@ void fwnode_handle_put(struct fwnode_handle *fwnode);
 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
 int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
 
-unsigned int device_get_child_node_count(struct device *dev);
+unsigned int device_get_child_node_count(const struct device *dev);
 
 static inline bool device_property_read_bool(struct device *dev,
 					     const char *propname)
-- 
2.35.1


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

* [PATCH v1 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr()
  2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
                   ` (2 preceding siblings ...)
  2022-09-27 14:28 ` [PATCH v1 4/5] device property: Constify device child node APIs Andy Shevchenko
@ 2022-09-27 14:28 ` Andy Shevchenko
  2022-09-27 20:56 ` [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Sakari Ailus
  2022-09-28  7:35 ` Heikki Krogerus
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-09-27 14:28 UTC (permalink / raw)
  To: Andy Shevchenko, Prashant Malani, linux-acpi, linux-kernel, linux-usb
  Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

Constify parameter in device_dma_supported() and device_get_dma_attr()
since they don't alter anything related to it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/property.c  | 10 +++++-----
 include/linux/property.h |  5 ++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 04eb5e0ab407..5b0417f7e561 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -871,18 +871,18 @@ unsigned int device_get_child_node_count(const struct device *dev)
 }
 EXPORT_SYMBOL_GPL(device_get_child_node_count);
 
-bool device_dma_supported(struct device *dev)
+bool device_dma_supported(const struct device *dev)
 {
-	return fwnode_call_bool_op(dev_fwnode(dev), device_dma_supported);
+	return fwnode_call_bool_op(dev_fwnode_const(dev), device_dma_supported);
 }
 EXPORT_SYMBOL_GPL(device_dma_supported);
 
-enum dev_dma_attr device_get_dma_attr(struct device *dev)
+enum dev_dma_attr device_get_dma_attr(const struct device *dev)
 {
-	if (!fwnode_has_op(dev_fwnode(dev), device_get_dma_attr))
+	if (!fwnode_has_op(dev_fwnode_const(dev), device_get_dma_attr))
 		return DEV_DMA_NOT_SUPPORTED;
 
-	return fwnode_call_int_op(dev_fwnode(dev), device_get_dma_attr);
+	return fwnode_call_int_op(dev_fwnode_const(dev), device_get_dma_attr);
 }
 EXPORT_SYMBOL_GPL(device_get_dma_attr);
 
diff --git a/include/linux/property.h b/include/linux/property.h
index 31dd6cbea9b0..a9498757155d 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -384,9 +384,8 @@ property_entries_dup(const struct property_entry *properties);
 
 void property_entries_free(const struct property_entry *properties);
 
-bool device_dma_supported(struct device *dev);
-
-enum dev_dma_attr device_get_dma_attr(struct device *dev);
+bool device_dma_supported(const struct device *dev);
+enum dev_dma_attr device_get_dma_attr(const struct device *dev);
 
 const void *device_get_match_data(const struct device *dev);
 
-- 
2.35.1


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

* Re: [PATCH v1 2/5] device property: Constify fwnode connection match APIs
       [not found]   ` <202209280013.P9rEfc5m-lkp@intel.com>
@ 2022-09-27 17:33     ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-09-27 17:33 UTC (permalink / raw)
  To: kernel test robot
  Cc: Prashant Malani, linux-acpi, linux-kernel, linux-usb, kbuild-all,
	Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

On Wed, Sep 28, 2022 at 12:35:10AM +0800, kernel test robot wrote:
> Hi Andy,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on driver-core/driver-core-testing]
> [cannot apply to usb/usb-testing westeri-thunderbolt/next linus/master v6.0-rc7 next-20220923]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/device-property-Keep-dev_fwnode-and-dev_fwnode_const-separate/20220927-223109
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 1da40c2667388dd70306bfd3d4dcb49fd20b50a9
> config: sh-allmodconfig
> compiler: sh4-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/intel-lab-lkp/linux/commit/34401a778cc4e8ddd9610bf7f76d8b7e4fff142e
>         git remote add linux-review https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review Andy-Shevchenko/device-property-Keep-dev_fwnode-and-dev_fwnode_const-separate/20220927-223109
>         git checkout 34401a778cc4e8ddd9610bf7f76d8b7e4fff142e
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/usb/typec/
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):

Thanks, fixed locally for v2.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate
  2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
                   ` (3 preceding siblings ...)
  2022-09-27 14:28 ` [PATCH v1 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Andy Shevchenko
@ 2022-09-27 20:56 ` Sakari Ailus
  2022-09-28  7:35 ` Heikki Krogerus
  5 siblings, 0 replies; 9+ messages in thread
From: Sakari Ailus @ 2022-09-27 20:56 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Prashant Malani, linux-acpi, linux-kernel, linux-usb,
	Daniel Scally, Heikki Krogerus, Greg Kroah-Hartman,
	Rafael J. Wysocki

Hi Andy,

Thanks for the set.

On Tue, Sep 27, 2022 at 05:28:17PM +0300, Andy Shevchenko wrote:
> 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.

I guess you could go as far as saying it's not at all correct. :-)

> 
> Instead, introduce a const version of the dev_fwnode() API which takes
> and returns const pointers and use it where it's applicable.
> 
> 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>

For the set:

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate
  2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
                   ` (4 preceding siblings ...)
  2022-09-27 20:56 ` [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Sakari Ailus
@ 2022-09-28  7:35 ` Heikki Krogerus
  2022-09-28 12:12   ` Rafael J. Wysocki
  5 siblings, 1 reply; 9+ messages in thread
From: Heikki Krogerus @ 2022-09-28  7:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Prashant Malani, linux-acpi, linux-kernel, linux-usb,
	Daniel Scally, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

On Tue, Sep 27, 2022 at 05:28:17PM +0300, Andy Shevchenko wrote:
> 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.
> 
> 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>

For the whole series:

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/base/property.c  | 11 +++++++++--
>  include/linux/property.h |  3 ++-
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 4d6278a84868..699f1b115e0a 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -17,13 +17,20 @@
>  #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);
>  
> +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
>   * @dev: Device whose property is being checked
> @@ -1202,7 +1209,7 @@ EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
>  
>  const void *device_get_match_data(const struct device *dev)
>  {
> -	return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
> +	return fwnode_call_ptr_op(dev_fwnode_const(dev), device_get_match_data, dev);
>  }
>  EXPORT_SYMBOL_GPL(device_get_match_data);
>  
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 117cc200c656..ae5d7f8eccf4 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -32,7 +32,8 @@ enum dev_dma_attr {
>  	DEV_DMA_COHERENT,
>  };
>  
> -struct fwnode_handle *dev_fwnode(const struct device *dev);
> +struct fwnode_handle *dev_fwnode(struct device *dev);
> +const struct fwnode_handle *dev_fwnode_const(const struct device *dev);
>  
>  bool device_property_present(struct device *dev, const char *propname);
>  int device_property_read_u8_array(struct device *dev, const char *propname,
> -- 
> 2.35.1

-- 
heikki

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

* Re: [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate
  2022-09-28  7:35 ` Heikki Krogerus
@ 2022-09-28 12:12   ` Rafael J. Wysocki
  0 siblings, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2022-09-28 12:12 UTC (permalink / raw)
  To: Heikki Krogerus, Andy Shevchenko, Sakari Ailus
  Cc: Prashant Malani, ACPI Devel Maling List,
	Linux Kernel Mailing List,
	open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:,
	Daniel Scally, Greg Kroah-Hartman

On Wed, Sep 28, 2022 at 9:36 AM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> On Tue, Sep 27, 2022 at 05:28:17PM +0300, Andy Shevchenko wrote:
> > 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.
> >
> > 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>
>
> For the whole series:
>
> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
>
> > ---
> >  drivers/base/property.c  | 11 +++++++++--
> >  include/linux/property.h |  3 ++-
> >  2 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/base/property.c b/drivers/base/property.c
> > index 4d6278a84868..699f1b115e0a 100644
> > --- a/drivers/base/property.c
> > +++ b/drivers/base/property.c
> > @@ -17,13 +17,20 @@
> >  #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);
> >
> > +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
> >   * @dev: Device whose property is being checked
> > @@ -1202,7 +1209,7 @@ EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
> >
> >  const void *device_get_match_data(const struct device *dev)
> >  {
> > -     return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
> > +     return fwnode_call_ptr_op(dev_fwnode_const(dev), device_get_match_data, dev);
> >  }
> >  EXPORT_SYMBOL_GPL(device_get_match_data);
> >
> > diff --git a/include/linux/property.h b/include/linux/property.h
> > index 117cc200c656..ae5d7f8eccf4 100644
> > --- a/include/linux/property.h
> > +++ b/include/linux/property.h
> > @@ -32,7 +32,8 @@ enum dev_dma_attr {
> >       DEV_DMA_COHERENT,
> >  };
> >
> > -struct fwnode_handle *dev_fwnode(const struct device *dev);
> > +struct fwnode_handle *dev_fwnode(struct device *dev);
> > +const struct fwnode_handle *dev_fwnode_const(const struct device *dev);
> >
> >  bool device_property_present(struct device *dev, const char *propname);
> >  int device_property_read_u8_array(struct device *dev, const char *propname,
> > --

So I would like all of you to see the response from Greg to the v2 of
this patch and provide your input in that thread:

https://lore.kernel.org/linux-acpi/YzQqcFZtJn90URrJ@kroah.com/T/#u

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

end of thread, other threads:[~2022-09-28 12:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 14:28 [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Andy Shevchenko
2022-09-27 14:28 ` [PATCH v1 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
     [not found]   ` <202209280013.P9rEfc5m-lkp@intel.com>
2022-09-27 17:33     ` Andy Shevchenko
2022-09-27 14:28 ` [PATCH v1 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Andy Shevchenko
2022-09-27 14:28 ` [PATCH v1 4/5] device property: Constify device child node APIs Andy Shevchenko
2022-09-27 14:28 ` [PATCH v1 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Andy Shevchenko
2022-09-27 20:56 ` [PATCH v1 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Sakari Ailus
2022-09-28  7:35 ` Heikki Krogerus
2022-09-28 12:12   ` 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;
as well as URLs for NNTP newsgroup(s).