aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2010-02-08 05:12:17 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-16 19:01:23 -0500
commitb8f433dc5cd9b910c12ef5cca351bf720d3e68c1 (patch)
tree1126f4361f0776d1f96662d4abba6cfea0750d95
parent501c87a91909efaad91425635b29b01f1473c659 (diff)
CAPI: Convert capidev_list_lock into a mutex
No need for anything "harder" here (specifically no need for irqsave...). Also, make the list removal the first operation of capidev_free to avoid dumping half-released devices via /proc. Signed-off-by: Jan Kiszka <jan.kiszka@web.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/isdn/capi/capi.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 7d2ca6b2564c..623412e22c14 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -146,7 +146,7 @@ struct capidev {
146 146
147/* -------- global variables ---------------------------------------- */ 147/* -------- global variables ---------------------------------------- */
148 148
149static DEFINE_RWLOCK(capidev_list_lock); 149static DEFINE_MUTEX(capidev_list_lock);
150static LIST_HEAD(capidev_list); 150static LIST_HEAD(capidev_list);
151 151
152#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 152#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@ -406,7 +406,6 @@ static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)
406static struct capidev *capidev_alloc(void) 406static struct capidev *capidev_alloc(void)
407{ 407{
408 struct capidev *cdev; 408 struct capidev *cdev;
409 unsigned long flags;
410 409
411 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); 410 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
412 if (!cdev) 411 if (!cdev)
@@ -415,15 +414,19 @@ static struct capidev *capidev_alloc(void)
415 mutex_init(&cdev->ncci_list_mtx); 414 mutex_init(&cdev->ncci_list_mtx);
416 skb_queue_head_init(&cdev->recvqueue); 415 skb_queue_head_init(&cdev->recvqueue);
417 init_waitqueue_head(&cdev->recvwait); 416 init_waitqueue_head(&cdev->recvwait);
418 write_lock_irqsave(&capidev_list_lock, flags); 417
418 mutex_lock(&capidev_list_lock);
419 list_add_tail(&cdev->list, &capidev_list); 419 list_add_tail(&cdev->list, &capidev_list);
420 write_unlock_irqrestore(&capidev_list_lock, flags); 420 mutex_unlock(&capidev_list_lock);
421
421 return cdev; 422 return cdev;
422} 423}
423 424
424static void capidev_free(struct capidev *cdev) 425static void capidev_free(struct capidev *cdev)
425{ 426{
426 unsigned long flags; 427 mutex_lock(&capidev_list_lock);
428 list_del(&cdev->list);
429 mutex_unlock(&capidev_list_lock);
427 430
428 if (cdev->ap.applid) { 431 if (cdev->ap.applid) {
429 capi20_release(&cdev->ap); 432 capi20_release(&cdev->ap);
@@ -435,9 +438,6 @@ static void capidev_free(struct capidev *cdev)
435 capincci_free(cdev, 0xffffffff); 438 capincci_free(cdev, 0xffffffff);
436 mutex_unlock(&cdev->ncci_list_mtx); 439 mutex_unlock(&cdev->ncci_list_mtx);
437 440
438 write_lock_irqsave(&capidev_list_lock, flags);
439 list_del(&cdev->list);
440 write_unlock_irqrestore(&capidev_list_lock, flags);
441 kfree(cdev); 441 kfree(cdev);
442} 442}
443 443
@@ -1431,7 +1431,7 @@ static int capi20_proc_show(struct seq_file *m, void *v)
1431 struct capidev *cdev; 1431 struct capidev *cdev;
1432 struct list_head *l; 1432 struct list_head *l;
1433 1433
1434 read_lock(&capidev_list_lock); 1434 mutex_lock(&capidev_list_lock);
1435 list_for_each(l, &capidev_list) { 1435 list_for_each(l, &capidev_list) {
1436 cdev = list_entry(l, struct capidev, list); 1436 cdev = list_entry(l, struct capidev, list);
1437 seq_printf(m, "0 %d %lu %lu %lu %lu\n", 1437 seq_printf(m, "0 %d %lu %lu %lu %lu\n",
@@ -1441,7 +1441,7 @@ static int capi20_proc_show(struct seq_file *m, void *v)
1441 cdev->ap.nsentctlpkt, 1441 cdev->ap.nsentctlpkt,
1442 cdev->ap.nsentdatapkt); 1442 cdev->ap.nsentdatapkt);
1443 } 1443 }
1444 read_unlock(&capidev_list_lock); 1444 mutex_unlock(&capidev_list_lock);
1445 return 0; 1445 return 0;
1446} 1446}
1447 1447
@@ -1468,7 +1468,7 @@ static int capi20ncci_proc_show(struct seq_file *m, void *v)
1468 struct capincci *np; 1468 struct capincci *np;
1469 struct list_head *l; 1469 struct list_head *l;
1470 1470
1471 read_lock(&capidev_list_lock); 1471 mutex_lock(&capidev_list_lock);
1472 list_for_each(l, &capidev_list) { 1472 list_for_each(l, &capidev_list) {
1473 cdev = list_entry(l, struct capidev, list); 1473 cdev = list_entry(l, struct capidev, list);
1474 for (np=cdev->nccis; np; np = np->next) { 1474 for (np=cdev->nccis; np; np = np->next) {
@@ -1477,7 +1477,7 @@ static int capi20ncci_proc_show(struct seq_file *m, void *v)
1477 np->ncci); 1477 np->ncci);
1478 } 1478 }
1479 } 1479 }
1480 read_unlock(&capidev_list_lock); 1480 mutex_unlock(&capidev_list_lock);
1481 return 0; 1481 return 0;
1482} 1482}
1483 1483