isdn/capi: make kcapi use a separate workqueue

flush_scheduled_work() is deprecated and will be removed.  Because
kcapi uses fire-and-forget type works, it's impossible to flush each
work explicitly.  Create and use a dedicated workqueue instead.

Please note that with recent workqueue changes, each workqueue doesn't
reserve a lot of resources and using it as a flush domain is fine.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Jan Kiszka <jan.kiszka@web.de>
This commit is contained in:
Tejun Heo 2010-12-24 15:59:06 +01:00
parent 7fa5e85a0a
commit 158fa67753

View File

@ -38,6 +38,7 @@
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
static int showcapimsgs = 0; static int showcapimsgs = 0;
static struct workqueue_struct *kcapi_wq;
MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer"); MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer");
MODULE_AUTHOR("Carsten Paeth"); MODULE_AUTHOR("Carsten Paeth");
@ -291,7 +292,7 @@ static int notify_push(unsigned int event_type, u32 controller)
event->type = event_type; event->type = event_type;
event->controller = controller; event->controller = controller;
schedule_work(&event->work); queue_work(kcapi_wq, &event->work);
return 0; return 0;
} }
@ -408,7 +409,7 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl,
goto error; goto error;
} }
skb_queue_tail(&ap->recv_queue, skb); skb_queue_tail(&ap->recv_queue, skb);
schedule_work(&ap->recv_work); queue_work(kcapi_wq, &ap->recv_work);
rcu_read_unlock(); rcu_read_unlock();
return; return;
@ -743,7 +744,7 @@ u16 capi20_release(struct capi20_appl *ap)
mutex_unlock(&capi_controller_lock); mutex_unlock(&capi_controller_lock);
flush_scheduled_work(); flush_workqueue(kcapi_wq);
skb_queue_purge(&ap->recv_queue); skb_queue_purge(&ap->recv_queue);
if (showcapimsgs & 1) { if (showcapimsgs & 1) {
@ -1285,21 +1286,30 @@ static int __init kcapi_init(void)
{ {
int err; int err;
kcapi_wq = alloc_workqueue("kcapi", 0, 0);
if (!kcapi_wq)
return -ENOMEM;
register_capictr_notifier(&capictr_nb); register_capictr_notifier(&capictr_nb);
err = cdebug_init(); err = cdebug_init();
if (!err) if (err) {
kcapi_proc_init(); unregister_capictr_notifier(&capictr_nb);
return err; destroy_workqueue(kcapi_wq);
return err;
}
kcapi_proc_init();
return 0;
} }
static void __exit kcapi_exit(void) static void __exit kcapi_exit(void)
{ {
kcapi_proc_exit(); kcapi_proc_exit();
/* make sure all notifiers are finished */ unregister_capictr_notifier(&capictr_nb);
flush_scheduled_work();
cdebug_exit(); cdebug_exit();
destroy_workqueue(kcapi_wq);
} }
module_init(kcapi_init); module_init(kcapi_init);