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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-7.1-devm-alloc-wq' into for-7.1

Tejun Heo b39bf7f0 c116737e

+54
+4
Documentation/driver-api/driver-model/devres.rst
··· 464 464 465 465 WATCHDOG 466 466 devm_watchdog_register_device() 467 + 468 + WORKQUEUE 469 + devm_alloc_workqueue() 470 + devm_alloc_ordered_workqueue()
+22
include/linux/workqueue.h
··· 516 516 alloc_workqueue_noprof(const char *fmt, unsigned int flags, int max_active, ...); 517 517 #define alloc_workqueue(...) alloc_hooks(alloc_workqueue_noprof(__VA_ARGS__)) 518 518 519 + /** 520 + * devm_alloc_workqueue - Resource-managed allocate a workqueue 521 + * @dev: Device to allocate workqueue for 522 + * @fmt: printf format for the name of the workqueue 523 + * @flags: WQ_* flags 524 + * @max_active: max in-flight work items, 0 for default 525 + * @...: args for @fmt 526 + * 527 + * Resource managed workqueue, see alloc_workqueue() for details. 528 + * 529 + * The workqueue will be automatically destroyed on driver detach. Typically 530 + * this should be used in drivers already relying on devm interafaces. 531 + * 532 + * RETURNS: 533 + * Pointer to the allocated workqueue on success, %NULL on failure. 534 + */ 535 + __printf(2, 5) struct workqueue_struct * 536 + devm_alloc_workqueue(struct device *dev, const char *fmt, unsigned int flags, 537 + int max_active, ...); 538 + 519 539 #ifdef CONFIG_LOCKDEP 520 540 /** 521 541 * alloc_workqueue_lockdep_map - allocate a workqueue with user-defined lockdep_map ··· 592 572 */ 593 573 #define alloc_ordered_workqueue(fmt, flags, args...) \ 594 574 alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args) 575 + #define devm_alloc_ordered_workqueue(dev, fmt, flags, args...) \ 576 + devm_alloc_workqueue(dev, fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args) 595 577 596 578 #define create_workqueue(name) \ 597 579 alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_PERCPU, 1, (name))
+28
kernel/workqueue.c
··· 41 41 #include <linux/mempolicy.h> 42 42 #include <linux/freezer.h> 43 43 #include <linux/debug_locks.h> 44 + #include <linux/device/devres.h> 44 45 #include <linux/lockdep.h> 45 46 #include <linux/idr.h> 46 47 #include <linux/jhash.h> ··· 5893 5892 return wq; 5894 5893 } 5895 5894 EXPORT_SYMBOL_GPL(alloc_workqueue_noprof); 5895 + 5896 + static void devm_workqueue_release(void *res) 5897 + { 5898 + destroy_workqueue(res); 5899 + } 5900 + 5901 + __printf(2, 5) struct workqueue_struct * 5902 + devm_alloc_workqueue(struct device *dev, const char *fmt, unsigned int flags, 5903 + int max_active, ...) 5904 + { 5905 + struct workqueue_struct *wq; 5906 + va_list args; 5907 + int ret; 5908 + 5909 + va_start(args, max_active); 5910 + wq = alloc_workqueue(fmt, flags, max_active, args); 5911 + va_end(args); 5912 + if (!wq) 5913 + return NULL; 5914 + 5915 + ret = devm_add_action_or_reset(dev, devm_workqueue_release, wq); 5916 + if (ret) 5917 + return NULL; 5918 + 5919 + return wq; 5920 + } 5921 + EXPORT_SYMBOL_GPL(devm_alloc_workqueue); 5896 5922 5897 5923 #ifdef CONFIG_LOCKDEP 5898 5924 __printf(1, 5)