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,20 +154,21 @@ static char *b1isa_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1isa_driver = {
name: "b1isa",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1isa_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1isa_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: b1isa_add_card,
owner: THIS_MODULE,
name: "b1isa",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1isa_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1isa_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: b1isa_add_card,
};
static int __init b1isa_init(void)
......
......@@ -165,20 +165,21 @@ static void b1pci_remove_ctr(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1pci_driver = {
name: "b1pci",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1pci_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1pci_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
owner: THIS_MODULE,
name: "b1pci",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1pci_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1pci_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
#ifdef CONFIG_ISDN_DRV_AVMB1_B1PCIV4
......@@ -327,20 +328,21 @@ static void b1pciv4_remove_ctr(struct capi_ctr *ctrl)
static struct capi_driver b1pciv4_driver = {
name: "b1pciv4",
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
remove_ctr: b1pciv4_remove_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
procinfo: b1pciv4_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
owner: THIS_MODULE,
name: "b1pciv4",
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
remove_ctr: b1pciv4_remove_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
procinfo: b1pciv4_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
#endif /* CONFIG_ISDN_DRV_AVMB1_B1PCIV4 */
......
......@@ -152,20 +152,21 @@ static char *b1pcmcia_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver b1pcmcia_driver = {
name: "b1pcmcia",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1pcmcia_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1pcmcia_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0,
owner: THIS_MODULE,
name: "b1pcmcia",
revision: "0.0",
load_firmware: b1_load_firmware,
reset_ctr: b1_reset_ctr,
remove_ctr: b1pcmcia_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: b1_send_message,
procinfo: b1pcmcia_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0,
};
/* ------------------------------------------------------------- */
......
......@@ -1200,37 +1200,39 @@ static int c4_add_card(struct capi_driver *driver,
/* ------------------------------------------------------------- */
static struct capi_driver c2_driver = {
name: "c2",
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
remove_ctr: c4_remove_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
owner: THIS_MODULE,
name: "c2",
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
remove_ctr: c4_remove_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
static struct capi_driver c4_driver = {
name: "c4",
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
remove_ctr: c4_remove_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
owner: THIS_MODULE,
name: "c4",
revision: "0.0",
load_firmware: c4_load_firmware,
reset_ctr: c4_reset_ctr,
remove_ctr: c4_remove_ctr,
register_appl: c4_register_appl,
release_appl: c4_release_appl,
send_message: c4_send_message,
procinfo: c4_procinfo,
ctr_read_proc: c4_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
static int c4_attach_driver (struct capi_driver * driver)
......
......@@ -479,20 +479,21 @@ static char *t1isa_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver t1isa_driver = {
name: "t1isa",
revision: "0.0",
load_firmware: t1isa_load_firmware,
reset_ctr: t1isa_reset_ctr,
remove_ctr: t1isa_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: t1isa_send_message,
procinfo: t1isa_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: t1isa_add_card,
owner: THIS_MODULE,
name: "t1isa",
revision: "0.0",
load_firmware: t1isa_load_firmware,
reset_ctr: t1isa_reset_ctr,
remove_ctr: t1isa_remove_ctr,
register_appl: b1_register_appl,
release_appl: b1_release_appl,
send_message: t1isa_send_message,
procinfo: t1isa_procinfo,
ctr_read_proc: b1ctl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: t1isa_add_card,
};
static int __init t1isa_init(void)
......
......@@ -189,20 +189,21 @@ static char *t1pci_procinfo(struct capi_ctr *ctrl)
/* ------------------------------------------------------------- */
static struct capi_driver t1pci_driver = {
name: "t1pci",
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
remove_ctr: t1pci_remove_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
procinfo: t1pci_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
owner: THIS_MODULE,
name: "t1pci",
revision: "0.0",
load_firmware: b1dma_load_firmware,
reset_ctr: b1dma_reset_ctr,
remove_ctr: t1pci_remove_ctr,
register_appl: b1dma_register_appl,
release_appl: b1dma_release_appl,
send_message: b1dma_send_message,
procinfo: t1pci_procinfo,
ctr_read_proc: b1dmactl_read_proc,
driver_read_proc: 0, /* use standard driver_read_proc */
add_card: 0, /* no add_card function */
};
/* ------------------------------------------------------------- */
......
......@@ -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,30 +79,31 @@ struct capi_driver_interface {
};
struct capi_driver {
char name[32]; /* driver name */
char revision[32];
int (*load_firmware)(struct capi_ctr *, capiloaddata *);
void (*reset_ctr)(struct capi_ctr *);
void (*remove_ctr)(struct capi_ctr *);
void (*register_appl)(struct capi_ctr *, __u16 appl,
capi_register_params *);
void (*release_appl)(struct capi_ctr *, __u16 appl);
void (*send_message)(struct capi_ctr *, struct sk_buff *skb);
char *(*procinfo)(struct capi_ctr *);
int (*ctr_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_ctr *card);
int (*driver_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_driver *driver);
int (*add_card)(struct capi_driver *driver, capicardparams *data);
/* intitialized by kcapi */
struct capi_ctr *controller; /* list of controllers */
struct capi_driver *next;
int ncontroller;
struct proc_dir_entry *procent;
char procfn[128];
struct module *owner;
char name[32]; /* driver name */
char revision[32];
int (*load_firmware)(struct capi_ctr *, capiloaddata *);
void (*reset_ctr)(struct capi_ctr *);
void (*remove_ctr)(struct capi_ctr *);
void (*register_appl)(struct capi_ctr *, __u16 appl,
capi_register_params *);
void (*release_appl)(struct capi_ctr *, __u16 appl);
void (*send_message)(struct capi_ctr *, struct sk_buff *skb);
char *(*procinfo)(struct capi_ctr *);
int (*ctr_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_ctr *card);
int (*driver_read_proc)(char *page, char **start, off_t off,
int count, int *eof, struct capi_driver *driver);
int (*add_card)(struct capi_driver *driver, capicardparams *data);
/* intitialized by kcapi */
struct capi_ctr *controller; /* list of controllers */
struct capi_driver *next;
int ncontroller;
struct proc_dir_entry *procent;
char procfn[128];
};
struct capi_driver_interface *attach_capi_driver(struct capi_driver *driver);
......
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