diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 20:21:04 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-08 20:21:04 +0000 |
commit | 988addf82e4c03739375279de73929580a2d4a6a (patch) | |
tree | 989ae1cd4e264bbad80c65f04480486246e7b9f3 /drivers/isdn/capi/capidrv.c | |
parent | 004c1c7096659d352b83047a7593e91d8a30e3c5 (diff) | |
parent | 25cf84cf377c0aae5dbcf937ea89bc7893db5176 (diff) |
Merge branch 'origin' into devel-stable
Conflicts:
arch/arm/mach-mx2/devices.c
arch/arm/mach-mx2/devices.h
sound/soc/pxa/pxa-ssp.c
Diffstat (limited to 'drivers/isdn/capi/capidrv.c')
-rw-r--r-- | drivers/isdn/capi/capidrv.c | 103 |
1 files changed, 33 insertions, 70 deletions
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 66b7d7a8647..bf55ed5f38e 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c @@ -24,6 +24,7 @@ #include <linux/isdn.h> #include <linux/isdnif.h> #include <linux/proc_fs.h> +#include <linux/seq_file.h> #include <linux/capi.h> #include <linux/kernelcapi.h> #include <linux/ctype.h> @@ -34,7 +35,6 @@ #include <linux/isdn/capicmd.h> #include "capidrv.h" -static char *revision = "$Revision: 1.1.2.2 $"; static int debugmode = 0; MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux"); @@ -2210,96 +2210,73 @@ static int capidrv_delcontr(u16 contr) } -static void lower_callback(unsigned int cmd, u32 contr, void *data) +static int +lower_callback(struct notifier_block *nb, unsigned long val, void *v) { + capi_profile profile; + u32 contr = (long)v; - switch (cmd) { - case KCI_CONTRUP: + switch (val) { + case CAPICTR_UP: printk(KERN_INFO "capidrv: controller %hu up\n", contr); - (void) capidrv_addcontr(contr, (capi_profile *) data); + if (capi20_get_profile(contr, &profile) == CAPI_NOERROR) + (void) capidrv_addcontr(contr, &profile); break; - case KCI_CONTRDOWN: + case CAPICTR_DOWN: printk(KERN_INFO "capidrv: controller %hu down\n", contr); (void) capidrv_delcontr(contr); break; } + return NOTIFY_OK; } /* * /proc/capi/capidrv: * nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt */ -static int proc_capidrv_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int capidrv_proc_show(struct seq_file *m, void *v) { - int len = 0; - - len += sprintf(page+len, "%lu %lu %lu %lu\n", + seq_printf(m, "%lu %lu %lu %lu\n", global.ap.nrecvctlpkt, global.ap.nrecvdatapkt, global.ap.nsentctlpkt, global.ap.nsentdatapkt); - if (off+count >= len) - *eof = 1; - if (len < off) - return 0; - *start = page + off; - return ((count < len-off) ? count : len-off); + return 0; } -static struct procfsentries { - char *name; - mode_t mode; - int (*read_proc)(char *page, char **start, off_t off, - int count, int *eof, void *data); - struct proc_dir_entry *procent; -} procfsentries[] = { - /* { "capi", S_IFDIR, 0 }, */ - { "capi/capidrv", 0 , proc_capidrv_read_proc }, +static int capidrv_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, capidrv_proc_show, NULL); +} + +static const struct file_operations capidrv_proc_fops = { + .owner = THIS_MODULE, + .open = capidrv_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, }; static void __init proc_init(void) { - int nelem = ARRAY_SIZE(procfsentries); - int i; - - for (i=0; i < nelem; i++) { - struct procfsentries *p = procfsentries + i; - p->procent = create_proc_entry(p->name, p->mode, NULL); - if (p->procent) p->procent->read_proc = p->read_proc; - } + proc_create("capi/capidrv", 0, NULL, &capidrv_proc_fops); } static void __exit proc_exit(void) { - int nelem = ARRAY_SIZE(procfsentries); - int i; - - for (i=nelem-1; i >= 0; i--) { - struct procfsentries *p = procfsentries + i; - if (p->procent) { - remove_proc_entry(p->name, NULL); - p->procent = NULL; - } - } + remove_proc_entry("capi/capidrv", NULL); } +static struct notifier_block capictr_nb = { + .notifier_call = lower_callback, +}; + static int __init capidrv_init(void) { capi_profile profile; - char rev[32]; - char *p; u32 ncontr, contr; u16 errcode; - if ((p = strchr(revision, ':')) != NULL && p[1]) { - strncpy(rev, p + 2, sizeof(rev)); - rev[sizeof(rev)-1] = 0; - if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; - } else - strcpy(rev, "1.0"); - global.ap.rparam.level3cnt = -2; /* number of bchannels twice */ global.ap.rparam.datablkcnt = 16; global.ap.rparam.datablklen = 2048; @@ -2310,7 +2287,7 @@ static int __init capidrv_init(void) return -EIO; } - capi20_set_callback(&global.ap, lower_callback); + register_capictr_notifier(&capictr_nb); errcode = capi20_get_profile(0, &profile); if (errcode != CAPI_NOERROR) { @@ -2327,29 +2304,15 @@ static int __init capidrv_init(void) } proc_init(); - printk(KERN_NOTICE "capidrv: Rev %s: loaded\n", rev); return 0; } static void __exit capidrv_exit(void) { - char rev[32]; - char *p; - - if ((p = strchr(revision, ':')) != NULL) { - strncpy(rev, p + 1, sizeof(rev)); - rev[sizeof(rev)-1] = 0; - if ((p = strchr(rev, '$')) != NULL) - *p = 0; - } else { - strcpy(rev, " ??? "); - } - + unregister_capictr_notifier(&capictr_nb); capi20_release(&global.ap); proc_exit(); - - printk(KERN_NOTICE "capidrv: Rev%s: unloaded\n", rev); } module_init(capidrv_init); |