From 5e2da20648e39a0e3cb33861499b686a6fe38112 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 14:36:44 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA GUS Remove xxx_t typedefs from the ISA GUS drivers. Signed-off-by: Takashi Iwai --- sound/isa/gus/interwave.c | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'sound/isa/gus/interwave.c') diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index f703a9f4257c..f2e9c5073548 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -112,9 +112,9 @@ MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); struct snd_interwave { int irq; - snd_card_t *card; - snd_gus_card_t *gus; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus; + struct snd_cs4231 *cs4231; #ifdef SNDRV_STB struct resource *i2c_res; #endif @@ -128,7 +128,7 @@ struct snd_interwave { #endif }; -static snd_card_t *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -160,7 +160,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_interwave_pnpids); #ifdef SNDRV_STB -static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) +static void snd_interwave_i2c_setlines(struct snd_i2c_bus *bus, int ctrl, int data) { unsigned long port = bus->private_value; @@ -171,7 +171,7 @@ static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) udelay(10); } -static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) +static int snd_interwave_i2c_getclockline(struct snd_i2c_bus *bus) { unsigned long port = bus->private_value; unsigned char res; @@ -183,7 +183,7 @@ static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) return res; } -static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) +static int snd_interwave_i2c_getdataline(struct snd_i2c_bus *bus, int ack) { unsigned long port = bus->private_value; unsigned char res; @@ -197,19 +197,19 @@ static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) return res; } -static snd_i2c_bit_ops_t snd_interwave_i2c_bit_ops = { +static struct snd_i2c_bit_ops snd_interwave_i2c_bit_ops = { .setlines = snd_interwave_i2c_setlines, .getclock = snd_interwave_i2c_getclockline, .getdata = snd_interwave_i2c_getdataline, }; static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, - snd_gus_card_t * gus, int dev, - snd_i2c_bus_t **rbus) + struct snd_gus_card * gus, int dev, + struct snd_i2c_bus **rbus) { unsigned long port; - snd_i2c_bus_t *bus; - snd_card_t *card = iwcard->card; + struct snd_i2c_bus *bus; + struct snd_card *card = iwcard->card; char name[32]; int err; @@ -246,10 +246,10 @@ static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, #endif static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, - snd_gus_card_t * gus, + struct snd_gus_card * gus, int dev #ifdef SNDRV_STB - , snd_i2c_bus_t **rbus + , struct snd_i2c_bus **rbus #endif ) { @@ -314,7 +314,7 @@ static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs return IRQ_RETVAL(handled); } -static void __devinit snd_interwave_reset(snd_gus_card_t * gus) +static void __devinit snd_interwave_reset(struct snd_gus_card * gus) { snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00); udelay(160); @@ -322,7 +322,7 @@ static void __devinit snd_interwave_reset(snd_gus_card_t * gus) udelay(160); } -static void __devinit snd_interwave_bank_sizes(snd_gus_card_t * gus, int *sizes) +static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *sizes) { unsigned int idx; unsigned int local; @@ -371,7 +371,7 @@ struct rom_hdr { /* 511 */ unsigned char csum; }; -static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) +static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus) { static unsigned int lmc[13] = { @@ -470,7 +470,7 @@ static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) snd_interwave_reset(gus); } -static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) +static void __devinit snd_interwave_init(int dev, struct snd_gus_card * gus) { unsigned long flags; @@ -492,17 +492,17 @@ static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) } -static snd_kcontrol_new_t snd_interwave_controls[] = { +static struct snd_kcontrol_new snd_interwave_controls[] = { CS4231_DOUBLE("Master Playback Switch", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("Master Playback Volume", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 0, 0, 31, 1), CS4231_DOUBLE("Mic Playback Switch", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Mic Playback Volume", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 0, 0, 31, 1) }; -static int __devinit snd_interwave_mixer(cs4231_t *chip) +static int __devinit snd_interwave_mixer(struct snd_cs4231 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; unsigned int idx; int err; @@ -631,7 +631,7 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard, } #endif /* CONFIG_PNP */ -static void snd_interwave_free(snd_card_t *card) +static void snd_interwave_free(struct snd_card *card) { struct snd_interwave *iwcard = (struct snd_interwave *)card->private_data; @@ -650,14 +650,14 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_interwave *iwcard; - cs4231_t *cs4231; - snd_gus_card_t *gus; + struct snd_cs4231 *cs4231; + struct snd_gus_card *gus; #ifdef SNDRV_STB - snd_i2c_bus_t *i2c_bus; + struct snd_i2c_bus *i2c_bus; #endif - snd_pcm_t *pcm; + struct snd_pcm *pcm; char *str; int err; @@ -761,7 +761,7 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, #ifdef SNDRV_STB { - snd_ctl_elem_id_t id1, id2; + struct snd_ctl_elem_id id1, id2; memset(&id1, 0, sizeof(id1)); memset(&id2, 0, sizeof(id2)); id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -863,7 +863,7 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); -- cgit v1.2.3 From 654aa661779703d3b22ba04a83ddeb1a0dd7a09a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:13:43 +0100 Subject: [ALSA] gus - Use platform_device Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/gus/gusclassic.c | 116 +++++++++++------- sound/isa/gus/gusextreme.c | 116 ++++++++++-------- sound/isa/gus/gusmax.c | 117 +++++++++++------- sound/isa/gus/interwave.c | 292 ++++++++++++++++++++++++--------------------- 4 files changed, 367 insertions(+), 274 deletions(-) (limited to 'sound/isa/gus/interwave.c') diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 6db484f71367..57beb74f5b9d 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -20,14 +20,15 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -70,7 +71,6 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); -static struct snd_card *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusclassic: " @@ -101,20 +101,19 @@ static void __init snd_gusclassic_init(int dev, struct snd_gus_card * gus) gus->joystick_dac = joystick_dac[dev]; } -static int __init snd_gusclassic_probe(int dev) +static int __init snd_gusclassic_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2; struct snd_card *card; - struct snd_gusclassic *guscard; struct snd_gus_card *gus = NULL; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - guscard = (struct snd_gusclassic *)card->private_data; if (pcm_channels[dev] < 2) pcm_channels[dev] = 2; @@ -143,12 +142,31 @@ static int __init snd_gusclassic_probe(int dev) } } - - if ((err = snd_gus_create(card, - port[dev], - xirq, xdma1, xdma2, - 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) + if (port[dev] != SNDRV_AUTO_PORT) { + err = snd_gus_create(card, + port[dev], + xirq, xdma1, xdma2, + 0, channels[dev], pcm_channels[dev], + 0, &gus); + } else { + /* auto-probe legacy ports */ + static unsigned long possible_ports[] = { + 0x220, 0x230, 0x240, 0x250, 0x260, + }; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_gus_create(card, + possible_ports[i], + xirq, xdma1, xdma2, + 0, channels[dev], pcm_channels[dev], + 0, &gus); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + } + if (err < 0) goto _err; if ((err = snd_gusclassic_detect(gus)) < 0) @@ -178,13 +196,12 @@ static int __init snd_gusclassic_probe(int dev) if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_gusclassic_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -192,53 +209,60 @@ static int __init snd_gusclassic_probe(int dev) return err; } -static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) +static int snd_gusclassic_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusclassic_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define GUSCLASSIC_DRIVER "snd_gusclassic" + +static struct platform_driver snd_gusclassic_driver = { + .probe = snd_gusclassic_probe, + .remove = snd_gusclassic_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSCLASSIC_DRIVER + }, +}; + static int __init alsa_card_gusclassic_init(void) { - static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusclassic_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusclassic_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusclassic_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSCLASSIC_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS Classic soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_gusclassic_driver); + return err; } static void __exit alsa_card_gusclassic_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_gusclassic_cards[idx]); + platform_driver_unregister(&snd_gusclassic_driver); } module_init(alsa_card_gusclassic_init) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 9be59d501333..6fad9734a853 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -20,11 +20,13 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include #include @@ -85,7 +87,6 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); -static struct snd_card *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusextreme: " @@ -166,15 +167,15 @@ static int __init snd_gusextreme_mixer(struct snd_es1688 *chip) return 0; } -static int __init snd_gusextreme_probe(int dev) +static int __init snd_gusextreme_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; static int possible_ess_dmas[] = {1, 3, 0, -1}; static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; struct snd_card *card; - struct snd_gusextreme *acard; struct snd_gus_card *gus; struct snd_es1688 *es1688; struct snd_opl3 *opl3; @@ -183,7 +184,6 @@ static int __init snd_gusextreme_probe(int dev) card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - acard = (struct snd_gusextreme *)card->private_data; xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { @@ -223,10 +223,29 @@ static int __init snd_gusextreme_probe(int dev) } } - if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], - xess_irq, xmpu_irq, xess_dma, - ES1688_HW_1688, &es1688)) < 0) + if (port[dev] != SNDRV_AUTO_PORT) { + err = snd_es1688_create(card, port[dev], mpu_port[dev], + xess_irq, xmpu_irq, xess_dma, + ES1688_HW_1688, &es1688); + } else { + /* auto-probe legacy ports */ + static unsigned long possible_ports[] = {0x220, 0x240, 0x260}; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_es1688_create(card, + possible_ports[i], + mpu_port[dev], + xess_irq, xmpu_irq, xess_dma, + ES1688_HW_1688, &es1688); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + } + if (err < 0) goto out; + if (gf1_port[dev] < 0) gf1_port[dev] = port[dev] + 0x20; if ((err = snd_gus_create(card, @@ -287,13 +306,12 @@ static int __init snd_gusextreme_probe(int dev) sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto out; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto out; - snd_gusextreme_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; out: @@ -301,60 +319,60 @@ static int __init snd_gusextreme_probe(int dev) return err; } -static int __init snd_gusextreme_legacy_auto_probe(unsigned long xport) +static int snd_gusextreme_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusextreme_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define GUSEXTREME_DRIVER "snd_gusextreme" + +static struct platform_driver snd_gusextreme_driver = { + .probe = snd_gusextreme_probe, + .remove = snd_gusextreme_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSEXTREME_DRIVER + }, +}; + static int __init alsa_card_gusextreme_init(void) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusextreme_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusextreme_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusextreme_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSEXTREME_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_gusextreme_driver); + return err; } static void __exit alsa_card_gusextreme_exit(void) { - int idx; - struct snd_card *card; - struct snd_gusextreme *acard; - - for (idx = 0; idx < SNDRV_CARDS; idx++) { - card = snd_gusextreme_cards[idx]; - if (card == NULL) - continue; - acard = (struct snd_gusextreme *)card->private_data; - snd_card_free(snd_gusextreme_cards[idx]); - } + platform_driver_unregister(&snd_gusextreme_driver); } module_init(alsa_card_gusextreme_init) diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 63311cdb4a1a..d1b70ee9b039 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -20,15 +20,16 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -80,8 +81,6 @@ struct snd_gusmax { unsigned short pcm_status_reg; }; -static struct snd_card *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "gusmax: " static int __init snd_gusmax_detect(struct snd_gus_card * gus) @@ -203,8 +202,9 @@ static void snd_gusmax_free(struct snd_card *card) free_irq(maxcard->irq, (void *)maxcard); } -static int __init snd_gusmax_probe(int dev) +static int __init snd_gusmax_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; @@ -247,12 +247,32 @@ static int __init snd_gusmax_probe(int dev) } } - if ((err = snd_gus_create(card, - port[dev], - -xirq, xdma1, xdma2, - 0, channels[dev], - pcm_channels[dev], - 0, &gus)) < 0) + if (port[dev] != SNDRV_AUTO_PORT) { + err = snd_gus_create(card, + port[dev], + -xirq, xdma1, xdma2, + 0, channels[dev], + pcm_channels[dev], + 0, &gus); + } else { + static unsigned long possible_ports[] = { + 0x220, 0x230, 0x240, 0x250, 0x260 + }; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_gus_create(card, + possible_ports[i], + -xirq, xdma1, xdma2, + 0, channels[dev], + pcm_channels[dev], + 0, &gus); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + } + if (err < 0) goto _err; if ((err = snd_gusmax_detect(gus)) < 0) @@ -310,15 +330,15 @@ static int __init snd_gusmax_probe(int dev) if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; maxcard->gus = gus; maxcard->cs4231 = cs4231; - snd_gusmax_cards[dev] = card; + + platform_set_drvdata(pdev, card); return 0; _err: @@ -326,53 +346,60 @@ static int __init snd_gusmax_probe(int dev) return err; } -static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) +static int snd_gusmax_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusmax_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define GUSMAX_DRIVER "snd_gusmax" + +static struct platform_driver snd_gusmax_driver = { + .probe = snd_gusmax_probe, + .remove = snd_gusmax_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSMAX_DRIVER + }, +}; + static int __init alsa_card_gusmax_init(void) { - static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusmax_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusmax_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusmax_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSMAX_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS MAX soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_gusmax_driver); + return err; } static void __exit alsa_card_gusmax_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_gusmax_cards[idx]); + platform_driver_unregister(&snd_gusmax_driver); } module_init(alsa_card_gusmax_init) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index f2e9c5073548..67a5f7402453 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -23,19 +23,20 @@ */ #include -#include -#include #include +#include +#include +#include #include #include #include +#include #include #include #include #ifdef SNDRV_STB #include #endif -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -75,8 +76,12 @@ static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; #ifdef SNDRV_STB #define PFX "interwave-stb: " +#define INTERWAVE_DRIVER "snd_interwave_stb" +#define INTERWAVE_PNP_DRIVER "interwave-stb" #else #define PFX "interwave: " +#define INTERWAVE_DRIVER "snd_interwave" +#define INTERWAVE_PNP_DRIVER "interwave" #endif module_param_array(index, int, NULL, 0444); @@ -128,7 +133,6 @@ struct snd_interwave { #endif }; -static struct snd_card *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -633,7 +637,7 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard, static void snd_interwave_free(struct snd_card *card) { - struct snd_interwave *iwcard = (struct snd_interwave *)card->private_data; + struct snd_interwave *iwcard = card->private_data; if (iwcard == NULL) return; @@ -644,14 +648,26 @@ static void snd_interwave_free(struct snd_card *card) free_irq(iwcard->irq, (void *)iwcard); } -static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_interwave_card_new(int dev) { - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; - int xirq, xdma1, xdma2; struct snd_card *card; struct snd_interwave *iwcard; + + card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_interwave)); + if (card == NULL) + return NULL; + iwcard = card->private_data; + iwcard->card = card; + iwcard->irq = -1; + card->private_free = snd_interwave_free; + return card; +} + +static int __devinit snd_interwave_probe(struct snd_card *card, int dev) +{ + int xirq, xdma1, xdma2; + struct snd_interwave *iwcard = card->private_data; struct snd_cs4231 *cs4231; struct snd_gus_card *gus; #ifdef SNDRV_STB @@ -661,59 +677,23 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, char *str; int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_interwave)); - if (card == NULL) - return -ENOMEM; - iwcard = (struct snd_interwave *)card->private_data; - iwcard->card = card; - iwcard->irq = -1; - card->private_free = snd_interwave_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0) - goto _err; - snd_card_set_dev(card, &pcard->card->dev); - } -#endif xirq = irq[dev]; - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; - } - } xdma1 = dma1[dev]; - if (xdma1 == SNDRV_AUTO_DMA) { - if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); - err = -EBUSY; - goto _err; - } - } xdma2 = dma2[dev]; - if (xdma2 == SNDRV_AUTO_DMA) { - if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); - err = -EBUSY; - goto _err; - } - } if ((err = snd_gus_create(card, port[dev], -xirq, xdma1, xdma2, 0, 32, pcm_channels[dev], effect[dev], &gus)) < 0) - goto _err; + return err; if ((err = snd_interwave_detect(iwcard, gus, dev #ifdef SNDRV_STB , &i2c_bus #endif )) < 0) - goto _err; + return err; iwcard->gus_status_reg = gus->gf1.reg_irqstat; iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; @@ -721,12 +701,12 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, snd_interwave_init(dev, gus); snd_interwave_detect_memory(gus); if ((err = snd_gus_initialize(gus)) < 0) - goto _err; + return err; - if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { + if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, + "InterWave", iwcard)) { snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); - err = -EBUSY; - goto _err; + return -EBUSY; } iwcard->irq = xirq; @@ -738,26 +718,26 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, &cs4231)) < 0) - goto _err; + return err; if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) - goto _err; + return err; sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); strcat(pcm->name, " (codec)"); if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) - goto _err; + return err; if ((err = snd_cs4231_mixer(cs4231)) < 0) - goto _err; + return err; if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) - goto _err; + return err; } if ((err = snd_interwave_mixer(cs4231)) < 0) - goto _err; + return err; #ifdef SNDRV_STB { @@ -769,19 +749,19 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, strcpy(id2.name, id1.name); id2.index = 1; if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - goto _err; + return err; strcpy(id1.name, "Master Playback Volume"); strcpy(id2.name, id1.name); if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - goto _err; + return err; if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) - goto _err; + return err; } #endif gus->uart_enable = midi[dev]; if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) - goto _err; + return err; #ifndef SNDRV_STB str = "AMD InterWave"; @@ -800,121 +780,171 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - if ((err = snd_card_register(card)) < 0) - goto _err; + return err; iwcard->cs4231 = cs4231; iwcard->gus = gus; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_interwave_legacy[dev++] = card; return 0; +} - _err: - snd_card_free(card); - return err; +static int __init snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card *card; + int err; + + card = snd_interwave_card_new(dev); + if (! card) + return -ENOMEM; + + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_interwave_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(devptr, card); + return 0; } -static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) +static int __init snd_interwave_nonpnp_probe(struct platform_device *pdev) { - static int dev; - int res; + int dev = pdev->id; + int err; + static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; + static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) - continue; -#endif - port[dev] = xport; - res = snd_interwave_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma1[dev] == SNDRV_AUTO_DMA) { + if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + return -EBUSY; + } + } + if (dma2[dev] == SNDRV_AUTO_DMA) { + if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) + return snd_interwave_nonpnp_probe1(dev, pdev); + else { + static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + port[dev] = possible_ports[i]; + err = snd_interwave_nonpnp_probe1(dev, pdev); + if (! err) + return 0; + } + return err; } - return -ENODEV; } +static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +static struct platform_driver snd_interwave_driver = { + .probe = snd_interwave_nonpnp_probe, + .remove = __devexit_p(snd_interwave_nonpnp_remove), + /* FIXME: suspend,resume */ + .driver = { + .name = INTERWAVE_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_interwave_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - - return -ENODEV; + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_interwave_card_new(dev); + if (! card) + return -ENOMEM; + + if ((res = snd_interwave_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_interwave_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver interwave_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, - .name = "interwave", + .name = INTERWAVE_PNP_DRIVER, .id_table = snd_interwave_pnpids, .probe = snd_interwave_pnp_detect, .remove = __devexit_p(snd_interwave_pnp_remove), + /* FIXME: suspend,resume */ }; #endif /* CONFIG_PNP */ static int __init alsa_card_interwave_init(void) { - int cards = 0, i; - static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; + if ((err = platform_driver_register(&snd_interwave_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (!snd_interwave_probe(dev, NULL, NULL)) { - cards++; - continue; + device = platform_device_register_simple(INTERWAVE_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_interwave_driver); + return err; } -#ifdef MODULE - printk(KERN_ERR "InterWave soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); -#endif + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_interwave_probe_legacy_port); - if (i > 0) - cards += i; -#ifdef CONFIG_PNP + /* ISA PnP cards */ i = pnp_register_card_driver(&interwave_pnpc_driver); if (i > 0) cards += i; -#endif if (!cards) { -#ifdef CONFIG_PNP pnp_unregister_card_driver(&interwave_pnpc_driver); -#endif + platform_driver_unregister(&snd_interwave_driver); #ifdef MODULE printk(KERN_ERR "InterWave soundcard not found or device busy\n"); #endif @@ -925,14 +955,8 @@ static int __init alsa_card_interwave_init(void) static void __exit alsa_card_interwave_exit(void) { - int dev; - -#ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&interwave_pnpc_driver); -#endif - for (dev = 0; dev < SNDRV_CARDS; dev++) - snd_card_free(snd_interwave_legacy[dev]); + platform_driver_unregister(&snd_interwave_driver); } module_init(alsa_card_interwave_init) -- cgit v1.2.3 From f7a9275d949cb0bf1f259a1546e52a0bf518151c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 7 Dec 2005 09:13:42 +0100 Subject: [ALSA] unregister platform devices Call platform_device_unregister() for all platform devices that we've registered. Signed-off-by: Clemens Ladisch --- sound/arm/sa11xx-uda1341.c | 6 +++-- sound/drivers/dummy.c | 16 ++++++++++-- sound/drivers/mpu401/mpu401.c | 21 +++++++++++----- sound/drivers/mtpav.c | 4 ++- sound/drivers/serial-u16550.c | 16 ++++++++++-- sound/drivers/virmidi.c | 16 ++++++++++-- sound/isa/ad1848/ad1848.c | 16 ++++++++++-- sound/isa/cmi8330.c | 34 +++++++++++++++++++------ sound/isa/cs423x/cs4231.c | 16 ++++++++++-- sound/isa/cs423x/cs4236.c | 51 +++++++++++++++++++++++++++----------- sound/isa/es1688/es1688.c | 16 ++++++++++-- sound/isa/es18xx.c | 34 +++++++++++++++++++------ sound/isa/gus/gusclassic.c | 16 ++++++++++-- sound/isa/gus/gusextreme.c | 16 ++++++++++-- sound/isa/gus/gusmax.c | 16 ++++++++++-- sound/isa/gus/interwave.c | 34 +++++++++++++++++++------ sound/isa/opl3sa2.c | 43 ++++++++++++++++++++++++-------- sound/isa/opti9xx/opti92x-ad1848.c | 9 +++++-- sound/isa/sb/sb16.c | 42 ++++++++++++++++++++++--------- sound/isa/sb/sb8.c | 16 ++++++++++-- sound/isa/sgalaxy.c | 16 ++++++++++-- sound/isa/sscape.c | 33 ++++++++++++++++++------ sound/isa/wavefront/wavefront.c | 35 ++++++++++++++++++++------ sound/ppc/powermac.c | 4 ++- 24 files changed, 415 insertions(+), 111 deletions(-) (limited to 'sound/isa/gus/interwave.c') diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 3c342c1a7c80..13057d92f08a 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.26 2005/11/17 17:19:50 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.27 2005/12/07 09:13:42 cladisch Exp $ */ /*************************************************************************************************** * @@ -155,6 +155,8 @@ static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .mask = 0, }; +static struct platform_device *device; + /* }}} */ /* {{{ Clock and sample rate stuff */ @@ -976,7 +978,6 @@ static struct platform_driver sa11xx_uda1341_driver = { static int __init sa11xx_uda1341_init(void) { int err; - struct platform_device *device; if (!machine_is_h3xxx()) return -ENODEV; @@ -992,6 +993,7 @@ static int __init sa11xx_uda1341_init(void) static void __exit sa11xx_uda1341_exit(void) { + platform_device_unregister(device); platform_driver_unregister(&sa11xx_uda1341_driver); } diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 186117571745..96d207051628 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -144,6 +144,8 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver."); //module_param_array(midi_devs, int, NULL, 0444); //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define MIXER_ADDR_MASTER 0 #define MIXER_ADDR_LINE 1 #define MIXER_ADDR_MIC 2 @@ -634,6 +636,15 @@ static struct platform_driver snd_dummy_driver = { }, }; +static void __init_or_module snd_dummy_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_dummy_driver); +} + static int __init alsa_card_dummy_init(void) { int i, cards, err; @@ -650,6 +661,7 @@ static int __init alsa_card_dummy_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -662,13 +674,13 @@ static int __init alsa_card_dummy_init(void) return 0; errout: - platform_driver_unregister(&snd_dummy_driver); + snd_dummy_unregister_all(); return err; } static void __exit alsa_card_dummy_exit(void) { - platform_driver_unregister(&snd_dummy_driver); + snd_dummy_unregister_all(); } module_init(alsa_card_dummy_init) diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index ec817a86d3dd..915589a402ab 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -58,6 +58,7 @@ MODULE_PARM_DESC(port, "Port # for MPU-401 device."); module_param_array(irq, int, NULL, 0444); MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); +static struct platform_device *platform_devices[SNDRV_CARDS]; static int pnp_registered = 0; static int snd_mpu401_create(int dev, struct snd_card **rcard) @@ -220,6 +221,17 @@ static struct pnp_driver snd_mpu401_pnp_driver = { static struct pnp_driver snd_mpu401_pnp_driver; #endif +static void __init_or_module snd_mpu401_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_driver(&snd_mpu401_pnp_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_mpu401_driver); +} + static int __init alsa_card_mpu401_init(void) { int i, err, devices; @@ -240,6 +252,7 @@ static int __init alsa_card_mpu401_init(void) err = PTR_ERR(device); goto errout; } + platform_devices[i] = device; devices++; } if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) { @@ -257,17 +270,13 @@ static int __init alsa_card_mpu401_init(void) return 0; errout: - if (pnp_registered) - pnp_unregister_driver(&snd_mpu401_pnp_driver); - platform_driver_unregister(&snd_mpu401_driver); + snd_mpu401_unregister_all(); return err; } static void __exit alsa_card_mpu401_exit(void) { - if (pnp_registered) - pnp_unregister_driver(&snd_mpu401_pnp_driver); - platform_driver_unregister(&snd_mpu401_driver); + snd_mpu401_unregister_all(); } module_init(alsa_card_mpu401_init) diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index d9c4e224fa5f..b7a0b42813e1 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -95,6 +95,8 @@ MODULE_PARM_DESC(irq, "Parallel IRQ # for MotuMTPAV MIDI."); module_param(hwports, int, 0444); MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI."); +static struct platform_device *device; + /* * defines */ @@ -763,7 +765,6 @@ static struct platform_driver snd_mtpav_driver = { static int __init alsa_card_mtpav_init(void) { int err; - struct platform_device *device; if ((err = platform_driver_register(&snd_mtpav_driver)) < 0) return err; @@ -778,6 +779,7 @@ static int __init alsa_card_mtpav_init(void) static void __exit alsa_card_mtpav_exit(void) { + platform_device_unregister(device); platform_driver_unregister(&snd_mtpav_driver); } diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 3381a43c592e..29676d800cae 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -168,6 +168,8 @@ typedef struct _snd_uart16550 { } snd_uart16550_t; +static struct platform_device *devices[SNDRV_CARDS]; + static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) { if (! uart->timer_running) { @@ -970,6 +972,15 @@ static struct platform_driver snd_serial_driver = { }, }; +static void __init_or_module snd_serial_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_serial_driver); +} + static int __init alsa_card_serial_init(void) { int i, cards, err; @@ -986,6 +997,7 @@ static int __init alsa_card_serial_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (! cards) { @@ -998,13 +1010,13 @@ static int __init alsa_card_serial_init(void) return 0; errout: - platform_driver_unregister(&snd_serial_driver); + snd_serial_unregister_all(); return err; } static void __exit alsa_card_serial_exit(void) { - platform_driver_unregister(&snd_serial_driver); + snd_serial_unregister_all(); } module_init(alsa_card_serial_init) diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index 9f36a6472478..4258723de2ab 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -82,6 +82,8 @@ struct snd_card_virmidi { struct snd_rawmidi *midi[MAX_MIDI_DEVICES]; }; +static struct platform_device *devices[SNDRV_CARDS]; + static int __init snd_virmidi_probe(struct platform_device *devptr) { @@ -144,6 +146,15 @@ static struct platform_driver snd_virmidi_driver = { }, }; +static void __init_or_module snd_virmidi_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_virmidi_driver); +} + static int __init alsa_card_virmidi_init(void) { int i, cards, err; @@ -160,6 +171,7 @@ static int __init alsa_card_virmidi_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -172,13 +184,13 @@ static int __init alsa_card_virmidi_init(void) return 0; errout: - platform_driver_unregister(&snd_virmidi_driver); + snd_virmidi_unregister_all(); return err; } static void __exit alsa_card_virmidi_exit(void) { - platform_driver_unregister(&snd_virmidi_driver); + snd_virmidi_unregister_all(); } module_init(alsa_card_virmidi_init) diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 1019e9fdff53..e091bbeffd2a 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -62,6 +62,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); module_param_array(thinkpad, bool, NULL, 0444); MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); +static struct platform_device *devices[SNDRV_CARDS]; + static int __init snd_ad1848_probe(struct platform_device *pdev) { @@ -167,6 +169,15 @@ static struct platform_driver snd_ad1848_driver = { }, }; +static void __init_or_module snd_ad1848_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_ad1848_driver); +} + static int __init alsa_card_ad1848_init(void) { int i, cards, err; @@ -184,6 +195,7 @@ static int __init alsa_card_ad1848_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -196,13 +208,13 @@ static int __init alsa_card_ad1848_init(void) return 0; errout: - platform_driver_unregister(&snd_ad1848_driver); + snd_ad1848_unregister_all(); return err; } static void __exit alsa_card_ad1848_exit(void) { - platform_driver_unregister(&snd_ad1848_driver); + snd_ad1848_unregister_all(); } module_init(alsa_card_ad1848_init) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index ba0114ebafde..bd8e23818460 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -108,6 +108,9 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver."); module_param_array(wssdma, int, NULL, 0444); MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #define CMI8330_RMUX3D 16 #define CMI8330_MUTEMUX 17 #define CMI8330_OUTPUTVOL 18 @@ -665,6 +668,17 @@ static struct pnp_card_driver cmi8330_pnpc_driver = { }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_cmi8330_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&cmi8330_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_cmi8330_driver); +} + static int __init alsa_card_cmi8330_init(void) { int i, err, cards = 0; @@ -680,31 +694,35 @@ static int __init alsa_card_cmi8330_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_cmi8330_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } err = pnp_register_card_driver(&cmi8330_pnpc_driver); - if (err > 0) + if (err >= 0) { + pnp_registered = 1; cards += err; + } if (!cards) { - pnp_unregister_card_driver(&cmi8330_pnpc_driver); - platform_driver_unregister(&snd_cmi8330_driver); #ifdef MODULE snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cmi8330_unregister_all(); + return err; } static void __exit alsa_card_cmi8330_exit(void) { - pnp_unregister_card_driver(&cmi8330_pnpc_driver); - platform_driver_unregister(&snd_cmi8330_driver); + snd_cmi8330_unregister_all(); } module_init(alsa_card_cmi8330_init) diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index b5252a5d7412..ab67b5c2590d 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -66,6 +66,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); +static struct platform_device *devices[SNDRV_CARDS]; + static int __init snd_cs4231_probe(struct platform_device *pdev) { @@ -183,6 +185,15 @@ static struct platform_driver snd_cs4231_driver = { }, }; +static void __init_or_module snd_cs4231_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_cs4231_driver); +} + static int __init alsa_card_cs4231_init(void) { int i, cards, err; @@ -200,6 +211,7 @@ static int __init alsa_card_cs4231_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -212,13 +224,13 @@ static int __init alsa_card_cs4231_init(void) return 0; errout: - platform_driver_unregister(&snd_cs4231_driver); + snd_cs4231_unregister_all(); return err; } static void __exit alsa_card_cs4231_exit(void) { - platform_driver_unregister(&snd_cs4231_driver); + snd_cs4231_unregister_all(); } module_init(alsa_card_cs4231_init) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 9e399b6e6ed9..e1683337e6cd 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -124,6 +124,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnpc_registered; +#ifdef CS4232 +static int pnp_registered; +#endif + struct snd_card_cs4236 { struct snd_cs4231 *chip; struct resource *res_sb_port; @@ -737,6 +743,21 @@ static struct pnp_card_driver cs423x_pnpc_driver = { }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_cs423x_unregister_all(void) +{ + int i; + + if (pnpc_registered) + pnp_unregister_card_driver(&cs423x_pnpc_driver); +#ifdef CS4232 + if (pnp_registered) + pnp_unregister_driver(&cs4232_pnp_driver); +#endif + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&cs423x_nonpnp_driver); +} + static int __init alsa_card_cs423x_init(void) { int i, err, cards = 0; @@ -752,40 +773,40 @@ static int __init alsa_card_cs423x_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&cs423x_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } #ifdef CS4232 i = pnp_register_driver(&cs4232_pnp_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } #endif i = pnp_register_card_driver(&cs423x_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnpc_registered = 1; cards += i; + } if (!cards) { -#ifdef CS4232 - pnp_unregister_driver(&cs4232_pnp_driver); -#endif - pnp_unregister_card_driver(&cs423x_pnpc_driver); - platform_driver_unregister(&cs423x_nonpnp_driver); #ifdef MODULE printk(KERN_ERR IDENT " soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cs423x_unregister_all(); + return err; } static void __exit alsa_card_cs423x_exit(void) { -#ifdef CS4232 - pnp_unregister_driver(&cs4232_pnp_driver); -#endif - pnp_unregister_card_driver(&cs423x_pnpc_driver); - platform_driver_unregister(&cs423x_nonpnp_driver); + snd_cs423x_unregister_all(); } module_init(alsa_card_cs423x_init) diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 68bd40a76f01..50d23cf3d7cc 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -69,6 +69,8 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define PFX "es1688: " static int __init snd_es1688_probe(struct platform_device *pdev) @@ -187,6 +189,15 @@ static struct platform_driver snd_es1688_driver = { }, }; +static void __init_or_module snd_es1688_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_es1688_driver); +} + static int __init alsa_card_es1688_init(void) { int i, cards, err; @@ -204,6 +215,7 @@ static int __init alsa_card_es1688_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -216,13 +228,13 @@ static int __init alsa_card_es1688_init(void) return 0; errout: - platform_driver_unregister(&snd_es1688_driver); + snd_es1688_unregister_all(); return err; } static void __exit alsa_card_es1688_exit(void) { - platform_driver_unregister(&snd_es1688_driver); + snd_es1688_unregister_all(); } module_init(alsa_card_es1688_init) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 34d47132f082..bf5de0782eb0 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1877,6 +1877,9 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #ifdef CONFIG_PNP static struct pnp_card_device_id snd_audiodrive_pnpids[] = { @@ -2202,6 +2205,17 @@ static struct pnp_card_driver es18xx_pnpc_driver = { }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_es18xx_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&es18xx_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_es18xx_nonpnp_driver); +} + static int __init alsa_card_es18xx_init(void) { int i, err, cards = 0; @@ -2217,31 +2231,35 @@ static int __init alsa_card_es18xx_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } i = pnp_register_card_driver(&es18xx_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } if(!cards) { - pnp_unregister_card_driver(&es18xx_pnpc_driver); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); #ifdef MODULE snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_es18xx_unregister_all(); + return err; } static void __exit alsa_card_es18xx_exit(void) { - pnp_unregister_card_driver(&es18xx_pnpc_driver); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); + snd_es18xx_unregister_all(); } module_init(alsa_card_es18xx_init) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 57beb74f5b9d..d1165b96fa3f 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -71,6 +71,8 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define PFX "gusclassic: " @@ -227,6 +229,15 @@ static struct platform_driver snd_gusclassic_driver = { }, }; +static void __init_or_module snd_gusclassic_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_gusclassic_driver); +} + static int __init alsa_card_gusclassic_init(void) { int i, cards, err; @@ -244,6 +255,7 @@ static int __init alsa_card_gusclassic_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -256,13 +268,13 @@ static int __init alsa_card_gusclassic_init(void) return 0; errout: - platform_driver_unregister(&snd_gusclassic_driver); + snd_gusclassic_unregister_all(); return err; } static void __exit alsa_card_gusclassic_exit(void) { - platform_driver_unregister(&snd_gusclassic_driver); + snd_gusclassic_unregister_all(); } module_init(alsa_card_gusclassic_init) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 6fad9734a853..239f16e6b9ee 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -87,6 +87,8 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); +struct platform_device *devices[SNDRV_CARDS]; + #define PFX "gusextreme: " @@ -337,6 +339,15 @@ static struct platform_driver snd_gusextreme_driver = { }, }; +static void __init_or_module snd_gusextreme_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_gusextreme_driver); +} + static int __init alsa_card_gusextreme_init(void) { int i, cards, err; @@ -354,6 +365,7 @@ static int __init alsa_card_gusextreme_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -366,13 +378,13 @@ static int __init alsa_card_gusextreme_init(void) return 0; errout: - platform_driver_unregister(&snd_gusextreme_driver); + snd_gusextreme_unregister_all(); return err; } static void __exit alsa_card_gusextreme_exit(void) { - platform_driver_unregister(&snd_gusextreme_driver); + snd_gusextreme_unregister_all(); } module_init(alsa_card_gusextreme_init) diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index d1b70ee9b039..d4d2b2a517d5 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -72,6 +72,8 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); +static struct platform_device *devices[SNDRV_CARDS]; + struct snd_gusmax { int irq; struct snd_card *card; @@ -364,6 +366,15 @@ static struct platform_driver snd_gusmax_driver = { }, }; +static void __init_or_module snd_gusmax_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_gusmax_driver); +} + static int __init alsa_card_gusmax_init(void) { int i, cards, err; @@ -381,6 +392,7 @@ static int __init alsa_card_gusmax_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -393,13 +405,13 @@ static int __init alsa_card_gusmax_init(void) return 0; errout: - platform_driver_unregister(&snd_gusmax_driver); + snd_gusmax_unregister_all(); return err; } static void __exit alsa_card_gusmax_exit(void) { - platform_driver_unregister(&snd_gusmax_driver); + snd_gusmax_unregister_all(); } module_init(alsa_card_gusmax_init) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 67a5f7402453..9838d992b101 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -115,6 +115,9 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver."); module_param_array(effect, int, NULL, 0444); MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + struct snd_interwave { int irq; struct snd_card *card; @@ -914,6 +917,17 @@ static struct pnp_card_driver interwave_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module snd_interwave_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&interwave_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_interwave_driver); +} + static int __init alsa_card_interwave_init(void) { int i, err, cards = 0; @@ -931,32 +945,36 @@ static int __init alsa_card_interwave_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_interwave_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } /* ISA PnP cards */ i = pnp_register_card_driver(&interwave_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } if (!cards) { - pnp_unregister_card_driver(&interwave_pnpc_driver); - platform_driver_unregister(&snd_interwave_driver); #ifdef MODULE printk(KERN_ERR "InterWave soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_interwave_unregister_all(); + return err; } static void __exit alsa_card_interwave_exit(void) { - pnp_unregister_card_driver(&interwave_pnpc_driver); - platform_driver_unregister(&snd_interwave_driver); + snd_interwave_unregister_all(); } module_init(alsa_card_interwave_init) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index aafe5565b6e5..ca359e0c674b 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -90,6 +90,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver."); module_param_array(opl3sa3_ymode, int, NULL, 0444); MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; +static int pnpc_registered; + /* control ports */ #define OPL3SA2_PM_CTRL 0x01 #define OPL3SA2_SYS_CTRL 0x02 @@ -921,6 +925,19 @@ static struct platform_driver snd_opl3sa2_nonpnp_driver = { }, }; +static void __init_or_module snd_opl3sa2_unregister_all(void) +{ + int i; + + if (pnpc_registered) + pnp_unregister_card_driver(&opl3sa2_pnpc_driver); + if (pnp_registered) + pnp_unregister_driver(&opl3sa2_pnp_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); +} + static int __init alsa_card_opl3sa2_init(void) { int i, err, cards = 0; @@ -938,36 +955,40 @@ static int __init alsa_card_opl3sa2_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } err = pnp_register_driver(&opl3sa2_pnp_driver); - if (err > 0) + if (err >= 0) { + pnp_registered = 1; cards += err; + } err = pnp_register_card_driver(&opl3sa2_pnpc_driver); - if (err > 0) + if (err >= 0) { + pnpc_registered = 1; cards += err; + } if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); #endif - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - pnp_unregister_driver(&opl3sa2_pnp_driver); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_opl3sa2_unregister_all(); + return err; } static void __exit alsa_card_opl3sa2_exit(void) { - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - pnp_unregister_driver(&opl3sa2_pnp_driver); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); + snd_opl3sa2_unregister_all(); } module_init(alsa_card_opl3sa2_init) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 39211e58cd68..1ea3944ef7ab 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -259,6 +259,7 @@ struct snd_opti9xx { }; static int snd_opti9xx_pnp_is_probed; +static struct platform_device *snd_opti9xx_platform_device; #ifdef CONFIG_PNP @@ -2095,8 +2096,10 @@ static int __init alsa_card_opti9xx_init(void) if (error < 0) return error; device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); - if (! IS_ERR(device)) + if (!IS_ERR(device)) { + snd_opti9xx_platform_device = device; return 0; + } platform_driver_unregister(&snd_opti9xx_driver); } pnp_unregister_card_driver(&opti9xx_pnpc_driver); @@ -2108,8 +2111,10 @@ static int __init alsa_card_opti9xx_init(void) static void __exit alsa_card_opti9xx_exit(void) { - if (! snd_opti9xx_pnp_is_probed) + if (!snd_opti9xx_pnp_is_probed) { + platform_device_unregister(snd_opti9xx_platform_device); platform_driver_unregister(&snd_opti9xx_driver); + } pnp_unregister_card_driver(&opti9xx_pnpc_driver); } diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 05816c5d829a..c0be7a5a3425 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -128,6 +128,11 @@ module_param_array(seq_ports, int, NULL, 0444); MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); #endif +static struct platform_device *platform_devices[SNDRV_CARDS]; +#ifdef CONFIG_PNP +static int pnp_registered; +#endif + struct snd_card_sb16 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ struct snd_sb *chip; @@ -687,6 +692,19 @@ static struct pnp_card_driver sb16_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module snd_sb16_unregister_all(void) +{ + int i; + +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&sb16_pnpc_driver); +#endif + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_sb16_nonpnp_driver); +} + static int __init alsa_card_sb16_init(void) { int i, err, cards = 0; @@ -702,23 +720,21 @@ static int __init alsa_card_sb16_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_sb16_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } #ifdef CONFIG_PNP /* PnP cards at last */ i = pnp_register_card_driver(&sb16_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } #endif if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif - platform_driver_unregister(&snd_sb16_nonpnp_driver); #ifdef MODULE snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); #ifdef SNDRV_SBAWE_EMU8000 @@ -727,17 +743,19 @@ static int __init alsa_card_sb16_init(void) snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); #endif #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_sb16_unregister_all(); + return err; } static void __exit alsa_card_sb16_exit(void) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif - platform_driver_unregister(&snd_sb16_nonpnp_driver); + snd_sb16_unregister_all(); } module_init(alsa_card_sb16_init) diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 0a3d55d639a9..60ee79cd14a3 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -56,6 +56,8 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); +static struct platform_device *devices[SNDRV_CARDS]; + struct snd_sb8 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ struct snd_sb *chip; @@ -238,6 +240,15 @@ static struct platform_driver snd_sb8_driver = { }, }; +static void __init_or_module snd_sb8_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_sb8_driver); +} + static int __init alsa_card_sb8_init(void) { int i, cards, err; @@ -255,6 +266,7 @@ static int __init alsa_card_sb8_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -267,13 +279,13 @@ static int __init alsa_card_sb8_init(void) return 0; errout: - platform_driver_unregister(&snd_sb8_driver); + snd_sb8_unregister_all(); return err; } static void __exit alsa_card_sb8_exit(void) { - platform_driver_unregister(&snd_sb8_driver); + snd_sb8_unregister_all(); } module_init(alsa_card_sb8_init) diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 2e1d4677fe12..0dbbb35b242c 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -64,6 +64,8 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); module_param_array(dma1, int, NULL, 0444); MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define SGALAXY_AUXC_LEFT 18 #define SGALAXY_AUXC_RIGHT 19 @@ -340,6 +342,15 @@ static struct platform_driver snd_sgalaxy_driver = { }, }; +static void __init_or_module snd_sgalaxy_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_sgalaxy_driver); +} + static int __init alsa_card_sgalaxy_init(void) { int i, cards, err; @@ -357,6 +368,7 @@ static int __init alsa_card_sgalaxy_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -369,13 +381,13 @@ static int __init alsa_card_sgalaxy_init(void) return 0; errout: - platform_driver_unregister(&snd_sgalaxy_driver); + snd_sgalaxy_unregister_all(); return err; } static void __exit alsa_card_sgalaxy_exit(void) { - platform_driver_unregister(&snd_sgalaxy_driver); + snd_sgalaxy_unregister_all(); } module_init(alsa_card_sgalaxy_init) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 6271efe689df..5fb981c0a281 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -67,6 +67,9 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver."); module_param_array(dma, int, NULL, 0444); MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); + +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; #ifdef CONFIG_PNP static struct pnp_card_device_id sscape_pnpids[] = { @@ -1384,6 +1387,17 @@ static struct pnp_card_driver sscape_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module sscape_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&sscape_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_sscape_driver); +} + static int __init sscape_manual_probe(void) { struct platform_device *device; @@ -1411,8 +1425,8 @@ static int __init sscape_manual_probe(void) dma[i] == SNDRV_AUTO_DMA) { printk(KERN_INFO "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); - platform_driver_unregister(&snd_sscape_driver); - return -ENXIO; + ret = -ENXIO; + goto errout; } /* @@ -1421,17 +1435,21 @@ static int __init sscape_manual_probe(void) device = platform_device_register_simple(SSCAPE_DRIVER, i, NULL, 0); if (IS_ERR(device)) { - platform_driver_unregister(&snd_sscape_driver); - return PTR_ERR(device); + ret = PTR_ERR(device); + goto errout; } + platform_devices[i] = device; } return 0; + + errout: + sscape_unregister_all(); + return ret; } static void sscape_exit(void) { - pnp_unregister_card_driver(&sscape_pnpc_driver); - platform_driver_unregister(&snd_sscape_driver); + sscape_unregister_all(); } @@ -1448,7 +1466,8 @@ static int __init sscape_init(void) ret = sscape_manual_probe(); if (ret < 0) return ret; - pnp_register_card_driver(&sscape_pnpc_driver); + if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0) + pnp_registered = 1; return 0; } diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 77a3012e5510..a6dcb2f970ca 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -83,6 +83,9 @@ MODULE_PARM_DESC(fm_port, "FM port #."); module_param_array(use_cs4232_midi, bool, NULL, 0444); MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #ifdef CONFIG_PNP @@ -688,6 +691,17 @@ static struct pnp_card_driver wavefront_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module snd_wavefront_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&wavefront_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_wavefront_driver); +} + static int __init alsa_card_wavefront_init(void) { int i, err, cards = 0; @@ -704,31 +718,36 @@ static int __init alsa_card_wavefront_init(void) device = platform_device_register_simple(WAVEFRONT_DRIVER, i, NULL, 0); if (IS_ERR(device)) { - platform_driver_unregister(&snd_wavefront_driver); - return PTR_ERR(device); + err = PTR_ERR(device); + goto errout; } + platform_devices[i] = device; cards++; } i = pnp_register_card_driver(&wavefront_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } if (!cards) { - pnp_unregister_card_driver(&wavefront_pnpc_driver); - platform_driver_unregister(&snd_wavefront_driver); #ifdef MODULE printk (KERN_ERR "No WaveFront cards found or devices busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_wavefront_unregister_all(); + return err; } static void __exit alsa_card_wavefront_exit(void) { - pnp_unregister_card_driver(&wavefront_pnpc_driver); - platform_driver_unregister(&snd_wavefront_driver); + snd_wavefront_unregister_all(); } module_init(alsa_card_wavefront_init) diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index efa06fe5f01b..f4902a219e50 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -46,6 +46,8 @@ MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip."); module_param(enable_beep, bool, 0444); MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); +static struct platform_device *device; + /* */ @@ -182,7 +184,6 @@ static struct platform_driver snd_pmac_driver = { static int __init alsa_card_pmac_init(void) { int err; - struct platform_device *device; if ((err = platform_driver_register(&snd_pmac_driver)) < 0) return err; @@ -197,6 +198,7 @@ static int __init alsa_card_pmac_init(void) static void __exit alsa_card_pmac_exit(void) { + platform_device_unregister(device); platform_driver_unregister(&snd_pmac_driver); } -- cgit v1.2.3