aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/sb/sb8.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-02-22 06:50:54 -0500
committerJaroslav Kysela <perex@suse.cz>2007-05-11 10:55:40 -0400
commit5e24c1c1c496c4603395d6e9cc320f85008fc891 (patch)
tree3bc2d3797f632d99c7f31a49346d4e77b56520aa /sound/isa/sb/sb8.c
parent442f4f36bed8bcadcbda299c615c12fae95eda99 (diff)
[ALSA] Port the rest of ALSA ISA drivers to isa_driver
Port the rest of ALSA ISA drivers to use isa_driver framework instead of platform_driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/isa/sb/sb8.c')
-rw-r--r--sound/isa/sb/sb8.c86
1 files changed, 31 insertions, 55 deletions
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index be1e83e6dea3..b7de1bc0e8a4 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.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/ioport.h> 27#include <linux/ioport.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -56,8 +56,6 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver.");
56module_param_array(dma8, int, NULL, 0444); 56module_param_array(dma8, int, NULL, 0444);
57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); 57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
58 58
59static struct platform_device *devices[SNDRV_CARDS];
60
61struct snd_sb8 { 59struct snd_sb8 {
62 struct resource *fm_res; /* used to block FM i/o region for legacy cards */ 60 struct resource *fm_res; /* used to block FM i/o region for legacy cards */
63 struct snd_sb *chip; 61 struct snd_sb *chip;
@@ -83,9 +81,23 @@ static void snd_sb8_free(struct snd_card *card)
83 release_and_free_resource(acard->fm_res); 81 release_and_free_resource(acard->fm_res);
84} 82}
85 83
86static int __devinit snd_sb8_probe(struct platform_device *pdev) 84static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev)
85{
86 if (!enable[dev])
87 return 0;
88 if (irq[dev] == SNDRV_AUTO_IRQ) {
89 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
90 return 0;
91 }
92 if (dma8[dev] == SNDRV_AUTO_DMA) {
93 snd_printk(KERN_ERR "%s: please specify dma8\n", pdev->bus_id);
94 return 0;
95 }
96 return 1;
97}
98
99static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev)
87{ 100{
88 int dev = pdev->id;
89 struct snd_sb *chip; 101 struct snd_sb *chip;
90 struct snd_card *card; 102 struct snd_card *card;
91 struct snd_sb8 *acard; 103 struct snd_sb8 *acard;
@@ -180,12 +192,12 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev)
180 chip->port, 192 chip->port,
181 irq[dev], dma8[dev]); 193 irq[dev], dma8[dev]);
182 194
183 snd_card_set_dev(card, &pdev->dev); 195 snd_card_set_dev(card, pdev);
184 196
185 if ((err = snd_card_register(card)) < 0) 197 if ((err = snd_card_register(card)) < 0)
186 goto _err; 198 goto _err;
187 199
188 platform_set_drvdata(pdev, card); 200 dev_set_drvdata(pdev, card);
189 return 0; 201 return 0;
190 202
191 _err: 203 _err:
@@ -193,17 +205,18 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev)
193 return err; 205 return err;
194} 206}
195 207
196static int __devexit snd_sb8_remove(struct platform_device *pdev) 208static int __devexit snd_sb8_remove(struct device *pdev, unsigned int dev)
197{ 209{
198 snd_card_free(platform_get_drvdata(pdev)); 210 snd_card_free(dev_get_drvdata(pdev));
199 platform_set_drvdata(pdev, NULL); 211 dev_set_drvdata(pdev, NULL);
200 return 0; 212 return 0;
201} 213}
202 214
203#ifdef CONFIG_PM 215#ifdef CONFIG_PM
204static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) 216static int snd_sb8_suspend(struct device *dev, unsigned int n,
217 pm_message_t state)
205{ 218{
206 struct snd_card *card = platform_get_drvdata(dev); 219 struct snd_card *card = dev_get_drvdata(dev);
207 struct snd_sb8 *acard = card->private_data; 220 struct snd_sb8 *acard = card->private_data;
208 struct snd_sb *chip = acard->chip; 221 struct snd_sb *chip = acard->chip;
209 222
@@ -213,9 +226,9 @@ static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state)
213 return 0; 226 return 0;
214} 227}
215 228
216static int snd_sb8_resume(struct platform_device *dev) 229static int snd_sb8_resume(struct device *dev, unsigned int n)
217{ 230{
218 struct snd_card *card = platform_get_drvdata(dev); 231 struct snd_card *card = dev_get_drvdata(dev);
219 struct snd_sb8 *acard = card->private_data; 232 struct snd_sb8 *acard = card->private_data;
220 struct snd_sb *chip = acard->chip; 233 struct snd_sb *chip = acard->chip;
221 234
@@ -228,7 +241,8 @@ static int snd_sb8_resume(struct platform_device *dev)
228 241
229#define SND_SB8_DRIVER "snd_sb8" 242#define SND_SB8_DRIVER "snd_sb8"
230 243
231static struct platform_driver snd_sb8_driver = { 244static struct isa_driver snd_sb8_driver = {
245 .match = snd_sb8_match,
232 .probe = snd_sb8_probe, 246 .probe = snd_sb8_probe,
233 .remove = __devexit_p(snd_sb8_remove), 247 .remove = __devexit_p(snd_sb8_remove),
234#ifdef CONFIG_PM 248#ifdef CONFIG_PM
@@ -240,52 +254,14 @@ static struct platform_driver snd_sb8_driver = {
240 }, 254 },
241}; 255};
242 256
243static void __init_or_module snd_sb8_unregister_all(void)
244{
245 int i;
246
247 for (i = 0; i < ARRAY_SIZE(devices); ++i)
248 platform_device_unregister(devices[i]);
249 platform_driver_unregister(&snd_sb8_driver);
250}
251
252static int __init alsa_card_sb8_init(void) 257static int __init alsa_card_sb8_init(void)
253{ 258{
254 int i, cards, err; 259 return isa_register_driver(&snd_sb8_driver, SNDRV_CARDS);
255
256 err = platform_driver_register(&snd_sb8_driver);
257 if (err < 0)
258 return err;
259
260 cards = 0;
261 for (i = 0; i < SNDRV_CARDS; i++) {
262 struct platform_device *device;
263 if (! enable[i])
264 continue;
265 device = platform_device_register_simple(SND_SB8_DRIVER,
266 i, NULL, 0);
267 if (IS_ERR(device))
268 continue;
269 if (!platform_get_drvdata(device)) {
270 platform_device_unregister(device);
271 continue;
272 }
273 devices[i] = device;
274 cards++;
275 }
276 if (!cards) {
277#ifdef MODULE
278 snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");
279#endif
280 snd_sb8_unregister_all();
281 return -ENODEV;
282 }
283 return 0;
284} 260}
285 261
286static void __exit alsa_card_sb8_exit(void) 262static void __exit alsa_card_sb8_exit(void)
287{ 263{
288 snd_sb8_unregister_all(); 264 isa_unregister_driver(&snd_sb8_driver);
289} 265}
290 266
291module_init(alsa_card_sb8_init) 267module_init(alsa_card_sb8_init)