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.

workqueue: Cleanup subsys attribute registration

While reviewing users of subsys_virtual_register() I noticed that
wq_sysfs_init() ignores the @groups argument. This looks like a
historical artifact as the original wq_subsys only had one attribute to
register.

On the way to building up an @groups argument to pass to
subsys_virtual_register() a few more cleanups fell out:

* Use DEVICE_ATTR_RO() and DEVICE_ATTR_RW() for
cpumask_{isolated,requested} and cpumask respectively. Rename the
@show and @store methods accordingly.

* Co-locate the attribute definition with the methods. This required
moving wq_unbound_cpumask_show down next to wq_unbound_cpumask_store
(renamed to cpumask_show() and cpumask_store())

* Use ATTRIBUTE_GROUPS() to skip some boilerplate declarations

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Dan Williams and committed by
Tejun Heo
79202591 d70f5d57

+24 -39
+24 -39
kernel/workqueue.c
··· 7246 7246 return written; 7247 7247 } 7248 7248 7249 - static ssize_t wq_unbound_cpumask_show(struct device *dev, 7249 + static ssize_t cpumask_requested_show(struct device *dev, 7250 + struct device_attribute *attr, char *buf) 7251 + { 7252 + return __wq_cpumask_show(dev, attr, buf, wq_requested_unbound_cpumask); 7253 + } 7254 + static DEVICE_ATTR_RO(cpumask_requested); 7255 + 7256 + static ssize_t cpumask_isolated_show(struct device *dev, 7257 + struct device_attribute *attr, char *buf) 7258 + { 7259 + return __wq_cpumask_show(dev, attr, buf, wq_isolated_cpumask); 7260 + } 7261 + static DEVICE_ATTR_RO(cpumask_isolated); 7262 + 7263 + static ssize_t cpumask_show(struct device *dev, 7250 7264 struct device_attribute *attr, char *buf) 7251 7265 { 7252 7266 return __wq_cpumask_show(dev, attr, buf, wq_unbound_cpumask); 7253 7267 } 7254 7268 7255 - static ssize_t wq_requested_cpumask_show(struct device *dev, 7256 - struct device_attribute *attr, char *buf) 7257 - { 7258 - return __wq_cpumask_show(dev, attr, buf, wq_requested_unbound_cpumask); 7259 - } 7260 - 7261 - static ssize_t wq_isolated_cpumask_show(struct device *dev, 7262 - struct device_attribute *attr, char *buf) 7263 - { 7264 - return __wq_cpumask_show(dev, attr, buf, wq_isolated_cpumask); 7265 - } 7266 - 7267 - static ssize_t wq_unbound_cpumask_store(struct device *dev, 7269 + static ssize_t cpumask_store(struct device *dev, 7268 7270 struct device_attribute *attr, const char *buf, size_t count) 7269 7271 { 7270 7272 cpumask_var_t cpumask; ··· 7282 7280 free_cpumask_var(cpumask); 7283 7281 return ret ? ret : count; 7284 7282 } 7283 + static DEVICE_ATTR_RW(cpumask); 7285 7284 7286 - static struct device_attribute wq_sysfs_cpumask_attrs[] = { 7287 - __ATTR(cpumask, 0644, wq_unbound_cpumask_show, 7288 - wq_unbound_cpumask_store), 7289 - __ATTR(cpumask_requested, 0444, wq_requested_cpumask_show, NULL), 7290 - __ATTR(cpumask_isolated, 0444, wq_isolated_cpumask_show, NULL), 7291 - __ATTR_NULL, 7285 + static struct attribute *wq_sysfs_cpumask_attrs[] = { 7286 + &dev_attr_cpumask.attr, 7287 + &dev_attr_cpumask_requested.attr, 7288 + &dev_attr_cpumask_isolated.attr, 7289 + NULL, 7292 7290 }; 7291 + ATTRIBUTE_GROUPS(wq_sysfs_cpumask); 7293 7292 7294 7293 static int __init wq_sysfs_init(void) 7295 7294 { 7296 - struct device *dev_root; 7297 - int err; 7298 - 7299 - err = subsys_virtual_register(&wq_subsys, NULL); 7300 - if (err) 7301 - return err; 7302 - 7303 - dev_root = bus_get_dev_root(&wq_subsys); 7304 - if (dev_root) { 7305 - struct device_attribute *attr; 7306 - 7307 - for (attr = wq_sysfs_cpumask_attrs; attr->attr.name; attr++) { 7308 - err = device_create_file(dev_root, attr); 7309 - if (err) 7310 - break; 7311 - } 7312 - put_device(dev_root); 7313 - } 7314 - return err; 7295 + return subsys_virtual_register(&wq_subsys, wq_sysfs_cpumask_groups); 7315 7296 } 7316 7297 core_initcall(wq_sysfs_init); 7317 7298