diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 14:41:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 14:41:32 -0500 |
commit | cb10ea549fdc0ab2dd8988adab5bf40b4fa642f3 (patch) | |
tree | 6bc11e0af9f0639a5eedd055401086c8c771f21e /sound/core/init.c | |
parent | 81d6e59dabb1ae0c782e9eb7e3d88f699d25b314 (diff) | |
parent | 5ce442fe2c9423ec5451222aee6f9b2127bb8311 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (367 commits)
ALSA: ASoC: fix a typo in omp-pcm.c
ASoC: Fix DSP formats in SSM2602 audio codec
ASoC: Fix incorrect DSP format in OMAP McBSP DAI and affected drivers
ALSA: hda: fix incorrect mixer index values for 92hd83xx
ALSA: hda: dinput_mux check
ALSA: hda - Add quirk for another HP dv7
ALSA: ASoC - Add missing __devexit annotation to wm8350.c
ALSA: ASoc: DaVinci: davinci-evm use dsp_b mode
ALSA: ASoC: DaVinci: i2s, evm, pass same value to codec and cpu_dai
ALSA: ASoC: tlv320aic3x add dsp_a
ALSA: ASoC: DaVinci: document I2S limitations
ALSA: ASoC: DaVinci: davinci-i2s clean up
ALSA: ASoC: DaVinci: davinci-i2s clean up
ALSA: ASoC: DaVinci: davinci-i2s add comments to explain polarity
ALSA: ASoC: DaVinci: davinvi-evm, make requests explicit
ALSA: ca0106 - disable 44.1kHz capture
ALSA: ca0106 - Add missing card->private_data initialization
ALSA: ca0106 - Check ac97 availability at PM
ALSA: hda - Power up always when no jack detection is available
ALSA: hda - Fix unused variable warnings in patch_sigmatel.c
...
Diffstat (limited to 'sound/core/init.c')
-rw-r--r-- | sound/core/init.c | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/sound/core/init.c b/sound/core/init.c index b47ff8b44be8..0d5520c415d3 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -533,6 +533,65 @@ static void choose_default_id(struct snd_card *card) | |||
533 | } | 533 | } |
534 | } | 534 | } |
535 | 535 | ||
536 | #ifndef CONFIG_SYSFS_DEPRECATED | ||
537 | static ssize_t | ||
538 | card_id_show_attr(struct device *dev, | ||
539 | struct device_attribute *attr, char *buf) | ||
540 | { | ||
541 | struct snd_card *card = dev_get_drvdata(dev); | ||
542 | return snprintf(buf, PAGE_SIZE, "%s\n", card ? card->id : "(null)"); | ||
543 | } | ||
544 | |||
545 | static ssize_t | ||
546 | card_id_store_attr(struct device *dev, struct device_attribute *attr, | ||
547 | const char *buf, size_t count) | ||
548 | { | ||
549 | struct snd_card *card = dev_get_drvdata(dev); | ||
550 | char buf1[sizeof(card->id)]; | ||
551 | size_t copy = count > sizeof(card->id) - 1 ? | ||
552 | sizeof(card->id) - 1 : count; | ||
553 | size_t idx; | ||
554 | int c; | ||
555 | |||
556 | for (idx = 0; idx < copy; idx++) { | ||
557 | c = buf[idx]; | ||
558 | if (!isalnum(c) && c != '_' && c != '-') | ||
559 | return -EINVAL; | ||
560 | } | ||
561 | memcpy(buf1, buf, copy); | ||
562 | buf1[copy] = '\0'; | ||
563 | mutex_lock(&snd_card_mutex); | ||
564 | if (!snd_info_check_reserved_words(buf1)) { | ||
565 | __exist: | ||
566 | mutex_unlock(&snd_card_mutex); | ||
567 | return -EEXIST; | ||
568 | } | ||
569 | for (idx = 0; idx < snd_ecards_limit; idx++) { | ||
570 | if (snd_cards[idx] && !strcmp(snd_cards[idx]->id, buf1)) | ||
571 | goto __exist; | ||
572 | } | ||
573 | strcpy(card->id, buf1); | ||
574 | snd_info_card_id_change(card); | ||
575 | mutex_unlock(&snd_card_mutex); | ||
576 | |||
577 | return count; | ||
578 | } | ||
579 | |||
580 | static struct device_attribute card_id_attrs = | ||
581 | __ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr); | ||
582 | |||
583 | static ssize_t | ||
584 | card_number_show_attr(struct device *dev, | ||
585 | struct device_attribute *attr, char *buf) | ||
586 | { | ||
587 | struct snd_card *card = dev_get_drvdata(dev); | ||
588 | return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1); | ||
589 | } | ||
590 | |||
591 | static struct device_attribute card_number_attrs = | ||
592 | __ATTR(number, S_IRUGO, card_number_show_attr, NULL); | ||
593 | #endif /* CONFIG_SYSFS_DEPRECATED */ | ||
594 | |||
536 | /** | 595 | /** |
537 | * snd_card_register - register the soundcard | 596 | * snd_card_register - register the soundcard |
538 | * @card: soundcard structure | 597 | * @card: soundcard structure |
@@ -553,7 +612,7 @@ int snd_card_register(struct snd_card *card) | |||
553 | #ifndef CONFIG_SYSFS_DEPRECATED | 612 | #ifndef CONFIG_SYSFS_DEPRECATED |
554 | if (!card->card_dev) { | 613 | if (!card->card_dev) { |
555 | card->card_dev = device_create(sound_class, card->dev, | 614 | card->card_dev = device_create(sound_class, card->dev, |
556 | MKDEV(0, 0), NULL, | 615 | MKDEV(0, 0), card, |
557 | "card%i", card->number); | 616 | "card%i", card->number); |
558 | if (IS_ERR(card->card_dev)) | 617 | if (IS_ERR(card->card_dev)) |
559 | card->card_dev = NULL; | 618 | card->card_dev = NULL; |
@@ -576,6 +635,16 @@ int snd_card_register(struct snd_card *card) | |||
576 | if (snd_mixer_oss_notify_callback) | 635 | if (snd_mixer_oss_notify_callback) |
577 | snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); | 636 | snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); |
578 | #endif | 637 | #endif |
638 | #ifndef CONFIG_SYSFS_DEPRECATED | ||
639 | if (card->card_dev) { | ||
640 | err = device_create_file(card->card_dev, &card_id_attrs); | ||
641 | if (err < 0) | ||
642 | return err; | ||
643 | err = device_create_file(card->card_dev, &card_number_attrs); | ||
644 | if (err < 0) | ||
645 | return err; | ||
646 | } | ||
647 | #endif | ||
579 | return 0; | 648 | return 0; |
580 | } | 649 | } |
581 | 650 | ||