include/linux/device.h | 60 ----------------------------------- include/linux/device/devres.h | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 60 deletions(-)
From: Pei Xiao <xiaopei01@kylinos.cn>
Since a21cad931276 ("driver core: Split devres APIs to
device/devres.h"),but some APIs like 'devm_alloc_percpu' didn't move to
devres.h. we should also move it.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
include/linux/device.h | 60 -----------------------------------
include/linux/device/devres.h | 58 +++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index ec330af24151..ab383a9bbc17 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -281,63 +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);
-/* allows to add/remove a custom action to devres stack */
-int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
-
-/**
- * devm_remove_action() - removes previously added custom action
- * @dev: Device that owns the action
- * @action: Function implementing the action
- * @data: Pointer to data passed to @action implementation
- *
- * Removes instance of @action previously added by devm_add_action().
- * Both action and data should match one of the existing entries.
- */
-static inline
-void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
-{
- WARN_ON(devm_remove_action_nowarn(dev, action, 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(dev, action, data) \
- __devm_add_action(dev, action, data, #action)
-
-static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
- void *data, const char *name)
-{
- int ret;
-
- ret = __devm_add_action(dev, action, data, name);
- if (ret)
- action(data);
-
- return ret;
-}
-#define devm_add_action_or_reset(dev, action, data) \
- __devm_add_action_or_reset(dev, action, data, #action)
-
-/**
- * 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
@@ -1163,9 +1106,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 9b49f9915850..8f93f7388dc1 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -126,4 +126,62 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
#endif
+/* allows to add/remove a custom action to devres stack */
+int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
+
+/**
+ * devm_remove_action() - removes previously added custom action
+ * @dev: Device that owns the action
+ * @action: Function implementing the action
+ * @data: Pointer to data passed to @action implementation
+ *
+ * Removes instance of @action previously added by devm_add_action().
+ * Both action and data should match one of the existing entries.
+ */
+static inline
+void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
+{
+ WARN_ON(devm_remove_action_nowarn(dev, action, 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(dev, action, data) \
+ __devm_add_action(dev, action, data, #action)
+
+static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
+ void *data, const char *name)
+{
+ int ret;
+
+ ret = __devm_add_action(dev, action, data, name);
+ if (ret)
+ action(data);
+
+ return ret;
+}
+#define devm_add_action_or_reset(dev, action, data) \
+ __devm_add_action_or_reset(dev, action, data, #action)
+
+/**
+ * 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
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on next-20250227]
[cannot apply to linus/master v6.14-rc4 v6.14-rc3 v6.14-rc2 v6.14-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/xiaopeitux-foxmail-com/driver-core-Split-devres-APIs-to-device-devres-h/20250228-172012
base: next-20250227
patch link: https://lore.kernel.org/r/tencent_66CF9C91EB4A4417F70E9511649A57DEC906%40qq.com
patch subject: [PATCH] driver core: Split devres APIs to device/devres.h
config: arm64-randconfig-004-20250301 (https://download.01.org/0day-ci/archive/20250301/202503011920.E8wPk3yy-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250301/202503011920.E8wPk3yy-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503011920.E8wPk3yy-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:10:
>> include/linux/device/devres.h:182:6: error: variable has incomplete type 'void'
182 | void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
| ^
include/linux/compiler_types.h:60:19: note: expanded from macro '__percpu'
60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:10:
>> include/linux/device/devres.h:182:15: error: expected ';' after top level declarator
182 | void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
| ^
>> include/linux/device/devres.h:184:57: error: expected ')'
184 | void devm_free_percpu(struct device *dev, void __percpu *pdata);
| ^
include/linux/device/devres.h:184:22: note: to match this '('
184 | void devm_free_percpu(struct device *dev, void __percpu *pdata);
| ^
>> include/linux/device/devres.h:184:48: error: 'void' must be the first and only parameter if specified
184 | void devm_free_percpu(struct device *dev, void __percpu *pdata);
| ^
include/linux/compiler_types.h:60:19: note: expanded from macro '__percpu'
60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:10:
>> include/linux/device/devres.h:186:25: warning: declaration of 'struct attribute_group' will not be visible outside of this function [-Wvisibility]
186 | const struct attribute_group *grp);
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:13:
In file included from include/linux/i2c.h:13:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:141:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:13:
In file included from include/linux/i2c.h:13:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:141:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:13:
In file included from include/linux/i2c.h:13:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:141:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
99 | set->sig[1] | set->sig[0]) == 0;
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:13:
In file included from include/linux/i2c.h:13:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:141:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
101 | return (set->sig[1] | set->sig[0]) == 0;
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:13:
In file included from include/linux/i2c.h:13:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:141:
In file included from include/linux/fs.h:34:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
include/uapi/asm-generic/signal.h:62:2: note: array 'sig' declared here
62 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c:13:
In file included from include/linux/i2c.h:13:
In file included from include/linux/acpi.h:14:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:141:
vim +/void +182 include/linux/device/devres.h
148
149 int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
150 #define devm_add_action(dev, action, data) \
151 __devm_add_action(dev, action, data, #action)
152
153 static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
154 void *data, const char *name)
155 {
156 int ret;
157
158 ret = __devm_add_action(dev, action, data, name);
159 if (ret)
160 action(data);
161
162 return ret;
163 }
164 #define devm_add_action_or_reset(dev, action, data) \
165 __devm_add_action_or_reset(dev, action, data, #action)
166
167 /**
168 * devm_alloc_percpu - Resource-managed alloc_percpu
169 * @dev: Device to allocate per-cpu memory for
170 * @type: Type to allocate per-cpu memory for
171 *
172 * Managed alloc_percpu. Per-cpu memory allocated with this function is
173 * automatically freed on driver detach.
174 *
175 * RETURNS:
176 * Pointer to allocated memory on success, NULL on failure.
177 */
178 #define devm_alloc_percpu(dev, type) \
179 ((typeof(type) __percpu *)__devm_alloc_percpu((dev), sizeof(type), \
180 __alignof__(type)))
181
> 182 void __percpu *__devm_alloc_percpu(struct device *dev, size_t size,
183 size_t align);
> 184 void devm_free_percpu(struct device *dev, void __percpu *pdata);
185 int __must_check devm_device_add_group(struct device *dev,
> 186 const struct attribute_group *grp);
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Fri, Feb 28, 2025 at 05:18:35PM +0800, xiaopeitux@foxmail.com wrote:
> From: Pei Xiao <xiaopei01@kylinos.cn>
>
> Since a21cad931276 ("driver core: Split devres APIs to
> device/devres.h"),but some APIs like 'devm_alloc_percpu' didn't move to
> devres.h. we should also move it.
Action move is part of the next step, see this [1].
So, basically you should take your --base branch, merge the immutable tag [2],
apply patch series from [1] and then create a patch of the leftovers as
mentioned in your commit message above.
[1]: https://lore.kernel.org/r/20250220162238.2738038-1-andriy.shevchenko@linux.intel.com
[2]: https://lore.kernel.org/r/Z7xGpz3Q4Zj6YHx7@black.fi.intel.com
--
With Best Regards,
Andy Shevchenko
在 2025/2/28 17:18, xiaopeitux@foxmail.com 写道:
> From: Pei Xiao <xiaopei01@kylinos.cn>
>
> Since a21cad931276 ("driver core: Split devres APIs to
> device/devres.h"),but some APIs like 'devm_alloc_percpu' didn't move to
> devres.h. we should also move it.
sorry, I forgot to modify the subject. This is an RFC.
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
> include/linux/device.h | 60 -----------------------------------
> include/linux/device/devres.h | 58 +++++++++++++++++++++++++++++++++
> 2 files changed, 58 insertions(+), 60 deletions(-)
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index ec330af24151..ab383a9bbc17 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -281,63 +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);
>
> -/* allows to add/remove a custom action to devres stack */
> -int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
> -
> -/**
> - * devm_remove_action() - removes previously added custom action
> - * @dev: Device that owns the action
> - * @action: Function implementing the action
> - * @data: Pointer to data passed to @action implementation
> - *
> - * Removes instance of @action previously added by devm_add_action().
> - * Both action and data should match one of the existing entries.
> - */
> -static inline
> -void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
> -{
> - WARN_ON(devm_remove_action_nowarn(dev, action, 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(dev, action, data) \
> - __devm_add_action(dev, action, data, #action)
> -
> -static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
> - void *data, const char *name)
> -{
> - int ret;
> -
> - ret = __devm_add_action(dev, action, data, name);
> - if (ret)
> - action(data);
> -
> - return ret;
> -}
> -#define devm_add_action_or_reset(dev, action, data) \
> - __devm_add_action_or_reset(dev, action, data, #action)
> -
> -/**
> - * 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
> @@ -1163,9 +1106,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 9b49f9915850..8f93f7388dc1 100644
> --- a/include/linux/device/devres.h
> +++ b/include/linux/device/devres.h
> @@ -126,4 +126,62 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
>
> #endif
>
> +/* allows to add/remove a custom action to devres stack */
> +int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
> +
> +/**
> + * devm_remove_action() - removes previously added custom action
> + * @dev: Device that owns the action
> + * @action: Function implementing the action
> + * @data: Pointer to data passed to @action implementation
> + *
> + * Removes instance of @action previously added by devm_add_action().
> + * Both action and data should match one of the existing entries.
> + */
> +static inline
> +void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
> +{
> + WARN_ON(devm_remove_action_nowarn(dev, action, 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(dev, action, data) \
> + __devm_add_action(dev, action, data, #action)
> +
> +static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
> + void *data, const char *name)
> +{
> + int ret;
> +
> + ret = __devm_add_action(dev, action, data, name);
> + if (ret)
> + action(data);
> +
> + return ret;
> +}
> +#define devm_add_action_or_reset(dev, action, data) \
> + __devm_add_action_or_reset(dev, action, data, #action)
> +
> +/**
> + * 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_ */
On Fri, Feb 28, 2025 at 05:28:56PM +0800, Pei Xiao wrote:
> 在 2025/2/28 17:18, xiaopeitux@foxmail.com 写道:
> >
> > Since a21cad931276 ("driver core: Split devres APIs to
> > device/devres.h"),but some APIs like 'devm_alloc_percpu' didn't move to
> > devres.h. we should also move it.
> sorry, I forgot to modify the subject. This is an RFC.
You don't need to have it as an RFC, just base on the resent changes.
--
With Best Regards,
Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.