Commit 884f5c44 authored by Jan Kiszka's avatar Jan Kiszka Committed by David S. Miller

CAPI: Switch NCCI list to standard doubly linked list

Replace open-coded NCCI list management with standard mechanisms.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 28a1dbb6
...@@ -122,7 +122,7 @@ struct capiminor { ...@@ -122,7 +122,7 @@ struct capiminor {
static DEFINE_SPINLOCK(workaround_lock); static DEFINE_SPINLOCK(workaround_lock);
struct capincci { struct capincci {
struct capincci *next; struct list_head list;
u32 ncci; u32 ncci;
struct capidev *cdev; struct capidev *cdev;
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
...@@ -139,7 +139,7 @@ struct capidev { ...@@ -139,7 +139,7 @@ struct capidev {
struct sk_buff_head recvqueue; struct sk_buff_head recvqueue;
wait_queue_head_t recvwait; wait_queue_head_t recvwait;
struct capincci *nccis; struct list_head nccis;
struct mutex lock; struct mutex lock;
}; };
...@@ -356,7 +356,7 @@ static inline unsigned int capincci_minor_opencount(struct capincci *np) ...@@ -356,7 +356,7 @@ static inline unsigned int capincci_minor_opencount(struct capincci *np)
static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
{ {
struct capincci *np, **pp; struct capincci *np;
np = kzalloc(sizeof(*np), GFP_KERNEL); np = kzalloc(sizeof(*np), GFP_KERNEL);
if (!np) if (!np)
...@@ -366,39 +366,31 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) ...@@ -366,39 +366,31 @@ static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci)
capincci_alloc_minor(cdev, np); capincci_alloc_minor(cdev, np);
for (pp=&cdev->nccis; *pp; pp = &(*pp)->next) list_add_tail(&np->list, &cdev->nccis);
;
*pp = np; return np;
return np;
} }
static void capincci_free(struct capidev *cdev, u32 ncci) static void capincci_free(struct capidev *cdev, u32 ncci)
{ {
struct capincci *np, **pp; struct capincci *np, *tmp;
pp=&cdev->nccis; list_for_each_entry_safe(np, tmp, &cdev->nccis, list)
while (*pp) {
np = *pp;
if (ncci == 0xffffffff || np->ncci == ncci) { if (ncci == 0xffffffff || np->ncci == ncci) {
*pp = (*pp)->next;
capincci_free_minor(np); capincci_free_minor(np);
list_del(&np->list);
kfree(np); kfree(np);
if (*pp == NULL) return;
} else {
pp = &(*pp)->next;
} }
}
} }
static struct capincci *capincci_find(struct capidev *cdev, u32 ncci) static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)
{ {
struct capincci *p; struct capincci *np;
for (p=cdev->nccis; p ; p = p->next) { list_for_each_entry(np, &cdev->nccis, list)
if (p->ncci == ncci) if (np->ncci == ncci)
break; return np;
} return NULL;
return p;
} }
#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
...@@ -955,6 +947,7 @@ static int capi_open(struct inode *inode, struct file *file) ...@@ -955,6 +947,7 @@ static int capi_open(struct inode *inode, struct file *file)
mutex_init(&cdev->lock); mutex_init(&cdev->lock);
skb_queue_head_init(&cdev->recvqueue); skb_queue_head_init(&cdev->recvqueue);
init_waitqueue_head(&cdev->recvwait); init_waitqueue_head(&cdev->recvwait);
INIT_LIST_HEAD(&cdev->nccis);
file->private_data = cdev; file->private_data = cdev;
mutex_lock(&capidev_list_lock); mutex_lock(&capidev_list_lock);
...@@ -1427,19 +1420,14 @@ static const struct file_operations capi20_proc_fops = { ...@@ -1427,19 +1420,14 @@ static const struct file_operations capi20_proc_fops = {
*/ */
static int capi20ncci_proc_show(struct seq_file *m, void *v) static int capi20ncci_proc_show(struct seq_file *m, void *v)
{ {
struct capidev *cdev; struct capidev *cdev;
struct capincci *np; struct capincci *np;
struct list_head *l;
mutex_lock(&capidev_list_lock); mutex_lock(&capidev_list_lock);
list_for_each(l, &capidev_list) { list_for_each_entry(cdev, &capidev_list, list) {
cdev = list_entry(l, struct capidev, list);
mutex_lock(&cdev->lock); mutex_lock(&cdev->lock);
for (np=cdev->nccis; np; np = np->next) { list_for_each_entry(np, &cdev->nccis, list)
seq_printf(m, "%d 0x%x\n", seq_printf(m, "%d 0x%x\n", cdev->ap.applid, np->ncci);
cdev->ap.applid,
np->ncci);
}
mutex_unlock(&cdev->lock); mutex_unlock(&cdev->lock);
} }
mutex_unlock(&capidev_list_lock); mutex_unlock(&capidev_list_lock);
......
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