]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
devres: Add devm_is_action_added() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 20 Feb 2025 16:20:27 +0000 (18:20 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 28 Apr 2025 07:30:41 +0000 (09:30 +0200)
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>
Reviewed-by: Zijun Hu <quic_zijuhu@quicinc.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250220162238.2738038-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/base/devres.c
include/linux/device/devres.h

index d8a733ea5e1ac8ac89a119934c6774828f526692..7c20517a52c2a4e2f5faae9379c3598ffa616f13 100644 (file)
@@ -759,6 +759,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
index 9cd1787ef28ed9012438342a88214a6fac7f1790..ae696d10faff4468a41f37b5d5fd679d4ff11997 100644 (file)
@@ -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_ */