X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fisdn%2Fcapi%2Fkcapi.c;h=feec40cf59001e1be2de03c741b101b2b3e2aa45;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=8d58cfd45b0e4813063bbc636e58d5a7c50784eb;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 8d58cfd45..feec40cf5 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -40,7 +42,7 @@ static int showcapimsgs = 0; MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer"); MODULE_AUTHOR("Carsten Paeth"); MODULE_LICENSE("GPL"); -MODULE_PARM(showcapimsgs, "i"); +module_param(showcapimsgs, uint, 0); /* ------------------------------------------------------------- */ @@ -61,9 +63,9 @@ static char capi_manufakturer[64] = "AVM Berlin"; #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) LIST_HEAD(capi_drivers); -rwlock_t capi_drivers_list_lock = RW_LOCK_UNLOCKED; +DEFINE_RWLOCK(capi_drivers_list_lock); -static rwlock_t application_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(application_lock); static DECLARE_MUTEX(controller_sem); struct capi20_appl *capi_applications[CAPI_MAXAPPL]; @@ -148,7 +150,10 @@ static void register_appl(struct capi_ctr *card, u16 applid, capi_register_param { card = capi_ctr_get(card); - card->register_appl(card, applid, rparam); + if (card) + card->register_appl(card, applid, rparam); + else + printk(KERN_WARNING "%s: cannot get card resources\n", __FUNCTION__); } @@ -171,10 +176,15 @@ static void notify_up(u32 contr) if (showcapimsgs & 1) { printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr); } - + if (!card) { + printk(KERN_WARNING "%s: invalid contr %d\n", __FUNCTION__, contr); + return; + } for (applid = 1; applid <= CAPI_MAXAPPL; applid++) { ap = get_capi_appl_by_nr(applid); - if (ap && ap->callback && !ap->release_in_progress) + if (!ap || ap->release_in_progress) continue; + register_appl(card, applid, &ap->rparam); + if (ap->callback && !ap->release_in_progress) ap->callback(KCI_CONTRUP, contr, &card->profile); } } @@ -317,19 +327,8 @@ EXPORT_SYMBOL(capi_ctr_handle_message); void capi_ctr_ready(struct capi_ctr * card) { - u16 appl; - struct capi20_appl *ap; - card->cardstate = CARD_RUNNING; - down(&controller_sem); - for (appl = 1; appl <= CAPI_MAXAPPL; appl++) { - ap = get_capi_appl_by_nr(appl); - if (!ap || ap->release_in_progress) continue; - register_appl(card, appl, &ap->rparam); - } - up(&controller_sem); - printk(KERN_NOTICE "kcapi: card %d \"%s\" ready.\n", card->cnr, card->name); @@ -831,8 +830,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) while (card->cardstate != CARD_RUNNING) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ/10); /* 0.1 sec */ + msleep_interruptible(100); /* 0.1 sec */ if (signal_pending(current)) { capi_ctr_put(card); @@ -856,8 +854,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) while (card->cardstate > CARD_DETECTED) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ/10); /* 0.1 sec */ + msleep_interruptible(100); /* 0.1 sec */ if (signal_pending(current)) return -EINTR;