Skip to content

Commit e383bb8

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
devres: Add devm_is_action_added() helper
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 <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Zijun Hu <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent f5e5631 commit e383bb8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/base/devres.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,17 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
759759
}
760760
EXPORT_SYMBOL_GPL(__devm_add_action);
761761

762+
bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data)
763+
{
764+
struct action_devres devres = {
765+
.data = data,
766+
.action = action,
767+
};
768+
769+
return devres_find(dev, devm_action_release, devm_action_match, &devres);
770+
}
771+
EXPORT_SYMBOL_GPL(devm_is_action_added);
772+
762773
/**
763774
* devm_remove_action_nowarn() - removes previously added custom action
764775
* @dev: Device that owns the action

include/linux/device/devres.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,6 @@ static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(
165165
#define devm_add_action_or_reset(dev, action, data) \
166166
__devm_add_action_or_reset(dev, action, data, #action)
167167

168+
bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data);
169+
168170
#endif /* _DEVICE_DEVRES_H_ */

0 commit comments

Comments
 (0)