From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Zijun Hu <quic_zijuhu@quicinc.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
Raag Jadav <raag.jadav@intel.com>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH v2 2/3] devres: Add devm_is_action_added() helper
Date: Thu, 20 Feb 2025 18:20:27 +0200 [thread overview]
Message-ID: <20250220162238.2738038-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250220162238.2738038-1-andriy.shevchenko@linux.intel.com>
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
next prev parent reply other threads:[~2025-02-20 16:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Andy Shevchenko [this message]
2025-02-21 3:34 ` [PATCH v2 2/3] devres: Add devm_is_action_added() helper 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250220162238.2738038-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_zijuhu@quicinc.com \
--cc=raag.jadav@intel.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).