Skip to contentSkip to conversation

ad1848-lib: remove open_mutex

PATCH In review Krzysztof Helt 2 participants 2 messages Sep 19, 2007 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ad1848-lib: remove open_mutex

From: Krzysztof Helt <[email protected]>

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.

---

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

include/sound/ad1848.h +0 -1
diff -urp linux-ref/include/sound/ad1848.h linux-2.6.23/include/sound/ad1848.h
@@ -154,7 +154,6 @@ struct snd_ad1848 {
 #endif
 
 	spinlock_t reg_lock;
-	struct mutex open_mutex;
 };
 
 /* exported functions */
sound/isa/ad1848/ad1848_lib.c +3 -11
diff -urp linux-ref/sound/isa/ad1848/ad1848_lib.c linux-2.6.23/sound/isa/ad1848/ad1848_lib.c
@@ -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;
#1 lore raw

At Wed, 19 Sep 2007 18:06:31 +0200,

Quoted 11 lines · Krzysztof Helt

From: Krzysztof Helt <[email protected]>

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.

---

Quoted 7 lines

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)?

Yes, it looks fine.
But, I'd like to postpone after 1.0.15. OK?

Thanks,

Takashi