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) ...@@ -2293,7 +2293,6 @@ static void __exit proc_exit(void)
static struct capi_interface_user cuser = { static struct capi_interface_user cuser = {
name: "capidrv", name: "capidrv",
callback: lower_callback
}; };
static int __init capidrv_init(void) static int __init capidrv_init(void)
...@@ -2327,6 +2326,8 @@ static int __init capidrv_init(void) ...@@ -2327,6 +2326,8 @@ static int __init capidrv_init(void)
return -EIO; return -EIO;
} }
capi20_set_callback(global.appid, lower_callback);
errcode = capi20_get_profile(0, &profile); errcode = capi20_get_profile(0, &profile);
if (errcode != CAPI_NOERROR) { if (errcode != CAPI_NOERROR) {
capi20_release(global.appid); capi20_release(global.appid);
......
...@@ -68,6 +68,11 @@ struct capi_appl { ...@@ -68,6 +68,11 @@ struct capi_appl {
unsigned long nrecvdatapkt; unsigned long nrecvdatapkt;
unsigned long nsentctlpkt; unsigned long nsentctlpkt;
unsigned long nsentdatapkt; 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 { struct capi_notifier {
...@@ -548,35 +553,33 @@ static int notify_push(unsigned int cmd, u32 controller, ...@@ -548,35 +553,33 @@ static int notify_push(unsigned int cmd, u32 controller,
static void notify_up(u32 contr) 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_ctr *card = get_capi_ctr_by_nr(contr);
struct capi_appl *ap;
u16 applid;
printk(KERN_NOTICE "kcapi: notify up contr %d\n", contr); printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr);
spin_lock(&users_lock);
list_for_each(l, &users) { for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
p = list_entry(l, struct capi_interface_user, user_list); ap = get_capi_appl_by_nr(applid);
if (!p->callback) continue; if (ap && ap->callback)
(*p->callback) (KCI_CONTRUP, contr, &card->profile); ap->callback(KCI_CONTRUP, contr, &card->profile);
} }
spin_unlock(&users_lock);
} }
/* -------- KCI_CONTRDOWN ------------------------------------- */ /* -------- KCI_CONTRDOWN ------------------------------------- */
static void notify_down(u32 contr) static void notify_down(u32 contr)
{ {
struct list_head *l; struct capi_appl *ap;
struct capi_interface_user *p; u16 applid;
printk(KERN_NOTICE "kcapi: notify down contr %d\n", contr); printk(KERN_DEBUG "kcapi: notify down contr %d\n", contr);
spin_lock(&users_lock);
list_for_each(l, &users) { for (applid = 1; applid <= CAPI_MAXAPPL; applid++) {
p = list_entry(l, struct capi_interface_user, user_list); ap = get_capi_appl_by_nr(applid);
if (!p->callback) continue; if (ap && ap->callback)
(*p->callback) (KCI_CONTRDOWN, contr, 0); ap->callback(KCI_CONTRDOWN, contr, 0);
} }
spin_unlock(&users_lock);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
...@@ -1318,6 +1321,16 @@ int capi20_manufacturer(unsigned int cmd, void *data) ...@@ -1318,6 +1321,16 @@ int capi20_manufacturer(unsigned int cmd, void *data)
EXPORT_SYMBOL(capi20_manufacturer); 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 --------------------------------- */ /* -------- Exported Functions --------------------------------- */
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
......
...@@ -54,7 +54,6 @@ typedef struct kcapi_carddef { ...@@ -54,7 +54,6 @@ typedef struct kcapi_carddef {
struct capi_interface_user { struct capi_interface_user {
char name[20]; char name[20];
void (*callback) (unsigned int cmd, __u32 contr, void *data);
/* internal */ /* internal */
struct list_head user_list; struct list_head user_list;
}; };
...@@ -76,6 +75,11 @@ u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]); ...@@ -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); u16 capi20_get_profile(u32 contr, struct capi_profile *profp);
int capi20_manufacturer(unsigned int cmd, void *data); 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_NOERROR 0x0000
#define CAPI_TOOMANYAPPLS 0x1001 #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