Commit 56424fa8 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: CAPI: Move the notification callback

The callback to be notified of added/removed controllers is
logically per application.

This will be replaced by the standardized mechanism anyway, so the
temporary capi20_set_callback will fortunately vanish later.
parent c5933354
......@@ -2293,7 +2293,6 @@ static void __exit proc_exit(void)
static struct capi_interface_user cuser = {
name: "capidrv",
callback: lower_callback
};
static int __init capidrv_init(void)
......@@ -2327,6 +2326,8 @@ static int __init capidrv_init(void)
return -EIO;
}
capi20_set_callback(global.appid, lower_callback);
errcode = capi20_get_profile(0, &profile);
if (errcode != CAPI_NOERROR) {
capi20_release(global.appid);
......
......@@ -68,6 +68,11 @@ struct capi_appl {
unsigned long nrecvdatapkt;
unsigned long nsentctlpkt;
unsigned long nsentdatapkt;
/* ugly hack to allow for notification of added/removed
* controllers. The Right Way (tm) is known. XXX
*/
void (*callback) (unsigned int cmd, __u32 contr, void *data);
};
struct capi_notifier {
......@@ -548,35 +553,33 @@ static int notify_push(unsigned int cmd, u32 controller,
static void notify_up(u32 contr)
{
struct list_head *l;
struct capi_interface_user *p;
struct capi_ctr *card = get_capi_ctr_by_nr(contr);
struct capi_appl *ap;
u16 applid;
printk(KERN_NOTICE "kcapi: notify up contr %d\n", contr);
spin_lock(&users_lock);
list_for_each(l, &users) {
p = list_entry(l, struct capi_interface_user, user_list);
if (!p->callback) continue;
(*p->callback) (KCI_CONTRUP, contr, &card->profile);
printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr);
for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
ap = get_capi_appl_by_nr(applid);
if (ap && ap->callback)
ap->callback(KCI_CONTRUP, contr, &card->profile);
}
spin_unlock(&users_lock);
}
/* -------- KCI_CONTRDOWN ------------------------------------- */
static void notify_down(u32 contr)
{
struct list_head *l;
struct capi_interface_user *p;
struct capi_appl *ap;
u16 applid;
printk(KERN_NOTICE "kcapi: notify down contr %d\n", contr);
spin_lock(&users_lock);
list_for_each(l, &users) {
p = list_entry(l, struct capi_interface_user, user_list);
if (!p->callback) continue;
(*p->callback) (KCI_CONTRDOWN, contr, 0);
printk(KERN_DEBUG "kcapi: notify down contr %d\n", contr);
for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
ap = get_capi_appl_by_nr(applid);
if (ap && ap->callback)
ap->callback(KCI_CONTRDOWN, contr, 0);
}
spin_unlock(&users_lock);
}
/* ------------------------------------------------------------ */
......@@ -1318,6 +1321,16 @@ int capi20_manufacturer(unsigned int cmd, void *data)
EXPORT_SYMBOL(capi20_manufacturer);
/* temporary hack */
void capi20_set_callback(u16 applid, void (*callback) (unsigned int cmd, __u32 contr, void *data))
{
struct capi_appl *ap = get_capi_appl_by_nr(applid);
ap->callback = callback;
}
EXPORT_SYMBOL(capi20_set_callback);
/* ------------------------------------------------------------- */
/* -------- Exported Functions --------------------------------- */
/* ------------------------------------------------------------- */
......
......@@ -54,7 +54,6 @@ typedef struct kcapi_carddef {
struct capi_interface_user {
char name[20];
void (*callback) (unsigned int cmd, __u32 contr, void *data);
/* internal */
struct list_head user_list;
};
......@@ -76,6 +75,11 @@ u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]);
u16 capi20_get_profile(u32 contr, struct capi_profile *profp);
int capi20_manufacturer(unsigned int cmd, void *data);
/* temporary hack XXX */
void capi20_set_callback(u16 applid, void (*callback) (unsigned int cmd, __u32 contr, void *data));
#define CAPI_NOERROR 0x0000
#define CAPI_TOOMANYAPPLS 0x1001
......
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