aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-12-25 05:40:34 -0500
committerTakashi Iwai <tiwai@suse.de>2008-12-25 05:40:34 -0500
commit5ce442fe2c9423ec5451222aee6f9b2127bb8311 (patch)
tree9cb12cf2c4ab5a8af5de219c22eade3908b5cb59
parent60cda2b53a7826d273198f668cd124f0eeda0e4a (diff)
parent2af752936b311a846622668f8b0f1893d8eccade (diff)
Merge branch 'topic/udev-id-rename' into to-push
-rw-r--r--include/sound/info.h106
-rw-r--r--sound/core/info.c17
-rw-r--r--sound/core/init.c71
-rw-r--r--sound/pci/rme9652/hdsp.c2
-rw-r--r--sound/pci/rme9652/hdspm.c2
5 files changed, 146 insertions, 52 deletions
diff --git a/include/sound/info.h b/include/sound/info.h
index 8ae72e74f898..7c2ee1a21b00 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -40,30 +40,34 @@ struct snd_info_buffer {
40struct snd_info_entry; 40struct snd_info_entry;
41 41
42struct snd_info_entry_text { 42struct snd_info_entry_text {
43 void (*read) (struct snd_info_entry *entry, struct snd_info_buffer *buffer); 43 void (*read)(struct snd_info_entry *entry,
44 void (*write) (struct snd_info_entry *entry, struct snd_info_buffer *buffer); 44 struct snd_info_buffer *buffer);
45 void (*write)(struct snd_info_entry *entry,
46 struct snd_info_buffer *buffer);
45}; 47};
46 48
47struct snd_info_entry_ops { 49struct snd_info_entry_ops {
48 int (*open) (struct snd_info_entry *entry, 50 int (*open)(struct snd_info_entry *entry,
49 unsigned short mode, void **file_private_data); 51 unsigned short mode, void **file_private_data);
50 int (*release) (struct snd_info_entry * entry, 52 int (*release)(struct snd_info_entry *entry,
51 unsigned short mode, void *file_private_data); 53 unsigned short mode, void *file_private_data);
52 long (*read) (struct snd_info_entry *entry, void *file_private_data, 54 long (*read)(struct snd_info_entry *entry, void *file_private_data,
53 struct file * file, char __user *buf, 55 struct file *file, char __user *buf,
56 unsigned long count, unsigned long pos);
57 long (*write)(struct snd_info_entry *entry, void *file_private_data,
58 struct file *file, const char __user *buf,
54 unsigned long count, unsigned long pos); 59 unsigned long count, unsigned long pos);
55 long (*write) (struct snd_info_entry *entry, void *file_private_data, 60 long long (*llseek)(struct snd_info_entry *entry,
56 struct file * file, const char __user *buf, 61 void *file_private_data, struct file *file,
57 unsigned long count, unsigned long pos); 62 long long offset, int orig);
58 long long (*llseek) (struct snd_info_entry *entry, void *file_private_data, 63 unsigned int(*poll)(struct snd_info_entry *entry,
59 struct file * file, long long offset, int orig); 64 void *file_private_data, struct file *file,
60 unsigned int (*poll) (struct snd_info_entry *entry, void *file_private_data, 65 poll_table *wait);
61 struct file * file, poll_table * wait); 66 int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
62 int (*ioctl) (struct snd_info_entry *entry, void *file_private_data, 67 struct file *file, unsigned int cmd, unsigned long arg);
63 struct file * file, unsigned int cmd, unsigned long arg); 68 int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
64 int (*mmap) (struct snd_info_entry *entry, void *file_private_data, 69 struct inode *inode, struct file *file,
65 struct inode * inode, struct file * file, 70 struct vm_area_struct *vma);
66 struct vm_area_struct * vma);
67}; 71};
68 72
69struct snd_info_entry { 73struct snd_info_entry {
@@ -106,34 +110,37 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer);
106static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} 110static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
107#endif 111#endif
108 112
109int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3))); 113int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) \
114 __attribute__ ((format (printf, 2, 3)));
110int snd_info_init(void); 115int snd_info_init(void);
111int snd_info_done(void); 116int snd_info_done(void);
112 117
113int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len); 118int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
114char *snd_info_get_str(char *dest, char *src, int len); 119char *snd_info_get_str(char *dest, char *src, int len);
115struct snd_info_entry *snd_info_create_module_entry(struct module * module, 120struct snd_info_entry *snd_info_create_module_entry(struct module *module,
116 const char *name, 121 const char *name,
117 struct snd_info_entry * parent); 122 struct snd_info_entry *parent);
118struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, 123struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
119 const char *name, 124 const char *name,
120 struct snd_info_entry * parent); 125 struct snd_info_entry *parent);
121void snd_info_free_entry(struct snd_info_entry * entry); 126void snd_info_free_entry(struct snd_info_entry *entry);
122int snd_info_store_text(struct snd_info_entry * entry); 127int snd_info_store_text(struct snd_info_entry *entry);
123int snd_info_restore_text(struct snd_info_entry * entry); 128int snd_info_restore_text(struct snd_info_entry *entry);
124 129
125int snd_info_card_create(struct snd_card * card); 130int snd_info_card_create(struct snd_card *card);
126int snd_info_card_register(struct snd_card * card); 131int snd_info_card_register(struct snd_card *card);
127int snd_info_card_free(struct snd_card * card); 132int snd_info_card_free(struct snd_card *card);
128void snd_info_card_disconnect(struct snd_card * card); 133void snd_info_card_disconnect(struct snd_card *card);
129int snd_info_register(struct snd_info_entry * entry); 134void snd_info_card_id_change(struct snd_card *card);
135int snd_info_register(struct snd_info_entry *entry);
130 136
131/* for card drivers */ 137/* for card drivers */
132int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_entry **entryp); 138int snd_card_proc_new(struct snd_card *card, const char *name,
139 struct snd_info_entry **entryp);
133 140
134static inline void snd_info_set_text_ops(struct snd_info_entry *entry, 141static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
135 void *private_data, 142 void *private_data,
136 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) 143 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
137{ 144{
138 entry->private_data = private_data; 145 entry->private_data = private_data;
139 entry->c.text.read = read; 146 entry->c.text.read = read;
@@ -146,21 +153,22 @@ int snd_info_check_reserved_words(const char *str);
146#define snd_seq_root NULL 153#define snd_seq_root NULL
147#define snd_oss_root NULL 154#define snd_oss_root NULL
148 155
149static inline int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) { return 0; } 156static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
150static inline int snd_info_init(void) { return 0; } 157static inline int snd_info_init(void) { return 0; }
151static inline int snd_info_done(void) { return 0; } 158static inline int snd_info_done(void) { return 0; }
152 159
153static inline int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len) { return 0; } 160static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
154static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; } 161static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
155static inline struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, struct snd_info_entry * parent) { return NULL; } 162static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
156static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, const char *name, struct snd_info_entry * parent) { return NULL; } 163static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
157static inline void snd_info_free_entry(struct snd_info_entry * entry) { ; } 164static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
158 165
159static inline int snd_info_card_create(struct snd_card * card) { return 0; } 166static inline int snd_info_card_create(struct snd_card *card) { return 0; }
160static inline int snd_info_card_register(struct snd_card * card) { return 0; } 167static inline int snd_info_card_register(struct snd_card *card) { return 0; }
161static inline int snd_info_card_free(struct snd_card * card) { return 0; } 168static inline int snd_info_card_free(struct snd_card *card) { return 0; }
162static inline void snd_info_card_disconnect(struct snd_card * card) { } 169static inline void snd_info_card_disconnect(struct snd_card *card) { }
163static inline int snd_info_register(struct snd_info_entry * entry) { return 0; } 170static inline void snd_info_card_id_change(struct snd_card *card) { }
171static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
164 172
165static inline int snd_card_proc_new(struct snd_card *card, const char *name, 173static inline int snd_card_proc_new(struct snd_card *card, const char *name,
166 struct snd_info_entry **entryp) { return -EINVAL; } 174 struct snd_info_entry **entryp) { return -EINVAL; }
diff --git a/sound/core/info.c b/sound/core/info.c
index 527b207462b0..70fa87189f36 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -653,6 +653,23 @@ int snd_info_card_register(struct snd_card *card)
653} 653}
654 654
655/* 655/*
656 * called on card->id change
657 */
658void snd_info_card_id_change(struct snd_card *card)
659{
660 mutex_lock(&info_mutex);
661 if (card->proc_root_link) {
662 snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
663 card->proc_root_link = NULL;
664 }
665 if (strcmp(card->id, card->proc_root->name))
666 card->proc_root_link = proc_symlink(card->id,
667 snd_proc_root,
668 card->proc_root->name);
669 mutex_unlock(&info_mutex);
670}
671
672/*
656 * de-register the card proc file 673 * de-register the card proc file
657 * called from init.c 674 * called from init.c
658 */ 675 */
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
537static ssize_t
538card_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
545static ssize_t
546card_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
580static struct device_attribute card_id_attrs =
581 __ATTR(id, S_IRUGO | S_IWUSR, card_id_show_attr, card_id_store_attr);
582
583static ssize_t
584card_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
591static 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
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index f87ff0497116..44d0c15e2b71 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
1452 if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) 1452 if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0)
1453 return -1; 1453 return -1;
1454 1454
1455 sprintf (hdsp->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); 1455 sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1);
1456 hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; 1456 hdsp->midi[id].rmidi->private_data = &hdsp->midi[id];
1457 1457
1458 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); 1458 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 d7dd53675ccd..71231cf1b2b0 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,
1293 if (err < 0) 1293 if (err < 0)
1294 return err; 1294 return err;
1295 1295
1296 sprintf (hdspm->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); 1296 sprintf(hdspm->midi[id].rmidi->name, "HDSPM MIDI %d", id+1);
1297 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; 1297 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id];
1298 1298
1299 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, 1299 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,