Commit 0433686c authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

devres: Pass unique name of the resource to devm_add_action()

Pass the unique name of the resource to devm_add_action(),
so it will be easier to debug managed resources.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230224200745.17324-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 295209ca
...@@ -722,20 +722,21 @@ static void devm_action_release(struct device *dev, void *res) ...@@ -722,20 +722,21 @@ static void devm_action_release(struct device *dev, void *res)
} }
/** /**
* devm_add_action() - add a custom action to list of managed resources * __devm_add_action() - add a custom action to list of managed resources
* @dev: Device that owns the action * @dev: Device that owns the action
* @action: Function that should be called * @action: Function that should be called
* @data: Pointer to data passed to @action implementation * @data: Pointer to data passed to @action implementation
* @name: Name of the resource (for debugging purposes)
* *
* This adds a custom action to the list of managed resources so that * This adds a custom action to the list of managed resources so that
* it gets executed as part of standard resource unwinding. * it gets executed as part of standard resource unwinding.
*/ */
int devm_add_action(struct device *dev, void (*action)(void *), void *data) int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name)
{ {
struct action_devres *devres; struct action_devres *devres;
devres = devres_alloc(devm_action_release, devres = __devres_alloc_node(devm_action_release, sizeof(struct action_devres),
sizeof(struct action_devres), GFP_KERNEL); GFP_KERNEL, NUMA_NO_NODE, name);
if (!devres) if (!devres)
return -ENOMEM; return -ENOMEM;
...@@ -745,7 +746,7 @@ int devm_add_action(struct device *dev, void (*action)(void *), void *data) ...@@ -745,7 +746,7 @@ int devm_add_action(struct device *dev, void (*action)(void *), void *data)
devres_add(dev, devres); devres_add(dev, devres);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(devm_add_action); EXPORT_SYMBOL_GPL(__devm_add_action);
/** /**
* devm_remove_action() - removes previously added custom action * devm_remove_action() - removes previously added custom action
......
...@@ -243,10 +243,13 @@ void __iomem *devm_of_iomap(struct device *dev, ...@@ -243,10 +243,13 @@ void __iomem *devm_of_iomap(struct device *dev,
resource_size_t *size); resource_size_t *size);
/* allows to add/remove a custom action to devres stack */ /* allows to add/remove a custom action to devres stack */
int devm_add_action(struct device *dev, void (*action)(void *), void *data);
void devm_remove_action(struct device *dev, void (*action)(void *), void *data); void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
void devm_release_action(struct device *dev, void (*action)(void *), void *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(release, action, data) \
__devm_add_action(release, action, data, #action)
static inline int devm_add_action_or_reset(struct device *dev, static inline int devm_add_action_or_reset(struct device *dev,
void (*action)(void *), void *data) void (*action)(void *), void *data)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment