Messages in this thread Patch in this message |  | | From | Pei Xiao <> | | Subject | [PATCH] devres: Move remaining devm_alloc_percpu and devm_device_add_group to devres.h | | Date | Thu, 22 May 2025 17:01:26 +0800 |
| |
Since commit f5e5631df596("devres: Move devm_*_action*() APIs to devres.h"), But devm_alloc_percpu() and devm_device_add_group didn't be moved.
so move it.The changes improve header organization by keeping all resource-managed device APIs in the dedicated devres.h header, reducing cross-header dependencies and making the interfaces easier to locate.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> --- include/linux/device.h | 21 --------------------- include/linux/device/devres.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h index 4940db137fff..6dd6ae8f405b 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -281,25 +281,6 @@ int __must_check device_create_bin_file(struct device *dev, void device_remove_bin_file(struct device *dev, const struct bin_attribute *attr); -/** - * devm_alloc_percpu - Resource-managed alloc_percpu - * @dev: Device to allocate per-cpu memory for - * @type: Type to allocate per-cpu memory for - * - * Managed alloc_percpu. Per-cpu memory allocated with this function is - * automatically freed on driver detach. - * - * RETURNS: - * Pointer to allocated memory on success, NULL on failure. - */ -#define devm_alloc_percpu(dev, type) \ - ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \ - __alignof__(type))) - -void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, - size_t align); -void devm_free_percpu(struct device *dev, void __percpu *pdata); - struct device_dma_parameters { /* * a low level driver may set these to teach IOMMU code about @@ -1127,8 +1108,6 @@ static inline void device_remove_group(struct device *dev, device_remove_groups(dev, groups); } -int __must_check devm_device_add_group(struct device *dev, - const struct attribute_group *grp); /* * get_device - atomically increment the reference count for the device. diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h index ae696d10faff..624ba81d4d8b 100644 --- a/include/linux/device/devres.h +++ b/include/linux/device/devres.h @@ -7,8 +7,10 @@ #include <linux/numa.h> #include <linux/overflow.h> #include <linux/stdarg.h> +#include <linux/sysfs.h> #include <linux/types.h> #include <asm/bug.h> +#include <asm/percpu.h> struct device; struct device_node; @@ -167,4 +169,26 @@ static inline int __devm_add_action_or_reset(struct device *dev, void (*action)( bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data); +/** + * devm_alloc_percpu - Resource-managed alloc_percpu + * @dev: Device to allocate per-cpu memory for + * @type: Type to allocate per-cpu memory for + * + * Managed alloc_percpu. Per-cpu memory allocated with this function is + * automatically freed on driver detach. + * + * RETURNS: + * Pointer to allocated memory on success, NULL on failure. + */ +#define devm_alloc_percpu(dev, type) \ + ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \ + __alignof__(type))) + +void __percpu *__devm_alloc_percpu(struct device *dev, size_t size, + size_t align); +void devm_free_percpu(struct device *dev, void __percpu *pdata); + +int __must_check devm_device_add_group(struct device *dev, + const struct attribute_group *grp); + #endif /* _DEVICE_DEVRES_H_ */ -- 2.25.1
|  |