Skip to content

Commit 317515c

Browse files
committed
Merge: CNB101: driver core: Split devres APIs to device/devres.h
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1237 JIRA: https://issues.redhat.com/browse/RHEL-105008 * 18311a7 err.h: move IOMEM_ERR_PTR() to err.h * a21cad9 driver core: Split devres APIs to device/devres.h * f5e5631 devres: Move devm_*_action*() APIs to devres.h Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-07-23 10:04 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://issues.redhat.com/secure/CreateIssueDetails!init.jspa?pid=12334433&issuetype=1&priority=4&summary=backporter+webhook+issue&components=kernel-workflow+/+backporter)</small> Approved-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Petr Oros <poros@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Julio Faracco <jfaracco@redhat.com>
2 parents da3ae24 + 2a42d83 commit 317515c

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

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: 39 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,42 @@ 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+
129168
#endif /* _DEVICE_DEVRES_H_ */

0 commit comments

Comments
 (0)