aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/es1968.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/es1968.c')
-rw-r--r--sound/pci/es1968.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 3747a436f0cd..6a265ab3894e 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -103,6 +103,8 @@
103#include <linux/slab.h> 103#include <linux/slab.h>
104#include <linux/gameport.h> 104#include <linux/gameport.h>
105#include <linux/moduleparam.h> 105#include <linux/moduleparam.h>
106#include <linux/mutex.h>
107
106#include <sound/core.h> 108#include <sound/core.h>
107#include <sound/pcm.h> 109#include <sound/pcm.h>
108#include <sound/mpu401.h> 110#include <sound/mpu401.h>
@@ -569,7 +571,7 @@ struct es1968 {
569 u16 maestro_map[32]; 571 u16 maestro_map[32];
570 int bobclient; /* active timer instancs */ 572 int bobclient; /* active timer instancs */
571 int bob_freq; /* timer frequency */ 573 int bob_freq; /* timer frequency */
572 struct semaphore memory_mutex; /* memory lock */ 574 struct mutex memory_mutex; /* memory lock */
573 575
574 /* APU states */ 576 /* APU states */
575 unsigned char apu[NR_APUS]; 577 unsigned char apu[NR_APUS];
@@ -1356,13 +1358,13 @@ static int calc_available_memory_size(struct es1968 *chip)
1356 struct list_head *p; 1358 struct list_head *p;
1357 int max_size = 0; 1359 int max_size = 0;
1358 1360
1359 down(&chip->memory_mutex); 1361 mutex_lock(&chip->memory_mutex);
1360 list_for_each(p, &chip->buf_list) { 1362 list_for_each(p, &chip->buf_list) {
1361 struct esm_memory *buf = list_entry(p, struct esm_memory, list); 1363 struct esm_memory *buf = list_entry(p, struct esm_memory, list);
1362 if (buf->empty && buf->buf.bytes > max_size) 1364 if (buf->empty && buf->buf.bytes > max_size)
1363 max_size = buf->buf.bytes; 1365 max_size = buf->buf.bytes;
1364 } 1366 }
1365 up(&chip->memory_mutex); 1367 mutex_unlock(&chip->memory_mutex);
1366 if (max_size >= 128*1024) 1368 if (max_size >= 128*1024)
1367 max_size = 127*1024; 1369 max_size = 127*1024;
1368 return max_size; 1370 return max_size;
@@ -1375,20 +1377,20 @@ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size)
1375 struct list_head *p; 1377 struct list_head *p;
1376 1378
1377 size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; 1379 size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN;
1378 down(&chip->memory_mutex); 1380 mutex_lock(&chip->memory_mutex);
1379 list_for_each(p, &chip->buf_list) { 1381 list_for_each(p, &chip->buf_list) {
1380 buf = list_entry(p, struct esm_memory, list); 1382 buf = list_entry(p, struct esm_memory, list);
1381 if (buf->empty && buf->buf.bytes >= size) 1383 if (buf->empty && buf->buf.bytes >= size)
1382 goto __found; 1384 goto __found;
1383 } 1385 }
1384 up(&chip->memory_mutex); 1386 mutex_unlock(&chip->memory_mutex);
1385 return NULL; 1387 return NULL;
1386 1388
1387__found: 1389__found:
1388 if (buf->buf.bytes > size) { 1390 if (buf->buf.bytes > size) {
1389 struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); 1391 struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL);
1390 if (chunk == NULL) { 1392 if (chunk == NULL) {
1391 up(&chip->memory_mutex); 1393 mutex_unlock(&chip->memory_mutex);
1392 return NULL; 1394 return NULL;
1393 } 1395 }
1394 chunk->buf = buf->buf; 1396 chunk->buf = buf->buf;
@@ -1400,7 +1402,7 @@ __found:
1400 list_add(&chunk->list, &buf->list); 1402 list_add(&chunk->list, &buf->list);
1401 } 1403 }
1402 buf->empty = 0; 1404 buf->empty = 0;
1403 up(&chip->memory_mutex); 1405 mutex_unlock(&chip->memory_mutex);
1404 return buf; 1406 return buf;
1405} 1407}
1406 1408
@@ -1409,7 +1411,7 @@ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf)
1409{ 1411{
1410 struct esm_memory *chunk; 1412 struct esm_memory *chunk;
1411 1413
1412 down(&chip->memory_mutex); 1414 mutex_lock(&chip->memory_mutex);
1413 buf->empty = 1; 1415 buf->empty = 1;
1414 if (buf->list.prev != &chip->buf_list) { 1416 if (buf->list.prev != &chip->buf_list) {
1415 chunk = list_entry(buf->list.prev, struct esm_memory, list); 1417 chunk = list_entry(buf->list.prev, struct esm_memory, list);
@@ -1428,7 +1430,7 @@ static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf)
1428 kfree(chunk); 1430 kfree(chunk);
1429 } 1431 }
1430 } 1432 }
1431 up(&chip->memory_mutex); 1433 mutex_unlock(&chip->memory_mutex);
1432} 1434}
1433 1435
1434static void snd_es1968_free_dmabuf(struct es1968 *chip) 1436static void snd_es1968_free_dmabuf(struct es1968 *chip)
@@ -2579,7 +2581,7 @@ static int __devinit snd_es1968_create(struct snd_card *card,
2579 INIT_LIST_HEAD(&chip->buf_list); 2581 INIT_LIST_HEAD(&chip->buf_list);
2580 INIT_LIST_HEAD(&chip->substream_list); 2582 INIT_LIST_HEAD(&chip->substream_list);
2581 spin_lock_init(&chip->ac97_lock); 2583 spin_lock_init(&chip->ac97_lock);
2582 init_MUTEX(&chip->memory_mutex); 2584 mutex_init(&chip->memory_mutex);
2583 tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip); 2585 tasklet_init(&chip->hwvol_tq, es1968_update_hw_volume, (unsigned long)chip);
2584 chip->card = card; 2586 chip->card = card;
2585 chip->pci = pci; 2587 chip->pci = pci;