diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-06-10 01:26:26 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-06-10 01:26:26 -0400 |
commit | d3e3743694cbfd64450b3468e11b40ba8c6f4369 (patch) | |
tree | 625a71167bb1c7195aafff8ab333ba86d04e9fba /sound | |
parent | d108728ea24a766335ae22f10bfaf41f248fb70e (diff) | |
parent | 5fdc18d938c99399b73fe894bc24cb9400a1a2ee (diff) |
Merge branch 'topic/core-id-check' into for-linus
* topic/core-id-check:
ALSA: Core - clean up snd_card_set_id* calls and remove possible id collision
ALSA: Fix double locking of card list in snd_card_register()
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/init.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/sound/core/init.c b/sound/core/init.c index 6557dd85e191..d5d40d78c409 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -153,7 +153,7 @@ int snd_card_create(int idx, const char *xid, | |||
153 | if (!card) | 153 | if (!card) |
154 | return -ENOMEM; | 154 | return -ENOMEM; |
155 | if (xid) | 155 | if (xid) |
156 | snd_card_set_id(card, xid); | 156 | strlcpy(card->id, xid, sizeof(card->id)); |
157 | err = 0; | 157 | err = 0; |
158 | mutex_lock(&snd_card_mutex); | 158 | mutex_lock(&snd_card_mutex); |
159 | if (idx < 0) { | 159 | if (idx < 0) { |
@@ -476,23 +476,12 @@ int snd_card_free(struct snd_card *card) | |||
476 | 476 | ||
477 | EXPORT_SYMBOL(snd_card_free); | 477 | EXPORT_SYMBOL(snd_card_free); |
478 | 478 | ||
479 | /** | 479 | static void snd_card_set_id_no_lock(struct snd_card *card, const char *nid) |
480 | * snd_card_set_id - set card identification name | ||
481 | * @card: soundcard structure | ||
482 | * @nid: new identification string | ||
483 | * | ||
484 | * This function sets the card identification and checks for name | ||
485 | * collisions. | ||
486 | */ | ||
487 | void snd_card_set_id(struct snd_card *card, const char *nid) | ||
488 | { | 480 | { |
489 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; | 481 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; |
490 | const char *spos, *src; | 482 | const char *spos, *src; |
491 | char *id; | 483 | char *id; |
492 | 484 | ||
493 | /* check if user specified own card->id */ | ||
494 | if (card->id[0] != '\0') | ||
495 | return; | ||
496 | if (nid == NULL) { | 485 | if (nid == NULL) { |
497 | id = card->shortname; | 486 | id = card->shortname; |
498 | spos = src = id; | 487 | spos = src = id; |
@@ -529,14 +518,10 @@ void snd_card_set_id(struct snd_card *card, const char *nid) | |||
529 | } | 518 | } |
530 | if (!snd_info_check_reserved_words(id)) | 519 | if (!snd_info_check_reserved_words(id)) |
531 | goto __change; | 520 | goto __change; |
532 | mutex_lock(&snd_card_mutex); | ||
533 | for (i = 0; i < snd_ecards_limit; i++) { | 521 | for (i = 0; i < snd_ecards_limit; i++) { |
534 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, id)) { | 522 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, id)) |
535 | mutex_unlock(&snd_card_mutex); | ||
536 | goto __change; | 523 | goto __change; |
537 | } | ||
538 | } | 524 | } |
539 | mutex_unlock(&snd_card_mutex); | ||
540 | break; | 525 | break; |
541 | 526 | ||
542 | __change: | 527 | __change: |
@@ -561,6 +546,23 @@ void snd_card_set_id(struct snd_card *card, const char *nid) | |||
561 | } | 546 | } |
562 | } | 547 | } |
563 | 548 | ||
549 | /** | ||
550 | * snd_card_set_id - set card identification name | ||
551 | * @card: soundcard structure | ||
552 | * @nid: new identification string | ||
553 | * | ||
554 | * This function sets the card identification and checks for name | ||
555 | * collisions. | ||
556 | */ | ||
557 | void snd_card_set_id(struct snd_card *card, const char *nid) | ||
558 | { | ||
559 | /* check if user specified own card->id */ | ||
560 | if (card->id[0] != '\0') | ||
561 | return; | ||
562 | mutex_lock(&snd_card_mutex); | ||
563 | snd_card_set_id_no_lock(card, nid); | ||
564 | mutex_unlock(&snd_card_mutex); | ||
565 | } | ||
564 | EXPORT_SYMBOL(snd_card_set_id); | 566 | EXPORT_SYMBOL(snd_card_set_id); |
565 | 567 | ||
566 | #ifndef CONFIG_SYSFS_DEPRECATED | 568 | #ifndef CONFIG_SYSFS_DEPRECATED |
@@ -656,8 +658,7 @@ int snd_card_register(struct snd_card *card) | |||
656 | mutex_unlock(&snd_card_mutex); | 658 | mutex_unlock(&snd_card_mutex); |
657 | return 0; | 659 | return 0; |
658 | } | 660 | } |
659 | if (card->id[0] == '\0') | 661 | snd_card_set_id_no_lock(card, card->id[0] == '\0' ? NULL : card->id); |
660 | snd_card_set_id(card, NULL); | ||
661 | snd_cards[card->number] = card; | 662 | snd_cards[card->number] = card; |
662 | mutex_unlock(&snd_card_mutex); | 663 | mutex_unlock(&snd_card_mutex); |
663 | init_info_for_card(card); | 664 | init_info_for_card(card); |