linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/5] device property: Consitify a few APIs and
@ 2022-10-04  9:21 Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode() Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:21 UTC (permalink / raw)
  To: Andy Shevchenko, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Bjorn Andersson, Prashant Malani, linux-acpi,
	linux-kernel, linux-usb
  Cc: Daniel Scally, Rafael J. Wysocki

The property.h has inconsistency in how we annotate the parameters which
are not modified anyhow by the certain APIs. Also dev_fwnode() needs to
be rectified in sense of the handling const qualifier.

This series improves the above with only a couple of APIs left for now
untouched (PHY, which I believe doesn't belong to property.h to begin
with).

Changelog v3:
- used _Generic() to hide the _const API (Sakari, Greg)

Changelog v2:
- fixed USB Type-C compilation issues (LKP)
- added tags (Sakari, Heikki)

Andy Shevchenko (5):
  device property: Allow const parameter to dev_fwnode()
  device property: Constify fwnode connection match APIs
  device property: Constify parameter in fwnode_graph_is_endpoint()
  device property: Constify device child node APIs
  device property: Constify parameter in device_dma_supported() and
    device_get_dma_attr()

 drivers/base/property.c     | 29 ++++++++++++++++++-----------
 drivers/usb/roles/class.c   |  2 +-
 drivers/usb/typec/mux.c     |  8 ++++----
 drivers/usb/typec/retimer.c |  2 +-
 include/linux/property.h    | 34 +++++++++++++++++++---------------
 5 files changed, 43 insertions(+), 32 deletions(-)

-- 
2.35.1


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

* [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode()
  2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
@ 2022-10-04  9:21 ` Andy Shevchenko
  2022-10-04  9:34   ` Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:21 UTC (permalink / raw)
  To: Andy Shevchenko, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Bjorn Andersson, Prashant Malani, linux-acpi,
	linux-kernel, linux-usb
  Cc: Daniel Scally, 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.

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

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 4d6278a84868..d77302d28566 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
diff --git a/include/linux/property.h b/include/linux/property.h
index 117cc200c656..587b5b666b5b 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -32,7 +32,12 @@ enum dev_dma_attr {
 	DEV_DMA_COHERENT,
 };
 
-struct fwnode_handle *dev_fwnode(const struct device *dev);
+const struct fwnode_handle *__dev_fwnode_const(const struct device *dev);
+struct fwnode_handle *__dev_fwnode(struct device *dev);
+#define dev_fwnode(dev)							\
+	_Generic((dev),							\
+		 const struct device *: __dev_fwnode_const,	\
+		 struct device *: __dev_fwnode)(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] 10+ messages in thread

* [PATCH v3 2/5] device property: Constify fwnode connection match APIs
  2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode() Andy Shevchenko
@ 2022-10-04  9:21 ` Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:21 UTC (permalink / raw)
  To: Andy Shevchenko, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Bjorn Andersson, Prashant Malani, linux-acpi,
	linux-kernel, linux-usb
  Cc: Daniel Scally, 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>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/base/property.c     | 8 ++++----
 drivers/usb/roles/class.c   | 2 +-
 drivers/usb/typec/mux.c     | 8 ++++----
 drivers/usb/typec/retimer.c | 2 +-
 include/linux/property.h    | 8 ++++----
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index d77302d28566..58b8158add5c 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/mux.c b/drivers/usb/typec/mux.c
index 464330776cd6..f81ea26ab389 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -32,8 +32,8 @@ static int switch_fwnode_match(struct device *dev, const void *fwnode)
 	return dev_fwnode(dev) == fwnode;
 }
 
-static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
-				void *data)
+static void *typec_switch_match(const struct fwnode_handle *fwnode,
+				const char *id, void *data)
 {
 	struct device *dev;
 
@@ -262,8 +262,8 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode)
 	return dev_fwnode(dev) == fwnode;
 }
 
-static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
-			     void *data)
+static void *typec_mux_match(const struct fwnode_handle *fwnode,
+			     const char *id, void *data)
 {
 	const struct typec_altmode_desc *desc = 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 587b5b666b5b..8d82775a901a 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -442,21 +442,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);
 }
 
-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] 10+ messages in thread

* [PATCH v3 3/5] device property: Constify parameter in fwnode_graph_is_endpoint()
  2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode() Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
@ 2022-10-04  9:21 ` Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 4/5] device property: Constify device child node APIs Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:21 UTC (permalink / raw)
  To: Andy Shevchenko, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Bjorn Andersson, Prashant Malani, linux-acpi,
	linux-kernel, linux-usb
  Cc: Daniel Scally, 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>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@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 8d82775a901a..7abb1792044f 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -410,7 +410,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] 10+ messages in thread

* [PATCH v3 4/5] device property: Constify device child node APIs
  2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
                   ` (2 preceding siblings ...)
  2022-10-04  9:21 ` [PATCH v3 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Andy Shevchenko
@ 2022-10-04  9:21 ` Andy Shevchenko
  2022-10-04  9:21 ` [PATCH v3 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Andy Shevchenko
  2022-10-04 12:11 ` [PATCH v3 0/5] device property: Consitify a few APIs and Greg Kroah-Hartman
  5 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:21 UTC (permalink / raw)
  To: Andy Shevchenko, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Bjorn Andersson, Prashant Malani, linux-acpi,
	linux-kernel, linux-usb
  Cc: Daniel Scally, 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>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/base/property.c  |  6 +++---
 include/linux/property.h | 12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 58b8158add5c..d3ea5f82978f 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -763,7 +763,7 @@ 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);
@@ -800,7 +800,7 @@ 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);
@@ -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 7abb1792044f..472689e53ade 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -114,16 +114,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);
@@ -132,7 +132,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] 10+ messages in thread

* [PATCH v3 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr()
  2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
                   ` (3 preceding siblings ...)
  2022-10-04  9:21 ` [PATCH v3 4/5] device property: Constify device child node APIs Andy Shevchenko
@ 2022-10-04  9:21 ` Andy Shevchenko
  2022-10-04 12:11 ` [PATCH v3 0/5] device property: Consitify a few APIs and Greg Kroah-Hartman
  5 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:21 UTC (permalink / raw)
  To: Andy Shevchenko, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Bjorn Andersson, Prashant Malani, linux-acpi,
	linux-kernel, linux-usb
  Cc: Daniel Scally, 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>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/base/property.c  | 4 ++--
 include/linux/property.h | 5 ++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index d3ea5f82978f..68f61d3e3857 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -871,13 +871,13 @@ 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);
 }
 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))
 		return DEV_DMA_NOT_SUPPORTED;
diff --git a/include/linux/property.h b/include/linux/property.h
index 472689e53ade..83674f968a8f 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -388,9 +388,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] 10+ messages in thread

* Re: [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode()
  2022-10-04  9:21 ` [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode() Andy Shevchenko
@ 2022-10-04  9:34   ` Andy Shevchenko
  2022-10-04  9:38     ` Andy Shevchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:34 UTC (permalink / raw)
  To: Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Bjorn Andersson, Prashant Malani, linux-acpi, linux-kernel,
	linux-usb
  Cc: Daniel Scally, Rafael J. Wysocki

On Tue, Oct 04, 2022 at 12:21:25PM +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.
> 
> 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.

Hmm... it missed the device_get_match_data() implementation (reverse) change
somehow. And it still compiles to me, probably I rebased wrongly and the hunk
went to another patch. I'll investigate and resend as v4 the fixed version.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode()
  2022-10-04  9:34   ` Andy Shevchenko
@ 2022-10-04  9:38     ` Andy Shevchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2022-10-04  9:38 UTC (permalink / raw)
  To: Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Bjorn Andersson, Prashant Malani, linux-acpi, linux-kernel,
	linux-usb
  Cc: Daniel Scally, Rafael J. Wysocki

On Tue, Oct 04, 2022 at 12:34:56PM +0300, Andy Shevchenko wrote:
> On Tue, Oct 04, 2022 at 12:21:25PM +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.
> > 
> > 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.
> 
> Hmm... it missed the device_get_match_data() implementation (reverse) change
> somehow. And it still compiles to me, probably I rebased wrongly and the hunk
> went to another patch. I'll investigate and resend as v4 the fixed version.

Ah, sorry, I mixed this with previous version of the patch here, so everything
is fine in v3!

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 0/5] device property: Consitify a few APIs and
  2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
                   ` (4 preceding siblings ...)
  2022-10-04  9:21 ` [PATCH v3 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Andy Shevchenko
@ 2022-10-04 12:11 ` Greg Kroah-Hartman
  2022-10-22 11:50   ` Greg Kroah-Hartman
  5 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2022-10-04 12:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Heikki Krogerus, Sakari Ailus, Bjorn Andersson, Prashant Malani,
	linux-acpi, linux-kernel, linux-usb, Daniel Scally,
	Rafael J. Wysocki

On Tue, Oct 04, 2022 at 12:21:24PM +0300, Andy Shevchenko wrote:
> The property.h has inconsistency in how we annotate the parameters which
> are not modified anyhow by the certain APIs. Also dev_fwnode() needs to
> be rectified in sense of the handling const qualifier.
> 
> This series improves the above with only a couple of APIs left for now
> untouched (PHY, which I believe doesn't belong to property.h to begin
> with).

Looks sane at first glance.  I'll look at it some more once 6.1-rc1 is
out, thanks.

greg k-h

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

* Re: [PATCH v3 0/5] device property: Consitify a few APIs and
  2022-10-04 12:11 ` [PATCH v3 0/5] device property: Consitify a few APIs and Greg Kroah-Hartman
@ 2022-10-22 11:50   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2022-10-22 11:50 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Heikki Krogerus, Sakari Ailus, Bjorn Andersson, Prashant Malani,
	linux-acpi, linux-kernel, linux-usb, Daniel Scally,
	Rafael J. Wysocki

On Tue, Oct 04, 2022 at 02:11:10PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Oct 04, 2022 at 12:21:24PM +0300, Andy Shevchenko wrote:
> > The property.h has inconsistency in how we annotate the parameters which
> > are not modified anyhow by the certain APIs. Also dev_fwnode() needs to
> > be rectified in sense of the handling const qualifier.
> > 
> > This series improves the above with only a couple of APIs left for now
> > untouched (PHY, which I believe doesn't belong to property.h to begin
> > with).
> 
> Looks sane at first glance.  I'll look at it some more once 6.1-rc1 is
> out, thanks.

All now applied, thanks.,

greg k-h

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

end of thread, other threads:[~2022-10-22 11:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04  9:21 [PATCH v3 0/5] device property: Consitify a few APIs and Andy Shevchenko
2022-10-04  9:21 ` [PATCH v3 1/5] device property: Allow const parameter to dev_fwnode() Andy Shevchenko
2022-10-04  9:34   ` Andy Shevchenko
2022-10-04  9:38     ` Andy Shevchenko
2022-10-04  9:21 ` [PATCH v3 2/5] device property: Constify fwnode connection match APIs Andy Shevchenko
2022-10-04  9:21 ` [PATCH v3 3/5] device property: Constify parameter in fwnode_graph_is_endpoint() Andy Shevchenko
2022-10-04  9:21 ` [PATCH v3 4/5] device property: Constify device child node APIs Andy Shevchenko
2022-10-04  9:21 ` [PATCH v3 5/5] device property: Constify parameter in device_dma_supported() and device_get_dma_attr() Andy Shevchenko
2022-10-04 12:11 ` [PATCH v3 0/5] device property: Consitify a few APIs and Greg Kroah-Hartman
2022-10-22 11:50   ` Greg Kroah-Hartman

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).