diff options
Diffstat (limited to 'sound/isa/sscape.c')
-rw-r--r-- | sound/isa/sscape.c | 116 |
1 files changed, 38 insertions, 78 deletions
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index b1f25823c652..369de44a6904 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <sound/driver.h> | 24 | #include <sound/driver.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/isa.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/pnp.h> | 29 | #include <linux/pnp.h> |
30 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
@@ -68,8 +68,6 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver."); | |||
68 | module_param_array(dma, int, NULL, 0444); | 68 | module_param_array(dma, int, NULL, 0444); |
69 | MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); | 69 | MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); |
70 | 70 | ||
71 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
72 | |||
73 | #ifdef CONFIG_PNP | 71 | #ifdef CONFIG_PNP |
74 | static int pnp_registered; | 72 | static int pnp_registered; |
75 | static struct pnp_card_device_id sscape_pnpids[] = { | 73 | static struct pnp_card_device_id sscape_pnpids[] = { |
@@ -1254,9 +1252,27 @@ static int __devinit create_sscape(int dev, struct snd_card **rcardp) | |||
1254 | } | 1252 | } |
1255 | 1253 | ||
1256 | 1254 | ||
1257 | static int __devinit snd_sscape_probe(struct platform_device *pdev) | 1255 | static int __devinit snd_sscape_match(struct device *pdev, unsigned int i) |
1256 | { | ||
1257 | /* | ||
1258 | * Make sure we were given ALL of the other parameters. | ||
1259 | */ | ||
1260 | if (port[i] == SNDRV_AUTO_PORT) | ||
1261 | return 0; | ||
1262 | |||
1263 | if (irq[i] == SNDRV_AUTO_IRQ || | ||
1264 | mpu_irq[i] == SNDRV_AUTO_IRQ || | ||
1265 | dma[i] == SNDRV_AUTO_DMA) { | ||
1266 | printk(KERN_INFO | ||
1267 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); | ||
1268 | return 0; | ||
1269 | } | ||
1270 | |||
1271 | return 1; | ||
1272 | } | ||
1273 | |||
1274 | static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) | ||
1258 | { | 1275 | { |
1259 | int dev = pdev->id; | ||
1260 | struct snd_card *card; | 1276 | struct snd_card *card; |
1261 | int ret; | 1277 | int ret; |
1262 | 1278 | ||
@@ -1264,25 +1280,26 @@ static int __devinit snd_sscape_probe(struct platform_device *pdev) | |||
1264 | ret = create_sscape(dev, &card); | 1280 | ret = create_sscape(dev, &card); |
1265 | if (ret < 0) | 1281 | if (ret < 0) |
1266 | return ret; | 1282 | return ret; |
1267 | snd_card_set_dev(card, &pdev->dev); | 1283 | snd_card_set_dev(card, pdev); |
1268 | if ((ret = snd_card_register(card)) < 0) { | 1284 | if ((ret = snd_card_register(card)) < 0) { |
1269 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1285 | printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1270 | return ret; | 1286 | return ret; |
1271 | } | 1287 | } |
1272 | platform_set_drvdata(pdev, card); | 1288 | dev_set_drvdata(pdev, card); |
1273 | return 0; | 1289 | return 0; |
1274 | } | 1290 | } |
1275 | 1291 | ||
1276 | static int __devexit snd_sscape_remove(struct platform_device *devptr) | 1292 | static int __devexit snd_sscape_remove(struct device *devptr, unsigned int dev) |
1277 | { | 1293 | { |
1278 | snd_card_free(platform_get_drvdata(devptr)); | 1294 | snd_card_free(dev_get_drvdata(devptr)); |
1279 | platform_set_drvdata(devptr, NULL); | 1295 | dev_set_drvdata(devptr, NULL); |
1280 | return 0; | 1296 | return 0; |
1281 | } | 1297 | } |
1282 | 1298 | ||
1283 | #define SSCAPE_DRIVER "snd_sscape" | 1299 | #define SSCAPE_DRIVER "snd_sscape" |
1284 | 1300 | ||
1285 | static struct platform_driver snd_sscape_driver = { | 1301 | static struct isa_driver snd_sscape_driver = { |
1302 | .match = snd_sscape_match, | ||
1286 | .probe = snd_sscape_probe, | 1303 | .probe = snd_sscape_probe, |
1287 | .remove = __devexit_p(snd_sscape_remove), | 1304 | .remove = __devexit_p(snd_sscape_remove), |
1288 | /* FIXME: suspend/resume */ | 1305 | /* FIXME: suspend/resume */ |
@@ -1386,72 +1403,6 @@ static struct pnp_card_driver sscape_pnpc_driver = { | |||
1386 | 1403 | ||
1387 | #endif /* CONFIG_PNP */ | 1404 | #endif /* CONFIG_PNP */ |
1388 | 1405 | ||
1389 | static void __init_or_module sscape_unregister_all(void) | ||
1390 | { | ||
1391 | int i; | ||
1392 | |||
1393 | #ifdef CONFIG_PNP | ||
1394 | if (pnp_registered) | ||
1395 | pnp_unregister_card_driver(&sscape_pnpc_driver); | ||
1396 | #endif | ||
1397 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
1398 | platform_device_unregister(platform_devices[i]); | ||
1399 | platform_driver_unregister(&snd_sscape_driver); | ||
1400 | } | ||
1401 | |||
1402 | static int __init sscape_manual_probe(void) | ||
1403 | { | ||
1404 | struct platform_device *device; | ||
1405 | int i, ret; | ||
1406 | |||
1407 | ret = platform_driver_register(&snd_sscape_driver); | ||
1408 | if (ret < 0) | ||
1409 | return ret; | ||
1410 | |||
1411 | for (i = 0; i < SNDRV_CARDS; ++i) { | ||
1412 | /* | ||
1413 | * We do NOT probe for ports. | ||
1414 | * If we're not given a port number for this | ||
1415 | * card then we completely ignore this line | ||
1416 | * of parameters. | ||
1417 | */ | ||
1418 | if (port[i] == SNDRV_AUTO_PORT) | ||
1419 | continue; | ||
1420 | |||
1421 | /* | ||
1422 | * Make sure we were given ALL of the other parameters. | ||
1423 | */ | ||
1424 | if (irq[i] == SNDRV_AUTO_IRQ || | ||
1425 | mpu_irq[i] == SNDRV_AUTO_IRQ || | ||
1426 | dma[i] == SNDRV_AUTO_DMA) { | ||
1427 | printk(KERN_INFO | ||
1428 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); | ||
1429 | sscape_unregister_all(); | ||
1430 | return -ENXIO; | ||
1431 | } | ||
1432 | |||
1433 | /* | ||
1434 | * This cards looks OK ... | ||
1435 | */ | ||
1436 | device = platform_device_register_simple(SSCAPE_DRIVER, | ||
1437 | i, NULL, 0); | ||
1438 | if (IS_ERR(device)) | ||
1439 | continue; | ||
1440 | if (!platform_get_drvdata(device)) { | ||
1441 | platform_device_unregister(device); | ||
1442 | continue; | ||
1443 | } | ||
1444 | platform_devices[i] = device; | ||
1445 | } | ||
1446 | return 0; | ||
1447 | } | ||
1448 | |||
1449 | static void sscape_exit(void) | ||
1450 | { | ||
1451 | sscape_unregister_all(); | ||
1452 | } | ||
1453 | |||
1454 | |||
1455 | static int __init sscape_init(void) | 1406 | static int __init sscape_init(void) |
1456 | { | 1407 | { |
1457 | int ret; | 1408 | int ret; |
@@ -1462,7 +1413,7 @@ static int __init sscape_init(void) | |||
1462 | * of allocating cards, because the operator is | 1413 | * of allocating cards, because the operator is |
1463 | * S-P-E-L-L-I-N-G it out for us... | 1414 | * S-P-E-L-L-I-N-G it out for us... |
1464 | */ | 1415 | */ |
1465 | ret = sscape_manual_probe(); | 1416 | ret = isa_register_driver(&snd_sscape_driver, SNDRV_CARDS); |
1466 | if (ret < 0) | 1417 | if (ret < 0) |
1467 | return ret; | 1418 | return ret; |
1468 | #ifdef CONFIG_PNP | 1419 | #ifdef CONFIG_PNP |
@@ -1472,5 +1423,14 @@ static int __init sscape_init(void) | |||
1472 | return 0; | 1423 | return 0; |
1473 | } | 1424 | } |
1474 | 1425 | ||
1426 | static void __exit sscape_exit(void) | ||
1427 | { | ||
1428 | #ifdef CONFIG_PNP | ||
1429 | if (pnp_registered) | ||
1430 | pnp_unregister_card_driver(&sscape_pnpc_driver); | ||
1431 | #endif | ||
1432 | isa_unregister_driver(&snd_sscape_driver); | ||
1433 | } | ||
1434 | |||
1475 | module_init(sscape_init); | 1435 | module_init(sscape_init); |
1476 | module_exit(sscape_exit); | 1436 | module_exit(sscape_exit); |