lkml.org 
[lkml]   [2010]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 13/31] 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>
    ---
    drivers/isdn/capi/capi.c | 24 ++++++++++++------------
    1 files changed, 12 insertions(+), 12 deletions(-)

    diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
    index fa18971..2af6c05 100644
    --- a/drivers/isdn/capi/capi.c
    +++ b/drivers/isdn/capi/capi.c
    @@ -145,7 +145,7 @@ struct capidev {

    /* -------- global variables ---------------------------------------- */

    -static DEFINE_RWLOCK(capidev_list_lock);
    +static DEFINE_MUTEX(capidev_list_lock);
    static LIST_HEAD(capidev_list);

    #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
    @@ -405,7 +405,6 @@ static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)
    static struct capidev *capidev_alloc(void)
    {
    struct capidev *cdev;
    - unsigned long flags;

    cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
    if (!cdev)
    @@ -414,15 +413,19 @@ static struct capidev *capidev_alloc(void)
    mutex_init(&cdev->ncci_list_mtx);
    skb_queue_head_init(&cdev->recvqueue);
    init_waitqueue_head(&cdev->recvwait);
    - write_lock_irqsave(&capidev_list_lock, flags);
    +
    + mutex_lock(&capidev_list_lock);
    list_add_tail(&cdev->list, &capidev_list);
    - write_unlock_irqrestore(&capidev_list_lock, flags);
    + mutex_unlock(&capidev_list_lock);
    +
    return cdev;
    }

    static void capidev_free(struct capidev *cdev)
    {
    - unsigned long flags;
    + mutex_lock(&capidev_list_lock);
    + list_del(&cdev->list);
    + mutex_unlock(&capidev_list_lock);

    if (cdev->ap.applid) {
    capi20_release(&cdev->ap);
    @@ -434,9 +437,6 @@ static void capidev_free(struct capidev *cdev)
    capincci_free(cdev, 0xffffffff);
    mutex_unlock(&cdev->ncci_list_mtx);

    - write_lock_irqsave(&capidev_list_lock, flags);
    - list_del(&cdev->list);
    - write_unlock_irqrestore(&capidev_list_lock, flags);
    kfree(cdev);
    }

    @@ -1432,7 +1432,7 @@ static int proc_capidev_read_proc(char *page, char **start, off_t off,
    struct list_head *l;
    int len = 0;

    - read_lock(&capidev_list_lock);
    + mutex_lock(&capidev_list_lock);
    list_for_each(l, &capidev_list) {
    cdev = list_entry(l, struct capidev, list);
    len += sprintf(page+len, "0 %d %lu %lu %lu %lun",
    @@ -1451,7 +1451,7 @@ static int proc_capidev_read_proc(char *page, char **start, off_t off,
    }

    endloop:
    - read_unlock(&capidev_list_lock);
    + mutex_unlock(&capidev_list_lock);
    if (len < count)
    *eof = 1;
    if (len > count) len = count;
    @@ -1471,7 +1471,7 @@ static int proc_capincci_read_proc(char *page, char **start, off_t off,
    struct list_head *l;
    int len = 0;

    - read_lock(&capidev_list_lock);
    + mutex_lock(&capidev_list_lock);
    list_for_each(l, &capidev_list) {
    cdev = list_entry(l, struct capidev, list);
    for (np=cdev->nccis; np; np = np->next) {
    @@ -1488,7 +1488,7 @@ static int proc_capincci_read_proc(char *page, char **start, off_t off,
    }
    }
    endloop:
    - read_unlock(&capidev_list_lock);
    + mutex_unlock(&capidev_list_lock);
    *start = page+off;
    if (len < count)
    *eof = 1;
    --
    1.6.0.2


    \
     
     \ /
      Last update: 2010-01-23 00:27    [W:0.026 / U:0.068 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site