diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-12-25 11:40:34 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-12-25 11:40:34 +0100 |
commit | 5ce442fe2c9423ec5451222aee6f9b2127bb8311 (patch) | |
tree | 9cb12cf2c4ab5a8af5de219c22eade3908b5cb59 /sound | |
parent | 60cda2b53a7826d273198f668cd124f0eeda0e4a (diff) | |
parent | 2af752936b311a846622668f8b0f1893d8eccade (diff) | |
download | linux-3.10-5ce442fe2c9423ec5451222aee6f9b2127bb8311.tar.gz linux-3.10-5ce442fe2c9423ec5451222aee6f9b2127bb8311.tar.bz2 linux-3.10-5ce442fe2c9423ec5451222aee6f9b2127bb8311.zip |
Merge branch 'topic/udev-id-rename' into to-push
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/info.c | 17 | ||||
-rw-r--r-- | sound/core/init.c | 71 | ||||
-rw-r--r-- | sound/pci/rme9652/hdsp.c | 2 | ||||
-rw-r--r-- | sound/pci/rme9652/hdspm.c | 2 |
4 files changed, 89 insertions, 3 deletions
diff --git a/sound/core/info.c b/sound/core/info.c index 527b207462b..70fa87189f3 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -653,6 +653,23 @@ int snd_info_card_register(struct snd_card *card) } /* + * called on card->id change + */ +void snd_info_card_id_change(struct snd_card *card) +{ + mutex_lock(&info_mutex); + if (card->proc_root_link) { + snd_remove_proc_entry(snd_proc_root, card->proc_root_link); + card->proc_root_link = NULL; + } + if (strcmp(card->id, card->proc_root->name)) + card->proc_root_link = proc_symlink(card->id, + snd_proc_root, + card->proc_root->name); + mutex_unlock(&info_mutex); +} + +/* * de-register the card proc file * called from init.c */ diff --git a/sound/core/init.c b/sound/core/init.c index b47ff8b44be..0d5520c415d 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -533,6 +533,65 @@ static void choose_default_id(struct snd_card *card) } } +#ifndef CONFIG_SYSFS_DEPRECATED +static ssize_t +card_id_show_attr(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_card *card = dev_get_drvdata(dev); + return snprintf(buf, PAGE_SIZE, "%s\n", card ? card->id : "(null)"); +} + +static ssize_t +card_id_store_attr(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct snd_card *card = dev_get_drvdata(dev); + char buf1[sizeof(card->id)]; + size_t copy = count > sizeof(card->id) - 1 ? + sizeof(card->id) - 1 : count; + size_t idx; + int c; + + for (idx = 0; idx < copy; idx++) { + c = buf[idx]; + if (!isalnum(c) && c != '_' && c != '-') + return -EINVAL; + } + memcpy(buf1, buf, copy); + buf1[copy] = '\0'; + mutex_lock(&snd_card_mutex); + if (!snd_info_check_reserved_words(buf1)) { + __exist: + mutex_unlock(&snd_card_mutex); + return -EEXIST; + } + for (idx = 0; idx < snd_ecards_limit; idx++) { + if (snd_cards[idx] && !strcmp(snd_cards[idx]->id, buf1)) + goto __exist; + } + strcpy(card->id, buf1); + snd_info_card_id_change(card); + mutex_unlock(&snd_card_mutex); + + return count; +} + +static struct device_attribute card_id_attrs = + __ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr); + +static ssize_t +card_number_show_attr(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_card *card = dev_get_drvdata(dev); + return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1); +} + +static struct device_attribute card_number_attrs = + __ATTR(number, S_IRUGO, card_number_show_attr, NULL); +#endif /* CONFIG_SYSFS_DEPRECATED */ + /** * snd_card_register - register the soundcard * @card: soundcard structure @@ -553,7 +612,7 @@ int snd_card_register(struct snd_card *card) #ifndef CONFIG_SYSFS_DEPRECATED if (!card->card_dev) { card->card_dev = device_create(sound_class, card->dev, - MKDEV(0, 0), NULL, + MKDEV(0, 0), card, "card%i", card->number); if (IS_ERR(card->card_dev)) card->card_dev = NULL; @@ -576,6 +635,16 @@ int snd_card_register(struct snd_card *card) if (snd_mixer_oss_notify_callback) snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); #endif +#ifndef CONFIG_SYSFS_DEPRECATED + if (card->card_dev) { + err = device_create_file(card->card_dev, &card_id_attrs); + if (err < 0) + return err; + err = device_create_file(card->card_dev, &card_number_attrs); + if (err < 0) + return err; + } +#endif return 0; } diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index f87ff049711..44d0c15e2b7 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -1452,7 +1452,7 @@ static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int i if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) return -1; - sprintf (hdsp->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); + sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1); hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index d7dd53675cc..71231cf1b2b 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -1293,7 +1293,7 @@ static int __devinit snd_hdspm_create_midi (struct snd_card *card, if (err < 0) return err; - sprintf (hdspm->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); + sprintf(hdspm->midi[id].rmidi->name, "HDSPM MIDI %d", id+1); hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; snd_rawmidi_set_ops(hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, |