Commit d25500eb authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: CAPI maintain driver MOD_USE_COUNT

Apart from the indentation changes, add an owner field to the hardware
driver struct and use that to automatically inc/dec the module use count
on register_appl()/release_appl()
parent 83bc4e5e
......@@ -122,6 +122,27 @@ static spinlock_t drivers_lock = SPIN_LOCK_UNLOCKED;
static struct tq_struct tq_state_notify;
static struct tq_struct tq_recv_notify;
/* -------- ref counting -------------------------------------- */
static inline struct capi_ctr *
capi_ctr_get(struct capi_ctr *card)
{
if (card->driver->owner) {
if (try_inc_mod_count(card->driver->owner))
return card;
else
return NULL;
}
return card;
}
static inline void
capi_ctr_put(struct capi_ctr *card)
{
if (card->driver->owner)
__MOD_DEC_USE_COUNT(card->driver->owner);
}
/* -------- util functions ------------------------------------ */
static char *cardstate2str(unsigned short cardstate)
......@@ -473,6 +494,8 @@ static void proc_capi_exit(void)
static void register_appl(struct capi_ctr *card, u16 applid, capi_register_params *rparam)
{
card = capi_ctr_get(card);
card->driver->register_appl(card, applid, rparam);
}
......@@ -495,6 +518,8 @@ static void release_appl(struct capi_ctr *card, u16 applid)
}
card->driver->release_appl(card, applid);
capi_ctr_put(card);
}
......@@ -909,6 +934,7 @@ static void controllercb_reseted(struct capi_ctr * card)
nextpp = &(*pp)->next;
}
}
capi_ctr_put(card);
}
printk(KERN_NOTICE "kcapi: card %d down.\n", CARDNR(card));
......
......@@ -154,6 +154,7 @@ static char *b1isa_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1isa_driver = {
owner: THIS_MODULE,
name: "b1isa",
revision: "0.0",
load_firmware: b1_load_firmware,
......
......@@ -165,6 +165,7 @@ static void b1pci_remove_ctr(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1pci_driver = {
owner: THIS_MODULE,
name: "b1pci",
revision: "0.0",
load_firmware: b1_load_firmware,
......@@ -327,6 +328,7 @@ static void b1pciv4_remove_ctr(struct capi_ctr *ctrl)
static struct capi_driver b1pciv4_driver = {
owner: THIS_MODULE,
name: "b1pciv4",
revision: "0.0",
load_firmware: b1dma_load_firmware,
......
......@@ -152,6 +152,7 @@ static char *b1pcmcia_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1pcmcia_driver = {
owner: THIS_MODULE,
name: "b1pcmcia",
revision: "0.0",
load_firmware: b1_load_firmware,
......
......@@ -1200,6 +1200,7 @@ static int c4_add_card(struct capi_driver *driver,
/* ------------------------------------------------------------- */
static struct capi_driver c2_driver = {
owner: THIS_MODULE,
name: "c2",
revision: "0.0",
load_firmware: c4_load_firmware,
......@@ -1217,6 +1218,7 @@ static struct capi_driver c2_driver = {
};
static struct capi_driver c4_driver = {
owner: THIS_MODULE,
name: "c4",
revision: "0.0",
load_firmware: c4_load_firmware,
......
......@@ -479,6 +479,7 @@ static char *t1isa_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver t1isa_driver = {
owner: THIS_MODULE,
name: "t1isa",
revision: "0.0",
load_firmware: t1isa_load_firmware,
......
......@@ -189,6 +189,7 @@ static char *t1pci_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver t1pci_driver = {
owner: THIS_MODULE,
name: "t1pci",
revision: "0.0",
load_firmware: b1dma_load_firmware,
......
......@@ -252,7 +252,6 @@ hycapi_register_appl(struct capi_ctr *ctrl, __u16 appl,
rp, sizeof(capi_register_params));
/* MOD_INC_USE_COUNT; */
ctrl->appl_registered(ctrl, appl);
}
/*********************************************************************
......@@ -313,7 +312,6 @@ hycapi_release_appl(struct capi_ctr *ctrl, __u16 appl)
{
hycapi_release_internal(ctrl, appl);
}
ctrl->appl_released(ctrl, appl);
/* MOD_DEC_USE_COUNT; */
}
......@@ -666,18 +664,21 @@ hycapi_tx_capiget(hysdn_card *card)
static struct capi_driver hycapi_driver = {
"hysdn",
"0.0",
hycapi_load_firmware,
hycapi_reset_ctr,
hycapi_remove_ctr,
hycapi_register_appl,
hycapi_release_appl,
hycapi_send_message,
hycapi_procinfo,
hycapi_read_proc,
0, /* use standard driver_read_proc */
0, /* no add_card function */
owner: THIS_MODULE,
name: "hysdn",
revision: "0.0",
load_firmware: hycapi_load_firmware,
reset_ctr: hycapi_reset_ctr,
remove_ctr: hycapi_remove_ctr,
register_appl: hycapi_register_appl,
release_appl: hycapi_release_appl,
send_message: hycapi_send_message,
procinfo: hycapi_procinfo,
ctr_read_proc: hycapi_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
......
......@@ -79,6 +79,7 @@ struct capi_driver_interface {
};
struct capi_driver {
struct module *owner;
char name[32]; /* driver name */
char revision[32];
int (*load_firmware)(struct capi_ctr *, capiloaddata *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment