diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-02-22 06:50:54 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-05-11 10:55:40 -0400 |
commit | 5e24c1c1c496c4603395d6e9cc320f85008fc891 (patch) | |
tree | 3bc2d3797f632d99c7f31a49346d4e77b56520aa /sound/isa/es18xx.c | |
parent | 442f4f36bed8bcadcbda299c615c12fae95eda99 (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/es18xx.c')
-rw-r--r-- | sound/isa/es18xx.c | 106 |
1 files changed, 37 insertions, 69 deletions
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 725c115ff97d..12b61af1a4ef 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c | |||
@@ -80,7 +80,7 @@ | |||
80 | #include <sound/driver.h> | 80 | #include <sound/driver.h> |
81 | #include <linux/init.h> | 81 | #include <linux/init.h> |
82 | #include <linux/err.h> | 82 | #include <linux/err.h> |
83 | #include <linux/platform_device.h> | 83 | #include <linux/isa.h> |
84 | #include <linux/slab.h> | 84 | #include <linux/slab.h> |
85 | #include <linux/pnp.h> | 85 | #include <linux/pnp.h> |
86 | #include <linux/isapnp.h> | 86 | #include <linux/isapnp.h> |
@@ -2035,8 +2035,6 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver."); | |||
2035 | module_param_array(dma2, int, NULL, 0444); | 2035 | module_param_array(dma2, int, NULL, 0444); |
2036 | MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); | 2036 | MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); |
2037 | 2037 | ||
2038 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
2039 | |||
2040 | #ifdef CONFIG_PNP | 2038 | #ifdef CONFIG_PNP |
2041 | static int pnp_registered, pnpc_registered; | 2039 | static int pnp_registered, pnpc_registered; |
2042 | 2040 | ||
@@ -2237,7 +2235,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | |||
2237 | return snd_card_register(card); | 2235 | return snd_card_register(card); |
2238 | } | 2236 | } |
2239 | 2237 | ||
2240 | static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr) | 2238 | static int __devinit snd_es18xx_isa_match(struct device *pdev, unsigned int dev) |
2239 | { | ||
2240 | return enable[dev] && !is_isapnp_selected(dev); | ||
2241 | } | ||
2242 | |||
2243 | static int __devinit snd_es18xx_isa_probe1(int dev, struct device *devptr) | ||
2241 | { | 2244 | { |
2242 | struct snd_card *card; | 2245 | struct snd_card *card; |
2243 | int err; | 2246 | int err; |
@@ -2245,18 +2248,17 @@ static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *d | |||
2245 | card = snd_es18xx_card_new(dev); | 2248 | card = snd_es18xx_card_new(dev); |
2246 | if (! card) | 2249 | if (! card) |
2247 | return -ENOMEM; | 2250 | return -ENOMEM; |
2248 | snd_card_set_dev(card, &devptr->dev); | 2251 | snd_card_set_dev(card, devptr); |
2249 | if ((err = snd_audiodrive_probe(card, dev)) < 0) { | 2252 | if ((err = snd_audiodrive_probe(card, dev)) < 0) { |
2250 | snd_card_free(card); | 2253 | snd_card_free(card); |
2251 | return err; | 2254 | return err; |
2252 | } | 2255 | } |
2253 | platform_set_drvdata(devptr, card); | 2256 | dev_set_drvdata(devptr, card); |
2254 | return 0; | 2257 | return 0; |
2255 | } | 2258 | } |
2256 | 2259 | ||
2257 | static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev) | 2260 | static int __devinit snd_es18xx_isa_probe(struct device *pdev, unsigned int dev) |
2258 | { | 2261 | { |
2259 | int dev = pdev->id; | ||
2260 | int err; | 2262 | int err; |
2261 | static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; | 2263 | static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; |
2262 | static int possible_dmas[] = {1, 0, 3, 5, -1}; | 2264 | static int possible_dmas[] = {1, 0, 3, 5, -1}; |
@@ -2281,13 +2283,13 @@ static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev) | |||
2281 | } | 2283 | } |
2282 | 2284 | ||
2283 | if (port[dev] != SNDRV_AUTO_PORT) { | 2285 | if (port[dev] != SNDRV_AUTO_PORT) { |
2284 | return snd_es18xx_nonpnp_probe1(dev, pdev); | 2286 | return snd_es18xx_isa_probe1(dev, pdev); |
2285 | } else { | 2287 | } else { |
2286 | static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; | 2288 | static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; |
2287 | int i; | 2289 | int i; |
2288 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { | 2290 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { |
2289 | port[dev] = possible_ports[i]; | 2291 | port[dev] = possible_ports[i]; |
2290 | err = snd_es18xx_nonpnp_probe1(dev, pdev); | 2292 | err = snd_es18xx_isa_probe1(dev, pdev); |
2291 | if (! err) | 2293 | if (! err) |
2292 | return 0; | 2294 | return 0; |
2293 | } | 2295 | } |
@@ -2295,33 +2297,36 @@ static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev) | |||
2295 | } | 2297 | } |
2296 | } | 2298 | } |
2297 | 2299 | ||
2298 | static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr) | 2300 | static int __devexit snd_es18xx_isa_remove(struct device *devptr, |
2301 | unsigned int dev) | ||
2299 | { | 2302 | { |
2300 | snd_card_free(platform_get_drvdata(devptr)); | 2303 | snd_card_free(dev_get_drvdata(devptr)); |
2301 | platform_set_drvdata(devptr, NULL); | 2304 | dev_set_drvdata(devptr, NULL); |
2302 | return 0; | 2305 | return 0; |
2303 | } | 2306 | } |
2304 | 2307 | ||
2305 | #ifdef CONFIG_PM | 2308 | #ifdef CONFIG_PM |
2306 | static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state) | 2309 | static int snd_es18xx_isa_suspend(struct device *dev, unsigned int n, |
2310 | pm_message_t state) | ||
2307 | { | 2311 | { |
2308 | return snd_es18xx_suspend(platform_get_drvdata(dev), state); | 2312 | return snd_es18xx_suspend(dev_get_drvdata(dev), state); |
2309 | } | 2313 | } |
2310 | 2314 | ||
2311 | static int snd_es18xx_nonpnp_resume(struct platform_device *dev) | 2315 | static int snd_es18xx_isa_resume(struct device *dev, unsigned int n) |
2312 | { | 2316 | { |
2313 | return snd_es18xx_resume(platform_get_drvdata(dev)); | 2317 | return snd_es18xx_resume(dev_get_drvdata(dev)); |
2314 | } | 2318 | } |
2315 | #endif | 2319 | #endif |
2316 | 2320 | ||
2317 | #define ES18XX_DRIVER "snd_es18xx" | 2321 | #define ES18XX_DRIVER "snd_es18xx" |
2318 | 2322 | ||
2319 | static struct platform_driver snd_es18xx_nonpnp_driver = { | 2323 | static struct isa_driver snd_es18xx_isa_driver = { |
2320 | .probe = snd_es18xx_nonpnp_probe, | 2324 | .match = snd_es18xx_isa_match, |
2321 | .remove = __devexit_p(snd_es18xx_nonpnp_remove), | 2325 | .probe = snd_es18xx_isa_probe, |
2326 | .remove = __devexit_p(snd_es18xx_isa_remove), | ||
2322 | #ifdef CONFIG_PM | 2327 | #ifdef CONFIG_PM |
2323 | .suspend = snd_es18xx_nonpnp_suspend, | 2328 | .suspend = snd_es18xx_isa_suspend, |
2324 | .resume = snd_es18xx_nonpnp_resume, | 2329 | .resume = snd_es18xx_isa_resume, |
2325 | #endif | 2330 | #endif |
2326 | .driver = { | 2331 | .driver = { |
2327 | .name = ES18XX_DRIVER | 2332 | .name = ES18XX_DRIVER |
@@ -2330,8 +2335,6 @@ static struct platform_driver snd_es18xx_nonpnp_driver = { | |||
2330 | 2335 | ||
2331 | 2336 | ||
2332 | #ifdef CONFIG_PNP | 2337 | #ifdef CONFIG_PNP |
2333 | static unsigned int __devinitdata es18xx_pnp_devices; | ||
2334 | |||
2335 | static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev, | 2338 | static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev, |
2336 | const struct pnp_device_id *id) | 2339 | const struct pnp_device_id *id) |
2337 | { | 2340 | { |
@@ -2362,7 +2365,6 @@ static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev, | |||
2362 | } | 2365 | } |
2363 | pnp_set_drvdata(pdev, card); | 2366 | pnp_set_drvdata(pdev, card); |
2364 | dev++; | 2367 | dev++; |
2365 | es18xx_pnp_devices++; | ||
2366 | return 0; | 2368 | return 0; |
2367 | } | 2369 | } |
2368 | 2370 | ||
@@ -2424,7 +2426,6 @@ static int __devinit snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard, | |||
2424 | 2426 | ||
2425 | pnp_set_card_drvdata(pcard, card); | 2427 | pnp_set_card_drvdata(pcard, card); |
2426 | dev++; | 2428 | dev++; |
2427 | es18xx_pnp_devices++; | ||
2428 | return 0; | 2429 | return 0; |
2429 | } | 2430 | } |
2430 | 2431 | ||
@@ -2460,44 +2461,14 @@ static struct pnp_card_driver es18xx_pnpc_driver = { | |||
2460 | }; | 2461 | }; |
2461 | #endif /* CONFIG_PNP */ | 2462 | #endif /* CONFIG_PNP */ |
2462 | 2463 | ||
2463 | static void __init_or_module snd_es18xx_unregister_all(void) | ||
2464 | { | ||
2465 | int i; | ||
2466 | |||
2467 | #ifdef CONFIG_PNP | ||
2468 | if (pnpc_registered) | ||
2469 | pnp_unregister_card_driver(&es18xx_pnpc_driver); | ||
2470 | if (pnp_registered) | ||
2471 | pnp_unregister_driver(&es18xx_pnp_driver); | ||
2472 | #endif | ||
2473 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
2474 | platform_device_unregister(platform_devices[i]); | ||
2475 | platform_driver_unregister(&snd_es18xx_nonpnp_driver); | ||
2476 | } | ||
2477 | |||
2478 | static int __init alsa_card_es18xx_init(void) | 2464 | static int __init alsa_card_es18xx_init(void) |
2479 | { | 2465 | { |
2480 | int i, err, cards = 0; | 2466 | int err; |
2481 | 2467 | ||
2482 | if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0) | 2468 | err = isa_register_driver(&snd_es18xx_isa_driver, SNDRV_CARDS); |
2469 | if (err < 0) | ||
2483 | return err; | 2470 | return err; |
2484 | 2471 | ||
2485 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
2486 | struct platform_device *device; | ||
2487 | if (! enable[i] || is_isapnp_selected(i)) | ||
2488 | continue; | ||
2489 | device = platform_device_register_simple(ES18XX_DRIVER, | ||
2490 | i, NULL, 0); | ||
2491 | if (IS_ERR(device)) | ||
2492 | continue; | ||
2493 | if (!platform_get_drvdata(device)) { | ||
2494 | platform_device_unregister(device); | ||
2495 | continue; | ||
2496 | } | ||
2497 | platform_devices[i] = device; | ||
2498 | cards++; | ||
2499 | } | ||
2500 | |||
2501 | #ifdef CONFIG_PNP | 2472 | #ifdef CONFIG_PNP |
2502 | err = pnp_register_driver(&es18xx_pnp_driver); | 2473 | err = pnp_register_driver(&es18xx_pnp_driver); |
2503 | if (!err) | 2474 | if (!err) |
@@ -2505,22 +2476,19 @@ static int __init alsa_card_es18xx_init(void) | |||
2505 | err = pnp_register_card_driver(&es18xx_pnpc_driver); | 2476 | err = pnp_register_card_driver(&es18xx_pnpc_driver); |
2506 | if (!err) | 2477 | if (!err) |
2507 | pnpc_registered = 1; | 2478 | pnpc_registered = 1; |
2508 | cards += es18xx_pnp_devices; | ||
2509 | #endif | ||
2510 | |||
2511 | if(!cards) { | ||
2512 | #ifdef MODULE | ||
2513 | snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); | ||
2514 | #endif | 2479 | #endif |
2515 | snd_es18xx_unregister_all(); | ||
2516 | return -ENODEV; | ||
2517 | } | ||
2518 | return 0; | 2480 | return 0; |
2519 | } | 2481 | } |
2520 | 2482 | ||
2521 | static void __exit alsa_card_es18xx_exit(void) | 2483 | static void __exit alsa_card_es18xx_exit(void) |
2522 | { | 2484 | { |
2523 | snd_es18xx_unregister_all(); | 2485 | #ifdef CONFIG_PNP |
2486 | if (pnpc_registered) | ||
2487 | pnp_unregister_card_driver(&es18xx_pnpc_driver); | ||
2488 | if (pnp_registered) | ||
2489 | pnp_unregister_driver(&es18xx_pnp_driver); | ||
2490 | #endif | ||
2491 | isa_unregister_driver(&snd_es18xx_isa_driver); | ||
2524 | } | 2492 | } |
2525 | 2493 | ||
2526 | module_init(alsa_card_es18xx_init) | 2494 | module_init(alsa_card_es18xx_init) |