From 7fa5e85a0ab9ed5d2d8b77eec7976c88a5911bda Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 24 Dec 2010 15:59:05 +0100 Subject: isdn/capi: unregister capictr notifier after init failure capidrv_init() could leave capictr notifier dangling after init failure. Fix it. Signed-off-by: Tejun Heo Acked-by: Jan Kiszka --- drivers/isdn/capi/capidrv.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/isdn') diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index e54e79d4e2c1..92607ed25e2e 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c @@ -2297,6 +2297,7 @@ static int __init capidrv_init(void) errcode = capi20_get_profile(0, &profile); if (errcode != CAPI_NOERROR) { + unregister_capictr_notifier(&capictr_nb); capi20_release(&global.ap); return -EIO; } -- cgit v1.2.3 From 158fa67753e1eb3edfa5a2d1868666d89d1cf09f Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 24 Dec 2010 15:59:06 +0100 Subject: 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 Acked-by: Jan Kiszka --- drivers/isdn/capi/kcapi.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'drivers/isdn') diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 3acf94cc5acd..2b33b2627fce 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -38,6 +38,7 @@ #include static int showcapimsgs = 0; +static struct workqueue_struct *kcapi_wq; MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer"); MODULE_AUTHOR("Carsten Paeth"); @@ -291,7 +292,7 @@ static int notify_push(unsigned int event_type, u32 controller) event->type = event_type; event->controller = controller; - schedule_work(&event->work); + queue_work(kcapi_wq, &event->work); return 0; } @@ -408,7 +409,7 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl, goto error; } skb_queue_tail(&ap->recv_queue, skb); - schedule_work(&ap->recv_work); + queue_work(kcapi_wq, &ap->recv_work); rcu_read_unlock(); return; @@ -743,7 +744,7 @@ u16 capi20_release(struct capi20_appl *ap) mutex_unlock(&capi_controller_lock); - flush_scheduled_work(); + flush_workqueue(kcapi_wq); skb_queue_purge(&ap->recv_queue); if (showcapimsgs & 1) { @@ -1285,21 +1286,30 @@ static int __init kcapi_init(void) { int err; + kcapi_wq = alloc_workqueue("kcapi", 0, 0); + if (!kcapi_wq) + return -ENOMEM; + register_capictr_notifier(&capictr_nb); err = cdebug_init(); - if (!err) - kcapi_proc_init(); - return err; + if (err) { + unregister_capictr_notifier(&capictr_nb); + destroy_workqueue(kcapi_wq); + return err; + } + + kcapi_proc_init(); + return 0; } static void __exit kcapi_exit(void) { kcapi_proc_exit(); - /* make sure all notifiers are finished */ - flush_scheduled_work(); + unregister_capictr_notifier(&capictr_nb); cdebug_exit(); + destroy_workqueue(kcapi_wq); } module_init(kcapi_init); -- cgit v1.2.3 From 0d26aa704e5bbca5a1ee9fdf0d02277ceb507eee Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 24 Dec 2010 15:59:07 +0100 Subject: mISDN: don't use flush_scheduled_work() flush_scheduled_work() is deprecated and scheduled to be removed. Directly flush ch->workq when freeing channel and cancel it on release. Signed-off-by: Tejun Heo Cc: Karsten Keil Cc: netdev@vger.kernel.org --- drivers/isdn/mISDN/hwchannel.c | 4 ++-- drivers/isdn/mISDN/l1oip_core.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/isdn') diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c index 307bd6e8988b..199f374cf9da 100644 --- a/drivers/isdn/mISDN/hwchannel.c +++ b/drivers/isdn/mISDN/hwchannel.c @@ -110,7 +110,7 @@ mISDN_freedchannel(struct dchannel *ch) } skb_queue_purge(&ch->squeue); skb_queue_purge(&ch->rqueue); - flush_scheduled_work(); + flush_work_sync(&ch->workq); return 0; } EXPORT_SYMBOL(mISDN_freedchannel); @@ -143,7 +143,7 @@ mISDN_freebchannel(struct bchannel *ch) mISDN_clear_bchannel(ch); skb_queue_purge(&ch->rqueue); ch->rcount = 0; - flush_scheduled_work(); + flush_work_sync(&ch->workq); return 0; } EXPORT_SYMBOL(mISDN_freebchannel); diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c index 5b59796ed250..bd526f664a39 100644 --- a/drivers/isdn/mISDN/l1oip_core.c +++ b/drivers/isdn/mISDN/l1oip_core.c @@ -1269,6 +1269,8 @@ release_card(struct l1oip *hc) if (timer_pending(&hc->timeout_tl)) del_timer(&hc->timeout_tl); + cancel_work_sync(&hc->workq); + if (hc->socket_thread) l1oip_socket_close(hc); -- cgit v1.2.3