Skip to content

Commit 0e4965c

Browse files
committed
Merge tag 'gpiod-devm-is-action-added-for-v6.16-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/brgl/linux into driver-core-next
Immutable tag for the driver core tree to pull from devres: Move devm_*_action*() APIs to devres.h devres: Add devm_is_action_added() helper * tag 'gpiod-devm-is-action-added-for-v6.16-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/brgl/linux: devres: Add devm_is_action_added() helper devres: Move devm_*_action*() APIs to devres.h
2 parents 785151f + e383bb8 commit 0e4965c

File tree

3 files changed

+52
-38
lines changed

3 files changed

+52
-38
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.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -281,44 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,
281281
void device_remove_bin_file(struct device *dev,
282282
const struct bin_attribute *attr);
283283

284-
/* allows to add/remove a custom action to devres stack */
285-
int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
286-
287-
/**
288-
* devm_remove_action() - removes previously added custom action
289-
* @dev: Device that owns the action
290-
* @action: Function implementing the action
291-
* @data: Pointer to data passed to @action implementation
292-
*
293-
* Removes instance of @action previously added by devm_add_action().
294-
* Both action and data should match one of the existing entries.
295-
*/
296-
static inline
297-
void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
298-
{
299-
WARN_ON(devm_remove_action_nowarn(dev, action, data));
300-
}
301-
302-
void devm_release_action(struct device *dev, void (*action)(void *), void *data);
303-
304-
int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
305-
#define devm_add_action(dev, action, data) \
306-
__devm_add_action(dev, action, data, #action)
307-
308-
static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
309-
void *data, const char *name)
310-
{
311-
int ret;
312-
313-
ret = __devm_add_action(dev, action, data, name);
314-
if (ret)
315-
action(data);
316-
317-
return ret;
318-
}
319-
#define devm_add_action_or_reset(dev, action, data) \
320-
__devm_add_action_or_reset(dev, action, data, #action)
321-
322284
/**
323285
* devm_alloc_percpu - Resource-managed alloc_percpu
324286
* @dev: Device to allocate per-cpu memory for

include/linux/device/devres.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/overflow.h>
99
#include <linux/stdarg.h>
1010
#include <linux/types.h>
11+
#include <asm/bug.h>
1112

1213
struct device;
1314
struct device_node;
@@ -126,4 +127,44 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
126127

127128
#endif
128129

130+
/* allows to add/remove a custom action to devres stack */
131+
int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
132+
133+
/**
134+
* devm_remove_action() - removes previously added custom action
135+
* @dev: Device that owns the action
136+
* @action: Function implementing the action
137+
* @data: Pointer to data passed to @action implementation
138+
*
139+
* Removes instance of @action previously added by devm_add_action().
140+
* Both action and data should match one of the existing entries.
141+
*/
142+
static inline
143+
void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
144+
{
145+
WARN_ON(devm_remove_action_nowarn(dev, action, data));
146+
}
147+
148+
void devm_release_action(struct device *dev, void (*action)(void *), void *data);
149+
150+
int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
151+
#define devm_add_action(dev, action, data) \
152+
__devm_add_action(dev, action, data, #action)
153+
154+
static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
155+
void *data, const char *name)
156+
{
157+
int ret;
158+
159+
ret = __devm_add_action(dev, action, data, name);
160+
if (ret)
161+
action(data);
162+
163+
return ret;
164+
}
165+
#define devm_add_action_or_reset(dev, action, data) \
166+
__devm_add_action_or_reset(dev, action, data, #action)
167+
168+
bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data);
169+
129170
#endif /* _DEVICE_DEVRES_H_ */

0 commit comments

Comments
 (0)