Skip to content

Commit 7920259

Browse files
djbwhtejun
authored andcommitted
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 <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent d70f5d5 commit 7920259

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

kernel/workqueue.c

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7246,25 +7246,27 @@ static ssize_t __wq_cpumask_show(struct device *dev,
72467246
return written;
72477247
}
72487248

7249-
static ssize_t wq_unbound_cpumask_show(struct device *dev,
7249+
static ssize_t cpumask_requested_show(struct device *dev,
72507250
struct device_attribute *attr, char *buf)
72517251
{
7252-
return __wq_cpumask_show(dev, attr, buf, wq_unbound_cpumask);
7252+
return __wq_cpumask_show(dev, attr, buf, wq_requested_unbound_cpumask);
72537253
}
7254+
static DEVICE_ATTR_RO(cpumask_requested);
72547255

7255-
static ssize_t wq_requested_cpumask_show(struct device *dev,
7256+
static ssize_t cpumask_isolated_show(struct device *dev,
72567257
struct device_attribute *attr, char *buf)
72577258
{
7258-
return __wq_cpumask_show(dev, attr, buf, wq_requested_unbound_cpumask);
7259+
return __wq_cpumask_show(dev, attr, buf, wq_isolated_cpumask);
72597260
}
7261+
static DEVICE_ATTR_RO(cpumask_isolated);
72607262

7261-
static ssize_t wq_isolated_cpumask_show(struct device *dev,
7263+
static ssize_t cpumask_show(struct device *dev,
72627264
struct device_attribute *attr, char *buf)
72637265
{
7264-
return __wq_cpumask_show(dev, attr, buf, wq_isolated_cpumask);
7266+
return __wq_cpumask_show(dev, attr, buf, wq_unbound_cpumask);
72657267
}
72667268

7267-
static ssize_t wq_unbound_cpumask_store(struct device *dev,
7269+
static ssize_t cpumask_store(struct device *dev,
72687270
struct device_attribute *attr, const char *buf, size_t count)
72697271
{
72707272
cpumask_var_t cpumask;
@@ -7280,36 +7282,19 @@ static ssize_t wq_unbound_cpumask_store(struct device *dev,
72807282
free_cpumask_var(cpumask);
72817283
return ret ? ret : count;
72827284
}
7285+
static DEVICE_ATTR_RW(cpumask);
72837286

7284-
static struct device_attribute wq_sysfs_cpumask_attrs[] = {
7285-
__ATTR(cpumask, 0644, wq_unbound_cpumask_show,
7286-
wq_unbound_cpumask_store),
7287-
__ATTR(cpumask_requested, 0444, wq_requested_cpumask_show, NULL),
7288-
__ATTR(cpumask_isolated, 0444, wq_isolated_cpumask_show, NULL),
7289-
__ATTR_NULL,
7287+
static struct attribute *wq_sysfs_cpumask_attrs[] = {
7288+
&dev_attr_cpumask.attr,
7289+
&dev_attr_cpumask_requested.attr,
7290+
&dev_attr_cpumask_isolated.attr,
7291+
NULL,
72907292
};
7293+
ATTRIBUTE_GROUPS(wq_sysfs_cpumask);
72917294

72927295
static int __init wq_sysfs_init(void)
72937296
{
7294-
struct device *dev_root;
7295-
int err;
7296-
7297-
err = subsys_virtual_register(&wq_subsys, NULL);
7298-
if (err)
7299-
return err;
7300-
7301-
dev_root = bus_get_dev_root(&wq_subsys);
7302-
if (dev_root) {
7303-
struct device_attribute *attr;
7304-
7305-
for (attr = wq_sysfs_cpumask_attrs; attr->attr.name; attr++) {
7306-
err = device_create_file(dev_root, attr);
7307-
if (err)
7308-
break;
7309-
}
7310-
put_device(dev_root);
7311-
}
7312-
return err;
7297+
return subsys_virtual_register(&wq_subsys, wq_sysfs_cpumask_groups);
73137298
}
73147299
core_initcall(wq_sysfs_init);
73157300

0 commit comments

Comments
 (0)