linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
@ 2025-02-20 16:20 Andy Shevchenko
  2025-02-20 16:20 ` [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-02-20 16:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Andy Shevchenko,
	Bartosz Golaszewski, Raag Jadav, linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
calls. This mini-series is for that. The necessary prerequisites are here
as well, namely:
1) moving the respective APIs to the devres.h;
2) adding a simple helper that GPIOLIB will rely on;
3) finishing the GPIOLIB conversion to the device managed action APIs.

The series is based on another series that's available via immutable tag
devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
tree (or Intel GPIO for the starter) with an immutable tag for the device
core and others if needed. Please, review and acknowledge.

Changelog v2:
- dropped actually unneeded patch (Raag)
- rewrote last patch as suggested (Raag)
- collected tags (Raag)

Link: https://lore.kernel.org/r/Z7cqCaME4LxTTBn6@black.fi.intel.com [1]
Cc: Raag Jadav <raag.jadav@intel.com>

Andy Shevchenko (3):
  devres: Move devm_*_action*() APIs to devres.h
  devres: Add devm_is_action_added() helper
  gpiolib: devres: Finish the conversion to use devm_add_action()

 drivers/base/devres.c         | 11 +++++
 drivers/gpio/gpiolib-devres.c | 90 ++++++++++-------------------------
 include/linux/device.h        | 38 ---------------
 include/linux/device/devres.h | 41 ++++++++++++++++
 4 files changed, 77 insertions(+), 103 deletions(-)


base-commit: 9deb15de8ca27cf9cba0d2bac53bbe37c836591b
-- 
2.45.1.3035.g276e886db78b


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

* [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h
  2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
@ 2025-02-20 16:20 ` Andy Shevchenko
  2025-02-21  3:26   ` Zijun Hu
  2025-02-20 16:20 ` [PATCH v2 2/3] devres: Add devm_is_action_added() helper Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-02-20 16:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Andy Shevchenko,
	Bartosz Golaszewski, Raag Jadav, linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

We have a newly created header linux/device/devres.h that gathers
device managed APIs, so users won't need to include entire device.h
for only these ones. Move devm_*_action*() APIs to devres.h as well.

Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/device.h        | 38 ----------------------------------
 include/linux/device/devres.h | 39 +++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 78ca7fd0e625..d6341a05e4fb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -281,44 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,
 void device_remove_bin_file(struct device *dev,
 			    const struct bin_attribute *attr);
 
-/* allows to add/remove a custom action to devres stack */
-int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
-
-/**
- * devm_remove_action() - removes previously added custom action
- * @dev: Device that owns the action
- * @action: Function implementing the action
- * @data: Pointer to data passed to @action implementation
- *
- * Removes instance of @action previously added by devm_add_action().
- * Both action and data should match one of the existing entries.
- */
-static inline
-void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
-{
-	WARN_ON(devm_remove_action_nowarn(dev, action, data));
-}
-
-void devm_release_action(struct device *dev, void (*action)(void *), void *data);
-
-int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
-#define devm_add_action(dev, action, data) \
-	__devm_add_action(dev, action, data, #action)
-
-static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
-					     void *data, const char *name)
-{
-	int ret;
-
-	ret = __devm_add_action(dev, action, data, name);
-	if (ret)
-		action(data);
-
-	return ret;
-}
-#define devm_add_action_or_reset(dev, action, data) \
-	__devm_add_action_or_reset(dev, action, data, #action)
-
 /**
  * devm_alloc_percpu - Resource-managed alloc_percpu
  * @dev: Device to allocate per-cpu memory for
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 9b49f9915850..9cd1787ef28e 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -8,6 +8,7 @@
 #include <linux/overflow.h>
 #include <linux/stdarg.h>
 #include <linux/types.h>
+#include <asm/bug.h>
 
 struct device;
 struct device_node;
@@ -126,4 +127,42 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
 
 #endif
 
+/* allows to add/remove a custom action to devres stack */
+int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
+
+/**
+ * devm_remove_action() - removes previously added custom action
+ * @dev: Device that owns the action
+ * @action: Function implementing the action
+ * @data: Pointer to data passed to @action implementation
+ *
+ * Removes instance of @action previously added by devm_add_action().
+ * Both action and data should match one of the existing entries.
+ */
+static inline
+void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
+{
+	WARN_ON(devm_remove_action_nowarn(dev, action, data));
+}
+
+void devm_release_action(struct device *dev, void (*action)(void *), void *data);
+
+int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
+#define devm_add_action(dev, action, data) \
+	__devm_add_action(dev, action, data, #action)
+
+static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
+					     void *data, const char *name)
+{
+	int ret;
+
+	ret = __devm_add_action(dev, action, data, name);
+	if (ret)
+		action(data);
+
+	return ret;
+}
+#define devm_add_action_or_reset(dev, action, data) \
+	__devm_add_action_or_reset(dev, action, data, #action)
+
 #endif /* _DEVICE_DEVRES_H_ */
-- 
2.45.1.3035.g276e886db78b


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

* [PATCH v2 2/3] devres: Add devm_is_action_added() helper
  2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
  2025-02-20 16:20 ` [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h Andy Shevchenko
@ 2025-02-20 16:20 ` Andy Shevchenko
  2025-02-21  3:34   ` Zijun Hu
  2025-02-20 16:20 ` [PATCH v2 3/3] gpiolib: devres: Finish the conversion to use devm_add_action() Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-02-20 16:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Andy Shevchenko,
	Bartosz Golaszewski, Raag Jadav, linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

In some code we would like to know if the action in device managed resources
was added by devm_add_action() family of calls. Introduce a helper for that.

Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/devres.c         | 11 +++++++++++
 include/linux/device/devres.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 93e7779ef21e..7c2babfa9396 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -749,6 +749,17 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
 }
 EXPORT_SYMBOL_GPL(__devm_add_action);
 
+bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data)
+{
+	struct action_devres devres = {
+		.data = data,
+		.action = action,
+	};
+
+	return devres_find(dev, devm_action_release, devm_action_match, &devres);
+}
+EXPORT_SYMBOL_GPL(devm_is_action_added);
+
 /**
  * devm_remove_action_nowarn() - removes previously added custom action
  * @dev: Device that owns the action
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 9cd1787ef28e..ae696d10faff 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -165,4 +165,6 @@ static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(
 #define devm_add_action_or_reset(dev, action, data) \
 	__devm_add_action_or_reset(dev, action, data, #action)
 
+bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data);
+
 #endif /* _DEVICE_DEVRES_H_ */
-- 
2.45.1.3035.g276e886db78b


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

* [PATCH v2 3/3] gpiolib: devres: Finish the conversion to use devm_add_action()
  2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
  2025-02-20 16:20 ` [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h Andy Shevchenko
  2025-02-20 16:20 ` [PATCH v2 2/3] devres: Add devm_is_action_added() helper Andy Shevchenko
@ 2025-02-20 16:20 ` Andy Shevchenko
  2025-03-03 10:49 ` [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-02-20 16:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Andy Shevchenko,
	Bartosz Golaszewski, Raag Jadav, linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

With a recently added helper we can complete the conversion of
the GPIOLIB code to use devm_add_action() in all suitable cases.
So do this.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-devres.c | 90 ++++++++++-------------------------
 1 file changed, 25 insertions(+), 65 deletions(-)

diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c
index 08205f355ceb..840d0ad7c5ba 100644
--- a/drivers/gpio/gpiolib-devres.c
+++ b/drivers/gpio/gpiolib-devres.c
@@ -6,7 +6,7 @@
  * Copyright (c) 2011 John Crispin <john@phrozen.org>
  */
 
-#include <linux/device.h>
+#include <linux/device/devres.h>
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/gfp.h>
@@ -19,32 +19,14 @@
 struct fwnode_handle;
 struct lock_class_key;
 
-static void devm_gpiod_release(struct device *dev, void *res)
+static void devm_gpiod_release(void *desc)
 {
-	struct gpio_desc **desc = res;
-
-	gpiod_put(*desc);
+	gpiod_put(desc);
 }
 
-static int devm_gpiod_match(struct device *dev, void *res, void *data)
+static void devm_gpiod_release_array(void *descs)
 {
-	struct gpio_desc **this = res, **gpio = data;
-
-	return *this == *gpio;
-}
-
-static void devm_gpiod_release_array(struct device *dev, void *res)
-{
-	struct gpio_descs **descs = res;
-
-	gpiod_put_array(*descs);
-}
-
-static int devm_gpiod_match_array(struct device *dev, void *res, void *data)
-{
-	struct gpio_descs **this = res, **gpios = data;
-
-	return *this == *gpios;
+	gpiod_put_array(descs);
 }
 
 /**
@@ -114,8 +96,8 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
 						    unsigned int idx,
 						    enum gpiod_flags flags)
 {
-	struct gpio_desc **dr;
 	struct gpio_desc *desc;
+	int ret;
 
 	desc = gpiod_get_index(dev, con_id, idx, flags);
 	if (IS_ERR(desc))
@@ -126,23 +108,16 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
 	 * already under resource management by this device.
 	 */
 	if (flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
-		struct devres *dres;
+		bool dres;
 
-		dres = devres_find(dev, devm_gpiod_release,
-				   devm_gpiod_match, &desc);
+		dres = devm_is_action_added(dev, devm_gpiod_release, desc);
 		if (dres)
 			return desc;
 	}
 
-	dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *),
-			  GFP_KERNEL);
-	if (!dr) {
-		gpiod_put(desc);
-		return ERR_PTR(-ENOMEM);
-	}
-
-	*dr = desc;
-	devres_add(dev, dr);
+	ret = devm_add_action_or_reset(dev, devm_gpiod_release, desc);
+	if (ret)
+		return ERR_PTR(ret);
 
 	return desc;
 }
@@ -171,22 +146,16 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 					      enum gpiod_flags flags,
 					      const char *label)
 {
-	struct gpio_desc **dr;
 	struct gpio_desc *desc;
-
-	dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *),
-			  GFP_KERNEL);
-	if (!dr)
-		return ERR_PTR(-ENOMEM);
+	int ret;
 
 	desc = gpiod_find_and_request(dev, fwnode, con_id, index, flags, label, false);
-	if (IS_ERR(desc)) {
-		devres_free(dr);
+	if (IS_ERR(desc))
 		return desc;
-	}
 
-	*dr = desc;
-	devres_add(dev, dr);
+	ret = devm_add_action_or_reset(dev, devm_gpiod_release, desc);
+	if (ret)
+		return ERR_PTR(ret);
 
 	return desc;
 }
@@ -244,22 +213,16 @@ struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev,
 						     const char *con_id,
 						     enum gpiod_flags flags)
 {
-	struct gpio_descs **dr;
 	struct gpio_descs *descs;
-
-	dr = devres_alloc(devm_gpiod_release_array,
-			  sizeof(struct gpio_descs *), GFP_KERNEL);
-	if (!dr)
-		return ERR_PTR(-ENOMEM);
+	int ret;
 
 	descs = gpiod_get_array(dev, con_id, flags);
-	if (IS_ERR(descs)) {
-		devres_free(dr);
+	if (IS_ERR(descs))
 		return descs;
-	}
 
-	*dr = descs;
-	devres_add(dev, dr);
+	ret = devm_add_action_or_reset(dev, devm_gpiod_release_array, descs);
+	if (ret)
+		return ERR_PTR(ret);
 
 	return descs;
 }
@@ -307,8 +270,7 @@ EXPORT_SYMBOL_GPL(devm_gpiod_get_array_optional);
  */
 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc)
 {
-	WARN_ON(devres_release(dev, devm_gpiod_release, devm_gpiod_match,
-		&desc));
+	devm_release_action(dev, devm_gpiod_release, desc);
 }
 EXPORT_SYMBOL_GPL(devm_gpiod_put);
 
@@ -321,20 +283,19 @@ EXPORT_SYMBOL_GPL(devm_gpiod_put);
  * you want to hand over lifecycle management of a descriptor to another
  * mechanism.
  */
-
 void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc)
 {
 	int ret;
 
 	if (IS_ERR_OR_NULL(desc))
 		return;
-	ret = devres_destroy(dev, devm_gpiod_release,
-			     devm_gpiod_match, &desc);
+
 	/*
 	 * If the GPIO descriptor is requested as nonexclusive, we
 	 * may call this function several times on the same descriptor
 	 * so it is OK if devres_destroy() returns -ENOENT.
 	 */
+	ret = devm_remove_action_nowarn(dev, devm_gpiod_release, desc);
 	if (ret == -ENOENT)
 		return;
 	/* Anything else we should warn about */
@@ -353,8 +314,7 @@ EXPORT_SYMBOL_GPL(devm_gpiod_unhinge);
  */
 void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs)
 {
-	WARN_ON(devres_release(dev, devm_gpiod_release_array,
-			       devm_gpiod_match_array, &descs));
+	devm_remove_action(dev, devm_gpiod_release_array, descs);
 }
 EXPORT_SYMBOL_GPL(devm_gpiod_put_array);
 
-- 
2.45.1.3035.g276e886db78b


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

* Re: [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h
  2025-02-20 16:20 ` [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h Andy Shevchenko
@ 2025-02-21  3:26   ` Zijun Hu
  0 siblings, 0 replies; 16+ messages in thread
From: Zijun Hu @ 2025-02-21  3:26 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, Bartosz Golaszewski,
	Raag Jadav, linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

On 2/21/2025 12:20 AM, Andy Shevchenko wrote:
> We have a newly created header linux/device/devres.h that gathers
> device managed APIs, so users won't need to include entire device.h
> for only these ones. Move devm_*_action*() APIs to devres.h as well.
> 
> Reviewed-by: Raag Jadav <raag.jadav@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/device.h        | 38 ----------------------------------
>  include/linux/device/devres.h | 39 +++++++++++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 38 deletions(-)
> 
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 78ca7fd0e625..d6341a05e4fb 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -281,44 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,
>  void device_remove_bin_file(struct device *dev,
>  			    const struct bin_attribute *attr);
>  
> -/* allows to add/remove a custom action to devres stack */
> -int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
> -
> -/**
> - * devm_remove_action() - removes previously added custom action
> - * @dev: Device that owns the action
> - * @action: Function implementing the action
> - * @data: Pointer to data passed to @action implementation
> - *
> - * Removes instance of @action previously added by devm_add_action().
> - * Both action and data should match one of the existing entries.
> - */
> -static inline
> -void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
> -{
> -	WARN_ON(devm_remove_action_nowarn(dev, action, data));
> -}
> -
> -void devm_release_action(struct device *dev, void (*action)(void *), void *data);
> -
> -int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
> -#define devm_add_action(dev, action, data) \
> -	__devm_add_action(dev, action, data, #action)
> -
> -static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
> -					     void *data, const char *name)
> -{
> -	int ret;
> -
> -	ret = __devm_add_action(dev, action, data, name);
> -	if (ret)
> -		action(data);
> -
> -	return ret;
> -}
> -#define devm_add_action_or_reset(dev, action, data) \
> -	__devm_add_action_or_reset(dev, action, data, #action)
> -
>  /**
>   * devm_alloc_percpu - Resource-managed alloc_percpu
>   * @dev: Device to allocate per-cpu memory for
> diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
> index 9b49f9915850..9cd1787ef28e 100644
> --- a/include/linux/device/devres.h
> +++ b/include/linux/device/devres.h
> @@ -8,6 +8,7 @@
>  #include <linux/overflow.h>
>  #include <linux/stdarg.h>
>  #include <linux/types.h>
> +#include <asm/bug.h>
>  
>  struct device;
>  struct device_node;
> @@ -126,4 +127,42 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
>  
>  #endif
>  
> +/* allows to add/remove a custom action to devres stack */
> +int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
> +
> +/**
> + * devm_remove_action() - removes previously added custom action
> + * @dev: Device that owns the action
> + * @action: Function implementing the action
> + * @data: Pointer to data passed to @action implementation
> + *
> + * Removes instance of @action previously added by devm_add_action().
> + * Both action and data should match one of the existing entries.
> + */
> +static inline
> +void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
> +{
> +	WARN_ON(devm_remove_action_nowarn(dev, action, data));
> +}
> +
> +void devm_release_action(struct device *dev, void (*action)(void *), void *data);
> +
> +int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
> +#define devm_add_action(dev, action, data) \
> +	__devm_add_action(dev, action, data, #action)
> +
> +static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
> +					     void *data, const char *name)
> +{
> +	int ret;
> +
> +	ret = __devm_add_action(dev, action, data, name);
> +	if (ret)
> +		action(data);
> +
> +	return ret;
> +}
> +#define devm_add_action_or_reset(dev, action, data) \
> +	__devm_add_action_or_reset(dev, action, data, #action)
> +
>  #endif /* _DEVICE_DEVRES_H_ */

Reviewed-by: Zijun Hu <quic_zijuhu@quicinc.com>

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

* Re: [PATCH v2 2/3] devres: Add devm_is_action_added() helper
  2025-02-20 16:20 ` [PATCH v2 2/3] devres: Add devm_is_action_added() helper Andy Shevchenko
@ 2025-02-21  3:34   ` Zijun Hu
  0 siblings, 0 replies; 16+ messages in thread
From: Zijun Hu @ 2025-02-21  3:34 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, Bartosz Golaszewski,
	Raag Jadav, linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

On 2/21/2025 12:20 AM, Andy Shevchenko wrote:
> In some code we would like to know if the action in device managed resources
> was added by devm_add_action() family of calls. Introduce a helper for that.
> 
> Reviewed-by: Raag Jadav <raag.jadav@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/base/devres.c         | 11 +++++++++++
>  include/linux/device/devres.h |  2 ++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index 93e7779ef21e..7c2babfa9396 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -749,6 +749,17 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
>  }
>  EXPORT_SYMBOL_GPL(__devm_add_action);
>  
> +bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data)
> +{
> +	struct action_devres devres = {
> +		.data = data,
> +		.action = action,
> +	};
> +
> +	return devres_find(dev, devm_action_release, devm_action_match, &devres);
> +}
> +EXPORT_SYMBOL_GPL(devm_is_action_added);
> +
>  /**
>   * devm_remove_action_nowarn() - removes previously added custom action
>   * @dev: Device that owns the action
> diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
> index 9cd1787ef28e..ae696d10faff 100644
> --- a/include/linux/device/devres.h
> +++ b/include/linux/device/devres.h
> @@ -165,4 +165,6 @@ static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(
>  #define devm_add_action_or_reset(dev, action, data) \
>  	__devm_add_action_or_reset(dev, action, data, #action)
>  
> +bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data);
> +
>  #endif /* _DEVICE_DEVRES_H_ */

Reviewed-by: Zijun Hu <quic_zijuhu@quicinc.com>


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

* Re: [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
                   ` (2 preceding siblings ...)
  2025-02-20 16:20 ` [PATCH v2 3/3] gpiolib: devres: Finish the conversion to use devm_add_action() Andy Shevchenko
@ 2025-03-03 10:49 ` Andy Shevchenko
  2025-03-03 10:52   ` Bartosz Golaszewski
  2025-04-22 18:55 ` Andy Shevchenko
  2025-04-28  7:41 ` (subset) " Bartosz Golaszewski
  5 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-03-03 10:49 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Bartosz Golaszewski, Raag Jadav,
	linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

On Thu, Feb 20, 2025 at 06:20:25PM +0200, Andy Shevchenko wrote:
> GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> calls. This mini-series is for that. The necessary prerequisites are here
> as well, namely:
> 1) moving the respective APIs to the devres.h;
> 2) adding a simple helper that GPIOLIB will rely on;
> 3) finishing the GPIOLIB conversion to the device managed action APIs.
> 
> The series is based on another series that's available via immutable tag
> devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
> tree (or Intel GPIO for the starter) with an immutable tag for the device
> core and others if needed. Please, review and acknowledge.

Bart, I know it's still 2 days left till the two-week ping time, but since we
are at rc-5 and this may affect other subsystems I gently ask for your
Ack/Review and I push it to my branch for GPIO (as it has dependencies which
are already in my and a few other trees).

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-03-03 10:49 ` [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
@ 2025-03-03 10:52   ` Bartosz Golaszewski
  2025-03-03 11:19     ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2025-03-03 10:52 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Zijun Hu, Bartosz Golaszewski, Raag Jadav,
	linux-kernel, linux-gpio, Rafael J. Wysocki, Danilo Krummrich,
	Linus Walleij

On Mon, Mar 3, 2025 at 11:49 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Feb 20, 2025 at 06:20:25PM +0200, Andy Shevchenko wrote:
> > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > calls. This mini-series is for that. The necessary prerequisites are here
> > as well, namely:
> > 1) moving the respective APIs to the devres.h;
> > 2) adding a simple helper that GPIOLIB will rely on;
> > 3) finishing the GPIOLIB conversion to the device managed action APIs.
> >
> > The series is based on another series that's available via immutable tag
> > devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
> > tree (or Intel GPIO for the starter) with an immutable tag for the device
> > core and others if needed. Please, review and acknowledge.
>
> Bart, I know it's still 2 days left till the two-week ping time, but since we
> are at rc-5 and this may affect other subsystems I gently ask for your
> Ack/Review and I push it to my branch for GPIO (as it has dependencies which
> are already in my and a few other trees).
>

I thought this needs an Ack from Greg or Rafael?

Bart

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

* Re: [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-03-03 10:52   ` Bartosz Golaszewski
@ 2025-03-03 11:19     ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-03-03 11:19 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Zijun Hu, Bartosz Golaszewski, Raag Jadav,
	linux-kernel, linux-gpio, Rafael J. Wysocki, Danilo Krummrich,
	Linus Walleij

On Mon, Mar 03, 2025 at 11:52:07AM +0100, Bartosz Golaszewski wrote:
> On Mon, Mar 3, 2025 at 11:49 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Thu, Feb 20, 2025 at 06:20:25PM +0200, Andy Shevchenko wrote:
> > > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > > calls. This mini-series is for that. The necessary prerequisites are here
> > > as well, namely:
> > > 1) moving the respective APIs to the devres.h;
> > > 2) adding a simple helper that GPIOLIB will rely on;
> > > 3) finishing the GPIOLIB conversion to the device managed action APIs.
> > >
> > > The series is based on another series that's available via immutable tag
> > > devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
> > > tree (or Intel GPIO for the starter) with an immutable tag for the device
> > > core and others if needed. Please, review and acknowledge.
> >
> > Bart, I know it's still 2 days left till the two-week ping time, but since we
> > are at rc-5 and this may affect other subsystems I gently ask for your
> > Ack/Review and I push it to my branch for GPIO (as it has dependencies which
> > are already in my and a few other trees).
> 
> I thought this needs an Ack from Greg or Rafael?

Ah, you a right, I wasn't carefully looked who gave already the tags.
Greg, when you have time, can you ack this, please?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
                   ` (3 preceding siblings ...)
  2025-03-03 10:49 ` [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
@ 2025-04-22 18:55 ` Andy Shevchenko
  2025-04-25 13:22   ` Greg Kroah-Hartman
  2025-04-28  7:41 ` (subset) " Bartosz Golaszewski
  5 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-04-22 18:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Bartosz Golaszewski, Raag Jadav,
	linux-kernel, linux-gpio
  Cc: Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

On Thu, Feb 20, 2025 at 06:20:25PM +0200, Andy Shevchenko wrote:
> GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> calls. This mini-series is for that. The necessary prerequisites are here
> as well, namely:
> 1) moving the respective APIs to the devres.h;
> 2) adding a simple helper that GPIOLIB will rely on;
> 3) finishing the GPIOLIB conversion to the device managed action APIs.
> 
> The series is based on another series that's available via immutable tag
> devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
> tree (or Intel GPIO for the starter) with an immutable tag for the device
> core and others if needed. Please, review and acknowledge.

Greg, I know you are busy, but do you have a chance to look at this and give
your Ack if you are okay with the idea? The route is assumed to be via GPIOLIB
tree.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-04-22 18:55 ` Andy Shevchenko
@ 2025-04-25 13:22   ` Greg Kroah-Hartman
  2025-04-25 17:04     ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Greg Kroah-Hartman @ 2025-04-25 13:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Zijun Hu, Bartosz Golaszewski, Raag Jadav, linux-kernel,
	linux-gpio, Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

On Tue, Apr 22, 2025 at 09:55:02PM +0300, Andy Shevchenko wrote:
> On Thu, Feb 20, 2025 at 06:20:25PM +0200, Andy Shevchenko wrote:
> > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > calls. This mini-series is for that. The necessary prerequisites are here
> > as well, namely:
> > 1) moving the respective APIs to the devres.h;
> > 2) adding a simple helper that GPIOLIB will rely on;
> > 3) finishing the GPIOLIB conversion to the device managed action APIs.
> > 
> > The series is based on another series that's available via immutable tag
> > devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
> > tree (or Intel GPIO for the starter) with an immutable tag for the device
> > core and others if needed. Please, review and acknowledge.
> 
> Greg, I know you are busy, but do you have a chance to look at this and give
> your Ack if you are okay with the idea? The route is assumed to be via GPIOLIB
> tree.

Looks fine to me:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-04-25 13:22   ` Greg Kroah-Hartman
@ 2025-04-25 17:04     ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-04-25 17:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Zijun Hu, Bartosz Golaszewski, Raag Jadav, linux-kernel,
	linux-gpio, Rafael J. Wysocki, Danilo Krummrich, Linus Walleij,
	Bartosz Golaszewski

On Fri, Apr 25, 2025 at 03:22:33PM +0200, Greg Kroah-Hartman wrote:
> On Tue, Apr 22, 2025 at 09:55:02PM +0300, Andy Shevchenko wrote:
> > On Thu, Feb 20, 2025 at 06:20:25PM +0200, Andy Shevchenko wrote:
> > > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > > calls. This mini-series is for that. The necessary prerequisites are here
> > > as well, namely:
> > > 1) moving the respective APIs to the devres.h;
> > > 2) adding a simple helper that GPIOLIB will rely on;
> > > 3) finishing the GPIOLIB conversion to the device managed action APIs.
> > > 
> > > The series is based on another series that's available via immutable tag
> > > devres-iio-input-pinctrl-v6.15 [1]. The idea is to route this via GPIOLIB
> > > tree (or Intel GPIO for the starter) with an immutable tag for the device
> > > core and others if needed. Please, review and acknowledge.
> > 
> > Greg, I know you are busy, but do you have a chance to look at this and give
> > your Ack if you are okay with the idea? The route is assumed to be via GPIOLIB
> > tree.
> 
> Looks fine to me:
> 
> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thank you!
Bart, are you okay to take this series?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: (subset) [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
                   ` (4 preceding siblings ...)
  2025-04-22 18:55 ` Andy Shevchenko
@ 2025-04-28  7:41 ` Bartosz Golaszewski
  2025-04-28  7:47   ` Andy Shevchenko
  5 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2025-04-28  7:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Zijun Hu, Raag Jadav, linux-kernel,
	linux-gpio, Andy Shevchenko
  Cc: Bartosz Golaszewski, Rafael J. Wysocki, Danilo Krummrich,
	Linus Walleij, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Thu, 20 Feb 2025 18:20:25 +0200, Andy Shevchenko wrote:
> GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> calls. This mini-series is for that. The necessary prerequisites are here
> as well, namely:
> 1) moving the respective APIs to the devres.h;
> 2) adding a simple helper that GPIOLIB will rely on;
> 3) finishing the GPIOLIB conversion to the device managed action APIs.
> 
> [...]

Applied, thanks!

[3/3] gpiolib: devres: Finish the conversion to use devm_add_action()
      https://git.kernel.org/brgl/linux/c/d1d52c6622a61a0ae8dd2bd2097b25c0f553d2f3

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

* Re: (subset) [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-04-28  7:41 ` (subset) " Bartosz Golaszewski
@ 2025-04-28  7:47   ` Andy Shevchenko
  2025-04-28  7:48     ` Bartosz Golaszewski
  0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2025-04-28  7:47 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Zijun Hu, Raag Jadav, linux-kernel,
	linux-gpio, Bartosz Golaszewski, Rafael J. Wysocki,
	Danilo Krummrich, Linus Walleij

On Mon, Apr 28, 2025 at 09:41:52AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> On Thu, 20 Feb 2025 18:20:25 +0200, Andy Shevchenko wrote:
> > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > calls. This mini-series is for that. The necessary prerequisites are here
> > as well, namely:
> > 1) moving the respective APIs to the devres.h;
> > 2) adding a simple helper that GPIOLIB will rely on;
> > 3) finishing the GPIOLIB conversion to the device managed action APIs.

[...]

> Applied, thanks!

Thanks!

> [3/3] gpiolib: devres: Finish the conversion to use devm_add_action()
>       https://git.kernel.org/brgl/linux/c/d1d52c6622a61a0ae8dd2bd2097b25c0f553d2f3

Only one? What about the first two?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: (subset) [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-04-28  7:47   ` Andy Shevchenko
@ 2025-04-28  7:48     ` Bartosz Golaszewski
  2025-04-28  7:51       ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2025-04-28  7:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Zijun Hu, Raag Jadav, linux-kernel,
	linux-gpio, Bartosz Golaszewski, Rafael J. Wysocki,
	Danilo Krummrich, Linus Walleij

On Mon, Apr 28, 2025 at 9:47 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Mon, Apr 28, 2025 at 09:41:52AM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > On Thu, 20 Feb 2025 18:20:25 +0200, Andy Shevchenko wrote:
> > > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > > calls. This mini-series is for that. The necessary prerequisites are here
> > > as well, namely:
> > > 1) moving the respective APIs to the devres.h;
> > > 2) adding a simple helper that GPIOLIB will rely on;
> > > 3) finishing the GPIOLIB conversion to the device managed action APIs.
>
> [...]
>
> > Applied, thanks!
>
> Thanks!
>
> > [3/3] gpiolib: devres: Finish the conversion to use devm_add_action()
> >       https://git.kernel.org/brgl/linux/c/d1d52c6622a61a0ae8dd2bd2097b25c0f553d2f3
>
> Only one? What about the first two?

b4 borked with the patches applied to gpio/for-next through an
immutable tag but all is there, please check the tree.

Bart

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

* Re: (subset) [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs
  2025-04-28  7:48     ` Bartosz Golaszewski
@ 2025-04-28  7:51       ` Andy Shevchenko
  0 siblings, 0 replies; 16+ messages in thread
From: Andy Shevchenko @ 2025-04-28  7:51 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, Zijun Hu, Raag Jadav, linux-kernel,
	linux-gpio, Bartosz Golaszewski, Rafael J. Wysocki,
	Danilo Krummrich, Linus Walleij

On Mon, Apr 28, 2025 at 09:48:37AM +0200, Bartosz Golaszewski wrote:
> On Mon, Apr 28, 2025 at 9:47 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Mon, Apr 28, 2025 at 09:41:52AM +0200, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > On Thu, 20 Feb 2025 18:20:25 +0200, Andy Shevchenko wrote:
> > > > GPIOLIB has some open coded stuff that can be folded to the devm_*_action*()
> > > > calls. This mini-series is for that. The necessary prerequisites are here
> > > > as well, namely:
> > > > 1) moving the respective APIs to the devres.h;
> > > > 2) adding a simple helper that GPIOLIB will rely on;
> > > > 3) finishing the GPIOLIB conversion to the device managed action APIs.

[...]

> > > Applied, thanks!
> >
> > Thanks!
> >
> > > [3/3] gpiolib: devres: Finish the conversion to use devm_add_action()
> > >       https://git.kernel.org/brgl/linux/c/d1d52c6622a61a0ae8dd2bd2097b25c0f553d2f3
> >
> > Only one? What about the first two?
> 
> b4 borked with the patches applied to gpio/for-next through an
> immutable tag but all is there, please check the tree.

Yes, yes, sorry for the noise, and thank you!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2025-04-28  7:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 16:20 [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
2025-02-20 16:20 ` [PATCH v2 1/3] devres: Move devm_*_action*() APIs to devres.h Andy Shevchenko
2025-02-21  3:26   ` Zijun Hu
2025-02-20 16:20 ` [PATCH v2 2/3] devres: Add devm_is_action_added() helper Andy Shevchenko
2025-02-21  3:34   ` Zijun Hu
2025-02-20 16:20 ` [PATCH v2 3/3] gpiolib: devres: Finish the conversion to use devm_add_action() Andy Shevchenko
2025-03-03 10:49 ` [PATCH v2 0/3] gpiolib: finish conversion to devm_*_action*() APIs Andy Shevchenko
2025-03-03 10:52   ` Bartosz Golaszewski
2025-03-03 11:19     ` Andy Shevchenko
2025-04-22 18:55 ` Andy Shevchenko
2025-04-25 13:22   ` Greg Kroah-Hartman
2025-04-25 17:04     ` Andy Shevchenko
2025-04-28  7:41 ` (subset) " Bartosz Golaszewski
2025-04-28  7:47   ` Andy Shevchenko
2025-04-28  7:48     ` Bartosz Golaszewski
2025-04-28  7:51       ` Andy Shevchenko

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