Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+52 -38
+11
drivers/base/devres.c
··· 759 759 } 760 760 EXPORT_SYMBOL_GPL(__devm_add_action); 761 761 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 + 762 773 /** 763 774 * devm_remove_action_nowarn() - removes previously added custom action 764 775 * @dev: Device that owns the action
-38
include/linux/device.h
··· 281 281 void device_remove_bin_file(struct device *dev, 282 282 const struct bin_attribute *attr); 283 283 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 - 322 284 /** 323 285 * devm_alloc_percpu - Resource-managed alloc_percpu 324 286 * @dev: Device to allocate per-cpu memory for
+41
include/linux/device/devres.h
··· 8 8 #include <linux/overflow.h> 9 9 #include <linux/stdarg.h> 10 10 #include <linux/types.h> 11 + #include <asm/bug.h> 11 12 12 13 struct device; 13 14 struct device_node; ··· 126 125 } 127 126 128 127 #endif 128 + 129 + /* allows to add/remove a custom action to devres stack */ 130 + int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data); 131 + 132 + /** 133 + * devm_remove_action() - removes previously added custom action 134 + * @dev: Device that owns the action 135 + * @action: Function implementing the action 136 + * @data: Pointer to data passed to @action implementation 137 + * 138 + * Removes instance of @action previously added by devm_add_action(). 139 + * Both action and data should match one of the existing entries. 140 + */ 141 + static inline 142 + void devm_remove_action(struct device *dev, void (*action)(void *), void *data) 143 + { 144 + WARN_ON(devm_remove_action_nowarn(dev, action, data)); 145 + } 146 + 147 + void devm_release_action(struct device *dev, void (*action)(void *), void *data); 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 + bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data); 129 168 130 169 #endif /* _DEVICE_DEVRES_H_ */