[PATCH] drivers/isdn/gigaset: reduce mutex scope
authorTilman Schmidt <tilman@imap.cc>
Mon, 12 Feb 2007 08:52:24 +0000 (00:52 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 12 Feb 2007 17:48:29 +0000 (09:48 -0800)
Do not lock the cardstate structure mutex earlier than necessary.

Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/isdn/gigaset/common.c
drivers/isdn/gigaset/interface.c

index 4f75cce6fdff41df1a1375356d4cd0438856bb9c..9d4ae04eb33fa3ade53e8517fb3f58361547384d 100644 (file)
@@ -640,7 +640,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
                return NULL;
        }
        mutex_init(&cs->mutex);
-       mutex_lock(&cs->mutex);
 
        gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
        cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
@@ -738,6 +737,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
 
        ++cs->cs_init;
 
+       /* set up character device */
        gigaset_if_init(cs);
 
        /* set up device sysfs */
@@ -753,11 +753,9 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
        add_timer(&cs->timer);
 
        gig_dbg(DEBUG_INIT, "cs initialized");
-       mutex_unlock(&cs->mutex);
        return cs;
 
 error:
-       mutex_unlock(&cs->mutex);
        gig_dbg(DEBUG_INIT, "failed");
        gigaset_freecs(cs);
        return NULL;
index f13de20947e0bf74f74fe6d2aa43129818e5b4f8..eb50f3dab5f77908ecc6111da0911b1a3370b9c2 100644 (file)
@@ -615,6 +615,8 @@ void gigaset_if_init(struct cardstate *cs)
                return;
 
        tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs);
+
+       mutex_lock(&cs->mutex);
        cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL);
 
        if (!IS_ERR(cs->tty_dev))
@@ -623,6 +625,7 @@ void gigaset_if_init(struct cardstate *cs)
                warn("could not register device to the tty subsystem");
                cs->tty_dev = NULL;
        }
+       mutex_unlock(&cs->mutex);
 }
 
 void gigaset_if_free(struct cardstate *cs)