aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/cs423x
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/cs423x')
-rw-r--r--sound/isa/cs423x/cs4231.c213
-rw-r--r--sound/isa/cs423x/cs4231_lib.c4
-rw-r--r--sound/isa/cs423x/cs4236.c131
3 files changed, 149 insertions, 199 deletions
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index 696a5c86bcfa..ac4041134150 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -23,7 +23,7 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/platform_device.h> 26#include <linux/isa.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
@@ -32,8 +32,11 @@
32#include <sound/mpu401.h> 32#include <sound/mpu401.h>
33#include <sound/initval.h> 33#include <sound/initval.h>
34 34
35#define CRD_NAME "Generic CS4231"
36#define DEV_NAME "cs4231"
37
38MODULE_DESCRIPTION(CRD_NAME);
35MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 39MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36MODULE_DESCRIPTION("Generic CS4231");
37MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
38MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}"); 41MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}");
39 42
@@ -48,132 +51,136 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
48static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ 51static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
49 52
50module_param_array(index, int, NULL, 0444); 53module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for CS4231 soundcard."); 54MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
52module_param_array(id, charp, NULL, 0444); 55module_param_array(id, charp, NULL, 0444);
53MODULE_PARM_DESC(id, "ID string for CS4231 soundcard."); 56MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
54module_param_array(enable, bool, NULL, 0444); 57module_param_array(enable, bool, NULL, 0444);
55MODULE_PARM_DESC(enable, "Enable CS4231 soundcard."); 58MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
56module_param_array(port, long, NULL, 0444); 59module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for CS4231 driver."); 60MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
58module_param_array(mpu_port, long, NULL, 0444); 61module_param_array(mpu_port, long, NULL, 0444);
59MODULE_PARM_DESC(mpu_port, "MPU-401 port # for CS4231 driver."); 62MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
60module_param_array(irq, int, NULL, 0444); 63module_param_array(irq, int, NULL, 0444);
61MODULE_PARM_DESC(irq, "IRQ # for CS4231 driver."); 64MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
62module_param_array(mpu_irq, int, NULL, 0444); 65module_param_array(mpu_irq, int, NULL, 0444);
63MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for CS4231 driver."); 66MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
64module_param_array(dma1, int, NULL, 0444); 67module_param_array(dma1, int, NULL, 0444);
65MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); 68MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
66module_param_array(dma2, int, NULL, 0444); 69module_param_array(dma2, int, NULL, 0444);
67MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); 70MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
68 71
69static struct platform_device *devices[SNDRV_CARDS]; 72static int __devinit snd_cs4231_match(struct device *dev, unsigned int n)
73{
74 if (!enable[n])
75 return 0;
70 76
77 if (port[n] == SNDRV_AUTO_PORT) {
78 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
79 return 0;
80 }
81 if (irq[n] == SNDRV_AUTO_IRQ) {
82 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id);
83 return 0;
84 }
85 if (dma1[n] == SNDRV_AUTO_DMA) {
86 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id);
87 return 0;
88 }
89 return 1;
90}
71 91
72static int __init snd_cs4231_probe(struct platform_device *pdev) 92static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
73{ 93{
74 int dev = pdev->id;
75 struct snd_card *card; 94 struct snd_card *card;
76 struct snd_pcm *pcm;
77 struct snd_cs4231 *chip; 95 struct snd_cs4231 *chip;
78 int err; 96 struct snd_pcm *pcm;
97 int error;
79 98
80 if (port[dev] == SNDRV_AUTO_PORT) { 99 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
81 snd_printk(KERN_ERR "specify port\n"); 100 if (!card)
82 return -EINVAL;
83 }
84 if (irq[dev] == SNDRV_AUTO_IRQ) {
85 snd_printk(KERN_ERR "specify irq\n");
86 return -EINVAL;
87 }
88 if (dma1[dev] == SNDRV_AUTO_DMA) {
89 snd_printk(KERN_ERR "specify dma1\n");
90 return -EINVAL; 101 return -EINVAL;
91 } 102
92 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 103 error = snd_cs4231_create(card, port[n], -1, irq[n], dma1[n], dma2[n],
93 if (card == NULL) 104 CS4231_HW_DETECT, 0, &chip);
94 return -ENOMEM; 105 if (error < 0)
95 if ((err = snd_cs4231_create(card, port[dev], -1, 106 goto out;
96 irq[dev], 107
97 dma1[dev],
98 dma2[dev],
99 CS4231_HW_DETECT,
100 0, &chip)) < 0)
101 goto _err;
102 card->private_data = chip; 108 card->private_data = chip;
103 109
104 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) 110 error = snd_cs4231_pcm(chip, 0, &pcm);
105 goto _err; 111 if (error < 0)
112 goto out;
106 113
107 strcpy(card->driver, "CS4231"); 114 strcpy(card->driver, "CS4231");
108 strcpy(card->shortname, pcm->name); 115 strcpy(card->shortname, pcm->name);
116
109 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 117 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
110 pcm->name, chip->port, irq[dev], dma1[dev]); 118 pcm->name, chip->port, irq[n], dma1[n]);
111 if (dma2[dev] >= 0) 119 if (dma2[n] >= 0)
112 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); 120 sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);
113 121
114 if ((err = snd_cs4231_mixer(chip)) < 0) 122 error = snd_cs4231_mixer(chip);
115 goto _err; 123 if (error < 0)
116 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) 124 goto out;
117 goto _err; 125
118 126 error = snd_cs4231_timer(chip, 0, NULL);
119 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 127 if (error < 0)
120 if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 128 goto out;
121 mpu_irq[dev] = -1; 129
130 if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) {
131 if (mpu_irq[n] == SNDRV_AUTO_IRQ)
132 mpu_irq[n] = -1;
122 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, 133 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
123 mpu_port[dev], 0, 134 mpu_port[n], 0, mpu_irq[n],
124 mpu_irq[dev], 135 mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
125 mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
126 NULL) < 0) 136 NULL) < 0)
127 printk(KERN_WARNING "cs4231: MPU401 not detected\n"); 137 printk(KERN_WARNING "%s: MPU401 not detected\n", dev->bus_id);
128 } 138 }
129 139
130 snd_card_set_dev(card, &pdev->dev); 140 snd_card_set_dev(card, dev);
131 141
132 if ((err = snd_card_register(card)) < 0) 142 error = snd_card_register(card);
133 goto _err; 143 if (error < 0)
144 goto out;
134 145
135 platform_set_drvdata(pdev, card); 146 dev_set_drvdata(dev, card);
136 return 0; 147 return 0;
137 148
138 _err: 149out: snd_card_free(card);
139 snd_card_free(card); 150 return error;
140 return err;
141} 151}
142 152
143static int __devexit snd_cs4231_remove(struct platform_device *devptr) 153static int __devexit snd_cs4231_remove(struct device *dev, unsigned int n)
144{ 154{
145 snd_card_free(platform_get_drvdata(devptr)); 155 snd_card_free(dev_get_drvdata(dev));
146 platform_set_drvdata(devptr, NULL); 156 dev_set_drvdata(dev, NULL);
147 return 0; 157 return 0;
148} 158}
149 159
150#ifdef CONFIG_PM 160#ifdef CONFIG_PM
151static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state) 161static int snd_cs4231_suspend(struct device *dev, unsigned int n, pm_message_t state)
152{ 162{
153 struct snd_card *card; 163 struct snd_card *card = dev_get_drvdata(dev);
154 struct snd_cs4231 *chip; 164 struct snd_cs4231 *chip = card->private_data;
155 card = platform_get_drvdata(dev); 165
156 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 166 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
157 chip = card->private_data;
158 chip->suspend(chip); 167 chip->suspend(chip);
159 return 0; 168 return 0;
160} 169}
161 170
162static int snd_cs4231_resume(struct platform_device *dev) 171static int snd_cs4231_resume(struct device *dev, unsigned int n)
163{ 172{
164 struct snd_card *card; 173 struct snd_card *card = dev_get_drvdata(dev);
165 struct snd_cs4231 *chip; 174 struct snd_cs4231 *chip = card->private_data;
166 card = platform_get_drvdata(dev); 175
167 chip = card->private_data;
168 chip->resume(chip); 176 chip->resume(chip);
169 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 177 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
170 return 0; 178 return 0;
171} 179}
172#endif 180#endif
173 181
174#define SND_CS4231_DRIVER "snd_cs4231" 182static struct isa_driver snd_cs4231_driver = {
175 183 .match = snd_cs4231_match,
176static struct platform_driver snd_cs4231_driver = {
177 .probe = snd_cs4231_probe, 184 .probe = snd_cs4231_probe,
178 .remove = __devexit_p(snd_cs4231_remove), 185 .remove = __devexit_p(snd_cs4231_remove),
179#ifdef CONFIG_PM 186#ifdef CONFIG_PM
@@ -181,57 +188,19 @@ static struct platform_driver snd_cs4231_driver = {
181 .resume = snd_cs4231_resume, 188 .resume = snd_cs4231_resume,
182#endif 189#endif
183 .driver = { 190 .driver = {
184 .name = SND_CS4231_DRIVER 191 .name = DEV_NAME
185 }, 192 }
186}; 193};
187 194
188static void __init_or_module snd_cs4231_unregister_all(void)
189{
190 int i;
191
192 for (i = 0; i < ARRAY_SIZE(devices); ++i)
193 platform_device_unregister(devices[i]);
194 platform_driver_unregister(&snd_cs4231_driver);
195}
196
197static int __init alsa_card_cs4231_init(void) 195static int __init alsa_card_cs4231_init(void)
198{ 196{
199 int i, cards, err; 197 return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS);
200
201 err = platform_driver_register(&snd_cs4231_driver);
202 if (err < 0)
203 return err;
204
205 cards = 0;
206 for (i = 0; i < SNDRV_CARDS; i++) {
207 struct platform_device *device;
208 if (! enable[i])
209 continue;
210 device = platform_device_register_simple(SND_CS4231_DRIVER,
211 i, NULL, 0);
212 if (IS_ERR(device))
213 continue;
214 if (!platform_get_drvdata(device)) {
215 platform_device_unregister(device);
216 continue;
217 }
218 devices[i] = device;
219 cards++;
220 }
221 if (!cards) {
222#ifdef MODULE
223 printk(KERN_ERR "CS4231 soundcard not found or device busy\n");
224#endif
225 snd_cs4231_unregister_all();
226 return -ENODEV;
227 }
228 return 0;
229} 198}
230 199
231static void __exit alsa_card_cs4231_exit(void) 200static void __exit alsa_card_cs4231_exit(void)
232{ 201{
233 snd_cs4231_unregister_all(); 202 isa_unregister_driver(&snd_cs4231_driver);
234} 203}
235 204
236module_init(alsa_card_cs4231_init) 205module_init(alsa_card_cs4231_init);
237module_exit(alsa_card_cs4231_exit) 206module_exit(alsa_card_cs4231_exit);
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 75c7c5f01989..914d77b61b0c 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -405,7 +405,6 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); 405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
406 int result = 0; 406 int result = 0;
407 unsigned int what; 407 unsigned int what;
408 struct list_head *pos;
409 struct snd_pcm_substream *s; 408 struct snd_pcm_substream *s;
410 int do_start; 409 int do_start;
411 410
@@ -425,8 +424,7 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
425 } 424 }
426 425
427 what = 0; 426 what = 0;
428 snd_pcm_group_for_each(pos, substream) { 427 snd_pcm_group_for_each_entry(s, substream) {
429 s = snd_pcm_group_substream_entry(pos);
430 if (s == chip->playback_substream) { 428 if (s == chip->playback_substream) {
431 what |= CS4231_PLAYBACK_ENABLE; 429 what |= CS4231_PLAYBACK_ENABLE;
432 snd_pcm_trigger_done(s, substream); 430 snd_pcm_trigger_done(s, substream);
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 07ffd5c22e81..87f1392a2fa7 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/pnp.h> 27#include <linux/pnp.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -75,10 +75,10 @@ MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235},"
75 75
76#ifdef CS4232 76#ifdef CS4232
77#define IDENT "CS4232" 77#define IDENT "CS4232"
78#define CS423X_DRIVER "snd_cs4232" 78#define DEV_NAME "cs4232"
79#else 79#else
80#define IDENT "CS4236+" 80#define IDENT "CS4236+"
81#define CS423X_DRIVER "snd_cs4236" 81#define DEV_NAME "cs4236"
82#endif 82#endif
83 83
84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
@@ -126,14 +126,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
126module_param_array(dma2, int, NULL, 0444); 126module_param_array(dma2, int, NULL, 0444);
127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
128 128
129static struct platform_device *platform_devices[SNDRV_CARDS];
130#ifdef CONFIG_PNP 129#ifdef CONFIG_PNP
131static int pnpc_registered; 130static int pnpc_registered;
132#ifdef CS4232 131#ifdef CS4232
133static int pnp_registered; 132static int pnp_registered;
134#endif 133#endif
135#endif /* CONFIG_PNP */ 134#endif /* CONFIG_PNP */
136static unsigned int snd_cs423x_devices;
137 135
138struct snd_card_cs4236 { 136struct snd_card_cs4236 {
139 struct snd_cs4231 *chip; 137 struct snd_cs4231 *chip;
@@ -542,38 +540,55 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
542 return snd_card_register(card); 540 return snd_card_register(card);
543} 541}
544 542
545static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) 543static int __devinit snd_cs423x_isa_match(struct device *pdev,
544 unsigned int dev)
546{ 545{
547 int dev = pdev->id; 546 if (!enable[dev] || is_isapnp_selected(dev))
548 struct snd_card *card; 547 return 0;
549 int err;
550 548
551 if (port[dev] == SNDRV_AUTO_PORT) { 549 if (port[dev] == SNDRV_AUTO_PORT) {
552 snd_printk(KERN_ERR "specify port\n"); 550 snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id);
553 return -EINVAL; 551 return 0;
554 } 552 }
555 if (cport[dev] == SNDRV_AUTO_PORT) { 553 if (cport[dev] == SNDRV_AUTO_PORT) {
556 snd_printk(KERN_ERR "specify cport\n"); 554 snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id);
557 return -EINVAL; 555 return 0;
556 }
557 if (irq[dev] == SNDRV_AUTO_IRQ) {
558 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
559 return 0;
558 } 560 }
561 if (dma1[dev] == SNDRV_AUTO_DMA) {
562 snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id);
563 return 0;
564 }
565 return 1;
566}
567
568static int __devinit snd_cs423x_isa_probe(struct device *pdev,
569 unsigned int dev)
570{
571 struct snd_card *card;
572 int err;
559 573
560 card = snd_cs423x_card_new(dev); 574 card = snd_cs423x_card_new(dev);
561 if (! card) 575 if (! card)
562 return -ENOMEM; 576 return -ENOMEM;
563 snd_card_set_dev(card, &pdev->dev); 577 snd_card_set_dev(card, pdev);
564 if ((err = snd_cs423x_probe(card, dev)) < 0) { 578 if ((err = snd_cs423x_probe(card, dev)) < 0) {
565 snd_card_free(card); 579 snd_card_free(card);
566 return err; 580 return err;
567 } 581 }
568 582
569 platform_set_drvdata(pdev, card); 583 dev_set_drvdata(pdev, card);
570 return 0; 584 return 0;
571} 585}
572 586
573static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) 587static int __devexit snd_cs423x_isa_remove(struct device *pdev,
588 unsigned int dev)
574{ 589{
575 snd_card_free(platform_get_drvdata(devptr)); 590 snd_card_free(dev_get_drvdata(pdev));
576 platform_set_drvdata(devptr, NULL); 591 dev_set_drvdata(pdev, NULL);
577 return 0; 592 return 0;
578} 593}
579 594
@@ -594,26 +609,28 @@ static int snd_cs423x_resume(struct snd_card *card)
594 return 0; 609 return 0;
595} 610}
596 611
597static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 612static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n,
613 pm_message_t state)
598{ 614{
599 return snd_cs423x_suspend(platform_get_drvdata(dev)); 615 return snd_cs423x_suspend(dev_get_drvdata(dev));
600} 616}
601 617
602static int snd_cs423x_nonpnp_resume(struct platform_device *dev) 618static int snd_cs423x_isa_resume(struct device *dev, unsigned int n)
603{ 619{
604 return snd_cs423x_resume(platform_get_drvdata(dev)); 620 return snd_cs423x_resume(dev_get_drvdata(dev));
605} 621}
606#endif 622#endif
607 623
608static struct platform_driver cs423x_nonpnp_driver = { 624static struct isa_driver cs423x_isa_driver = {
609 .probe = snd_cs423x_nonpnp_probe, 625 .match = snd_cs423x_isa_match,
610 .remove = __devexit_p(snd_cs423x_nonpnp_remove), 626 .probe = snd_cs423x_isa_probe,
627 .remove = __devexit_p(snd_cs423x_isa_remove),
611#ifdef CONFIG_PM 628#ifdef CONFIG_PM
612 .suspend = snd_cs423x_nonpnp_suspend, 629 .suspend = snd_cs423x_isa_suspend,
613 .resume = snd_cs423x_nonpnp_resume, 630 .resume = snd_cs423x_isa_resume,
614#endif 631#endif
615 .driver = { 632 .driver = {
616 .name = CS423X_DRIVER 633 .name = DEV_NAME
617 }, 634 },
618}; 635};
619 636
@@ -651,7 +668,6 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
651 } 668 }
652 pnp_set_drvdata(pdev, card); 669 pnp_set_drvdata(pdev, card);
653 dev++; 670 dev++;
654 snd_cs423x_devices++;
655 return 0; 671 return 0;
656} 672}
657 673
@@ -715,7 +731,6 @@ static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
715 } 731 }
716 pnp_set_card_drvdata(pcard, card); 732 pnp_set_card_drvdata(pcard, card);
717 dev++; 733 dev++;
718 snd_cs423x_devices++;
719 return 0; 734 return 0;
720} 735}
721 736
@@ -750,45 +765,13 @@ static struct pnp_card_driver cs423x_pnpc_driver = {
750}; 765};
751#endif /* CONFIG_PNP */ 766#endif /* CONFIG_PNP */
752 767
753static void __init_or_module snd_cs423x_unregister_all(void)
754{
755 int i;
756
757#ifdef CONFIG_PNP
758 if (pnpc_registered)
759 pnp_unregister_card_driver(&cs423x_pnpc_driver);
760#ifdef CS4232
761 if (pnp_registered)
762 pnp_unregister_driver(&cs4232_pnp_driver);
763#endif
764#endif /* CONFIG_PNP */
765 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
766 platform_device_unregister(platform_devices[i]);
767 platform_driver_unregister(&cs423x_nonpnp_driver);
768}
769
770static int __init alsa_card_cs423x_init(void) 768static int __init alsa_card_cs423x_init(void)
771{ 769{
772 int i, err; 770 int err;
773 771
774 if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0) 772 err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS);
773 if (err < 0)
775 return err; 774 return err;
776
777 for (i = 0; i < SNDRV_CARDS; i++) {
778 struct platform_device *device;
779 if (! enable[i] || is_isapnp_selected(i))
780 continue;
781 device = platform_device_register_simple(CS423X_DRIVER,
782 i, NULL, 0);
783 if (IS_ERR(device))
784 continue;
785 if (!platform_get_drvdata(device)) {
786 platform_device_unregister(device);
787 continue;
788 }
789 platform_devices[i] = device;
790 snd_cs423x_devices++;
791 }
792#ifdef CONFIG_PNP 775#ifdef CONFIG_PNP
793#ifdef CS4232 776#ifdef CS4232
794 err = pnp_register_driver(&cs4232_pnp_driver); 777 err = pnp_register_driver(&cs4232_pnp_driver);
@@ -799,20 +782,20 @@ static int __init alsa_card_cs423x_init(void)
799 if (!err) 782 if (!err)
800 pnpc_registered = 1; 783 pnpc_registered = 1;
801#endif /* CONFIG_PNP */ 784#endif /* CONFIG_PNP */
802
803 if (!snd_cs423x_devices) {
804#ifdef MODULE
805 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
806#endif
807 snd_cs423x_unregister_all();
808 return -ENODEV;
809 }
810 return 0; 785 return 0;
811} 786}
812 787
813static void __exit alsa_card_cs423x_exit(void) 788static void __exit alsa_card_cs423x_exit(void)
814{ 789{
815 snd_cs423x_unregister_all(); 790#ifdef CONFIG_PNP
791 if (pnpc_registered)
792 pnp_unregister_card_driver(&cs423x_pnpc_driver);
793#ifdef CS4232
794 if (pnp_registered)
795 pnp_unregister_driver(&cs4232_pnp_driver);
796#endif
797#endif /* CONFIG_PNP */
798 isa_unregister_driver(&cs423x_isa_driver);
816} 799}
817 800
818module_init(alsa_card_cs423x_init) 801module_init(alsa_card_cs423x_init)