[alsa-devel] [PATCH] ad1848-lib: remove open_mutex
Krzysztof Helt
krzysztof.h1 at gmail.com
Wed Sep 19 18:06:31 CEST 2007
From: Krzysztof Helt <krzysztof.h1 at wp.pl>
This patch removes open_mutex from the ad1848-lib as
open and close operations are called only from pcm layer
and mutexed there with pcm->open_mutex.
Signed-off-by: Krzysztof Helt <krzysztof.h1 at wp.pl>
---
Another step into crusade against the ad1848-lib. Inspired by
Trent's comments about missing locking I have checked and
open and close operations are already mutexed in the pcm layer
by similarly called pcm->open_mutex. The OSS pcm layer
also uses the pcm->open_mutex.
Is it right thing to do? (Takashi, Jaroslav)?
Regards,
Krzysztof
diff -urp linux-ref/include/sound/ad1848.h linux-2.6.23/include/sound/ad1848.h
--- linux-ref/include/sound/ad1848.h 2007-09-12 13:33:51.000000000 +0200
+++ linux-2.6.23/include/sound/ad1848.h 2007-09-19 17:54:30.000000000 +0200
@@ -154,7 +154,6 @@ struct snd_ad1848 {
#endif
spinlock_t reg_lock;
- struct mutex open_mutex;
};
/* exported functions */
diff -urp linux-ref/sound/isa/ad1848/ad1848_lib.c linux-2.6.23/sound/isa/ad1848/ad1848_lib.c
--- linux-ref/sound/isa/ad1848/ad1848_lib.c 2007-09-12 13:33:51.000000000 +0200
+++ linux-2.6.23/sound/isa/ad1848/ad1848_lib.c 2007-09-19 17:59:38.000000000 +0200
@@ -391,11 +391,9 @@ static int snd_ad1848_open(struct snd_ad
{
unsigned long flags;
- mutex_lock(&chip->open_mutex);
- if (chip->mode & AD1848_MODE_OPEN) {
- mutex_unlock(&chip->open_mutex);
+ if (chip->mode & AD1848_MODE_OPEN)
return -EAGAIN;
- }
+
snd_ad1848_mce_down(chip);
#ifdef SNDRV_DEBUG_MCE
@@ -436,7 +434,6 @@ static int snd_ad1848_open(struct snd_ad
spin_unlock_irqrestore(&chip->reg_lock, flags);
chip->mode = mode;
- mutex_unlock(&chip->open_mutex);
return 0;
}
@@ -445,11 +442,8 @@ static void snd_ad1848_close(struct snd_
{
unsigned long flags;
- mutex_lock(&chip->open_mutex);
- if (!chip->mode) {
- mutex_unlock(&chip->open_mutex);
+ if (!chip->mode)
return;
- }
/* disable IRQ */
spin_lock_irqsave(&chip->reg_lock, flags);
outb(0, AD1848P(chip, STATUS)); /* clear IRQ */
@@ -475,7 +469,6 @@ static void snd_ad1848_close(struct snd_
spin_unlock_irqrestore(&chip->reg_lock, flags);
chip->mode = 0;
- mutex_unlock(&chip->open_mutex);
}
/*
@@ -893,7 +886,6 @@ int snd_ad1848_create(struct snd_card *c
if (chip == NULL)
return -ENOMEM;
spin_lock_init(&chip->reg_lock);
- mutex_init(&chip->open_mutex);
chip->card = card;
chip->port = port;
chip->irq = -1;
More information about the Alsa-devel
mailing list