Re: [PATCH 3/4] workqueue: Add anon workqueue sysfs hierarchy

Viresh Kumar
2014-04-03T07:07:07Z

On 27 March 2014 22:51, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c

> static int __init wq_sysfs_init(void)
> {
> - return subsys_virtual_register(&wq_subsys, NULL);
> + struct device *anon_dev;
> + int ret;
> +
> + ret = subsys_virtual_register(&wq_subsys, NULL);
> + if (ret < 0)
> + return ret;
> +
> + mutex_lock(&wq_unbound_mutex);
> + cpumask_copy(&wq_anon_cpumask, cpu_possible_mask);
> + mutex_unlock(&wq_unbound_mutex);
> +
> + anon_dev = kzalloc(sizeof(*anon_dev), GFP_KERNEL);
> + if (!anon_dev)
> + return -ENOMEM;
> +
> + anon_dev->bus = &wq_subsys;
> + anon_dev->init_name = "anon_wqs";
> + anon_dev->release = device_release;
> +
> + ret = device_register(anon_dev);
> + if (ret) {
> + kfree(anon_dev);
> + return ret;
> + }
> +
> + ret = device_create_file(anon_dev, &wq_sysfs_anon_attr);
> + if (ret) {
> + device_unregister(anon_dev);

kfree(anon_dev) ??

> + return ret;
> + }
> +
> + kobject_uevent(&anon_dev->kobj, KOBJ_ADD);
> +
> + return 0;
> }
> core_initcall(wq_sysfs_init);