26 |
#include <linux/slab.h> |
#include <linux/slab.h> |
27 |
#include <linux/time.h> |
#include <linux/time.h> |
28 |
#include <linux/ctype.h> |
#include <linux/ctype.h> |
|
#include <linux/workqueue.h> |
|
29 |
#include <sound/core.h> |
#include <sound/core.h> |
30 |
#include <sound/control.h> |
#include <sound/control.h> |
31 |
#include <sound/info.h> |
#include <sound/info.h> |
49 |
snd_iprintf(buffer, "%s\n", entry->card->id); |
snd_iprintf(buffer, "%s\n", entry->card->id); |
50 |
} |
} |
51 |
|
|
52 |
|
static void snd_card_free_thread(void * __card); |
53 |
|
|
54 |
/** |
/** |
55 |
* snd_card_new - create and initialize a soundcard structure |
* snd_card_new - create and initialize a soundcard structure |
56 |
* @idx: card index (address) [0 ... (SNDRV_CARDS-1)] |
* @idx: card index (address) [0 ... (SNDRV_CARDS-1)] |
116 |
INIT_LIST_HEAD(&card->ctl_files); |
INIT_LIST_HEAD(&card->ctl_files); |
117 |
spin_lock_init(&card->files_lock); |
spin_lock_init(&card->files_lock); |
118 |
init_waitqueue_head(&card->shutdown_sleep); |
init_waitqueue_head(&card->shutdown_sleep); |
119 |
|
INIT_WORK(&card->free_workq, snd_card_free_thread, card); |
120 |
#ifdef CONFIG_PM |
#ifdef CONFIG_PM |
121 |
init_MUTEX(&card->power_lock); |
init_MUTEX(&card->power_lock); |
122 |
init_waitqueue_head(&card->power_sleep); |
init_waitqueue_head(&card->power_sleep); |
329 |
*/ |
*/ |
330 |
int snd_card_free_in_thread(snd_card_t * card) |
int snd_card_free_in_thread(snd_card_t * card) |
331 |
{ |
{ |
|
DECLARE_WORK(works, snd_card_free_thread, card); |
|
|
|
|
332 |
if (card->files == NULL) { |
if (card->files == NULL) { |
333 |
snd_card_free(card); |
snd_card_free(card); |
334 |
return 0; |
return 0; |
335 |
} |
} |
336 |
if (schedule_work(&works)) |
|
337 |
|
if (schedule_work(&card->free_workq)) |
338 |
return 0; |
return 0; |
339 |
|
|
340 |
snd_printk(KERN_ERR "kernel_thread failed in snd_card_free_in_thread for card %i\n", card->number); |
snd_printk(KERN_ERR "schedule_work() failed in snd_card_free_in_thread for card %i\n", card->number); |
341 |
/* try to free the structure immediately */ |
/* try to free the structure immediately */ |
342 |
snd_card_free(card); |
snd_card_free(card); |
343 |
return -EFAULT; |
return -EFAULT; |
355 |
id++; |
id++; |
356 |
} |
} |
357 |
id = card->id; |
id = card->id; |
358 |
|
while (*spos != '\0' && !isalnum(*spos)) |
359 |
|
spos++; |
360 |
|
if (isdigit(*spos)) |
361 |
|
*id++ = isalpha(card->shortname[0]) ? card->shortname[0] : 'D'; |
362 |
while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { |
while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { |
363 |
if (isalnum(*spos)) |
if (isalnum(*spos)) |
364 |
*id++ = *spos; |
*id++ = *spos; |
367 |
*id = '\0'; |
*id = '\0'; |
368 |
|
|
369 |
id = card->id; |
id = card->id; |
370 |
|
|
371 |
|
if (*id == '\0') |
372 |
|
strcpy(id, "default"); |
373 |
|
|
374 |
while (1) { |
while (1) { |
375 |
if (loops-- == 0) { |
if (loops-- == 0) { |
429 |
write_unlock(&snd_card_rwlock); |
write_unlock(&snd_card_rwlock); |
430 |
return 0; |
return 0; |
431 |
} |
} |
432 |
if (!card->id[0]) |
if (card->id[0] == '\0') |
433 |
choose_default_id(card); |
choose_default_id(card); |
434 |
snd_cards[card->number] = card; |
snd_cards[card->number] = card; |
435 |
snd_cards_count++; |
snd_cards_count++; |