added locking for new-style drivers. This is not hotplug-safe currently,

but at least no worse than before
This commit is contained in:
Kai Germaschewski 2001-08-21 09:52:52 +00:00
parent 89a11781cb
commit e80660afb5
5 changed files with 38 additions and 20 deletions

View File

@ -24,8 +24,8 @@ const char *lli_revision = "$Revision$";
extern struct IsdnCard cards[];
extern int nrcards;
extern void HiSax_mod_dec_use_count(void);
extern void HiSax_mod_inc_use_count(void);
extern void HiSax_mod_dec_use_count(struct IsdnCardState *cs);
extern void HiSax_mod_inc_use_count(struct IsdnCardState *cs);
static int init_b_st(struct Channel *chanp, int incoming);
static void release_b_st(struct Channel *chanp);
@ -1584,7 +1584,7 @@ HiSax_command(isdn_ctrl * ic)
}
break;
case (ISDN_CMD_LOCK):
HiSax_mod_inc_use_count();
HiSax_mod_inc_use_count(csta);
#ifdef MODULE
if (csta->channel[0].debug & 0x400)
HiSax_putstatus(csta, " LOCK ", "modcnt %lx",
@ -1592,7 +1592,7 @@ HiSax_command(isdn_ctrl * ic)
#endif /* MODULE */
break;
case (ISDN_CMD_UNLOCK):
HiSax_mod_dec_use_count();
HiSax_mod_dec_use_count(csta);
#ifdef MODULE
if (csta->channel[0].debug & 0x400)
HiSax_putstatus(csta, " UNLOCK ", "modcnt %lx",
@ -1624,11 +1624,11 @@ HiSax_command(isdn_ctrl * ic)
break;
case (3):
for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
HiSax_mod_dec_use_count();
HiSax_mod_dec_use_count(NULL);
break;
case (4):
for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
HiSax_mod_inc_use_count();
HiSax_mod_inc_use_count(NULL);
break;
case (5): /* set card in leased mode */
num = *(unsigned int *) ic->parm.num;
@ -1698,7 +1698,7 @@ HiSax_command(isdn_ctrl * ic)
#ifdef MODULE
case (55):
MOD_USE_COUNT = 0;
HiSax_mod_inc_use_count();
HiSax_mod_inc_use_count(NULL);
break;
#endif /* MODULE */
case (11):

View File

@ -437,16 +437,6 @@ void __init HiSaxVersion(void)
certification_check(1);
}
void HiSax_mod_dec_use_count(void)
{
MOD_DEC_USE_COUNT;
}
void HiSax_mod_inc_use_count(void)
{
MOD_INC_USE_COUNT;
}
#ifndef MODULE
#define MAX_ARG (HISAX_MAX_CARDS*5)
static int __init HiSax_setup(char *line)
@ -2110,6 +2100,33 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
}
}
void HiSax_mod_dec_use_count(struct IsdnCardState *cs)
{
struct module *mod;
if (cs && cs->cardmsg == hisax_cardmsg) {
mod = cs->hw.hisax_d_if->owner;
if (mod)
__MOD_DEC_USE_COUNT(mod);
} else {
MOD_DEC_USE_COUNT;
}
}
void HiSax_mod_inc_use_count(struct IsdnCardState *cs)
{
struct module *mod;
if (cs && cs->cardmsg == hisax_cardmsg) {
mod = cs->hw.hisax_d_if->owner;
if (mod)
// hope we do win the race...
try_inc_mod_count(mod);
} else {
MOD_INC_USE_COUNT;
}
}
#include <linux/pci.h>
static struct pci_device_id hisax_pci_tbl[] __initdata = {

View File

@ -847,6 +847,7 @@ new_adapter(struct pci_dev *pdev)
adapter->pci_dev = pdev;
SET_MODULE_OWNER(&adapter->isac.hisax_d_if);
adapter->isac.hisax_d_if.ifc.priv = &adapter->isac;
adapter->isac.hisax_d_if.ifc.l2l1 = isac_d_l2l1;

View File

@ -40,6 +40,7 @@ struct hisax_d_if {
struct hisax_if ifc;
// private to hisax
struct module *owner;
struct IsdnCardState *cs;
struct hisax_b_if *b_if[2];
struct sk_buff_head erq;

View File

@ -65,7 +65,6 @@ static void * __devinit probe_st5481(struct usb_device *dev,
struct hisax_b_if *b_if[2];
int retval, i;
MOD_INC_USE_COUNT;
printk(KERN_INFO "st541: found adapter VendorId %04x, ProductId %04x, LEDs %d\n",
dev->descriptor.idVendor, dev->descriptor.idProduct,
number_of_leds);
@ -78,6 +77,8 @@ static void * __devinit probe_st5481(struct usb_device *dev,
adapter->number_of_leds = number_of_leds;
adapter->usb_dev = dev;
SET_MODULE_OWNER(&adapter->hisax_d_if);
adapter->hisax_d_if.ifc.priv = adapter;
adapter->hisax_d_if.ifc.l2l1 = st5481_d_l2l1;
@ -120,7 +121,6 @@ static void * __devinit probe_st5481(struct usb_device *dev,
err_usb:
st5481_release_usb(adapter);
err:
MOD_DEC_USE_COUNT;
return NULL;
}
@ -147,7 +147,6 @@ static void __devexit disconnect_st5481(struct usb_device *dev, void *arg)
hisax_unregister(&adapter->hisax_d_if);
kfree(adapter);
MOD_DEC_USE_COUNT;
}
/*