diff options
Diffstat (limited to 'sound/isa/opti9xx/miro.c')
-rw-r--r-- | sound/isa/opti9xx/miro.c | 115 |
1 files changed, 43 insertions, 72 deletions
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 44ed1b65f6ce..59792f2fada1 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -33,9 +33,6 @@ MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Miro miroSOUND PCM1 pro, PCM12, PCM20 Radio"); -MODULE_SUPPORTED_DEVICE("{{Miro,miroSOUND PCM1 pro}, " - "{Miro,miroSOUND PCM12}, " - "{Miro,miroSOUND PCM20 Radio}}"); static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ @@ -725,35 +722,43 @@ static int snd_miro_mixer(struct snd_card *card, } for (idx = 0; idx < ARRAY_SIZE(snd_miro_controls); idx++) { - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_controls[idx], miro))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_controls[idx], miro)); + if (err < 0) return err; } if ((miro->aci->aci_product == 'A') || (miro->aci->aci_product == 'B')) { /* PCM1/PCM12 with power-amp and Line 2 */ - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro)); + if (err < 0) return err; - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_amp_control[0], miro))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_amp_control[0], miro)); + if (err < 0) return err; } if ((miro->aci->aci_product == 'B') || (miro->aci->aci_product == 'C')) { /* PCM12/PCM20 with mic-preamp */ - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro)); + if (err < 0) return err; - if (miro->aci->aci_version >= 176) - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) + if (miro->aci->aci_version >= 176) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro)); + if (err < 0) return err; + } } if (miro->aci->aci_product == 'C') { /* PCM20 with radio and 7 band equalizer */ - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro)); + if (err < 0) return err; for (idx = 0; idx < ARRAY_SIZE(snd_miro_eq_controls); idx++) { - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_eq_controls[idx], miro))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_eq_controls[idx], miro)); + if (err < 0) return err; } } @@ -1154,12 +1159,13 @@ __skip_mpu: return 0; } -static int snd_miro_opti_check(struct snd_miro *chip) +static int snd_miro_opti_check(struct snd_card *card, struct snd_miro *chip) { unsigned char value; - chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, - "OPTi9xx MC"); + chip->res_mc_base = + devm_request_region(card->dev, chip->mc_base, + chip->mc_base_size, "OPTi9xx MC"); if (chip->res_mc_base == NULL) return -ENOMEM; @@ -1168,7 +1174,7 @@ static int snd_miro_opti_check(struct snd_miro *chip) if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1))) return 0; - release_and_free_resource(chip->res_mc_base); + devm_release_resource(card->dev, chip->res_mc_base); chip->res_mc_base = NULL; return -ENODEV; @@ -1181,10 +1187,11 @@ static int snd_card_miro_detect(struct snd_card *card, for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { - if ((err = snd_miro_init(chip, i)) < 0) + err = snd_miro_init(chip, i); + if (err < 0) return err; - err = snd_miro_opti_check(chip); + err = snd_miro_opti_check(card, chip); if (err == 0) return 1; } @@ -1208,7 +1215,8 @@ static int snd_card_miro_aci_detect(struct snd_card *card, regval=inb(miro->mc_base + 4); aci->aci_port = (regval & 0x10) ? 0x344 : 0x354; - miro->res_aci_port = request_region(aci->aci_port, 3, "miro aci"); + miro->res_aci_port = + devm_request_region(card->dev, aci->aci_port, 3, "miro aci"); if (miro->res_aci_port == NULL) { snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", aci->aci_port, aci->aci_port+2); @@ -1247,16 +1255,6 @@ static int snd_card_miro_aci_detect(struct snd_card *card, return 0; } -static void snd_card_miro_free(struct snd_card *card) -{ - struct snd_miro *miro = card->private_data; - - release_and_free_resource(miro->res_aci_port); - if (miro->aci) - miro->aci->aci_port = 0; - release_and_free_resource(miro->res_mc_base); -} - static int snd_miro_probe(struct snd_card *card) { int error; @@ -1265,9 +1263,10 @@ static int snd_miro_probe(struct snd_card *card) struct snd_rawmidi *rmidi; if (!miro->res_mc_base) { - miro->res_mc_base = request_region(miro->mc_base, - miro->mc_base_size, - "miro (OPTi9xx MC)"); + miro->res_mc_base = devm_request_region(card->dev, + miro->mc_base, + miro->mc_base_size, + "miro (OPTi9xx MC)"); if (miro->res_mc_base == NULL) { snd_printk(KERN_ERR "request for OPTI9xx MC failed\n"); return -ENOMEM; @@ -1345,10 +1344,10 @@ static int snd_miro_probe(struct snd_card *card) } strcpy(card->driver, "miro"); - snprintf(card->longname, sizeof(card->longname), - "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, miro->name, codec->pcm->name, - miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); + scnprintf(card->longname, sizeof(card->longname), + "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", + card->shortname, miro->name, codec->pcm->name, + miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) rmidi = NULL; @@ -1402,17 +1401,15 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) struct snd_miro *miro; struct snd_card *card; - error = snd_card_new(devptr, index, id, THIS_MODULE, - sizeof(struct snd_miro), &card); + error = snd_devm_card_new(devptr, index, id, THIS_MODULE, + sizeof(struct snd_miro), &card); if (error < 0) return error; - card->private_free = snd_card_miro_free; miro = card->private_data; error = snd_card_miro_detect(card, miro); if (error < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); return -ENODEV; } @@ -1420,7 +1417,6 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) if (port == SNDRV_AUTO_PORT) { port = snd_legacy_find_free_ioport(possible_ports, 4); if (port < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to find a free WSS port\n"); return -EBUSY; } @@ -1429,7 +1425,6 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) if (mpu_port == SNDRV_AUTO_PORT) { mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2); if (mpu_port < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); return -EBUSY; @@ -1439,7 +1434,6 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) if (irq == SNDRV_AUTO_IRQ) { irq = snd_legacy_find_free_irq(possible_irqs); if (irq < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to find a free IRQ\n"); return -EBUSY; } @@ -1447,7 +1441,6 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) if (mpu_irq == SNDRV_AUTO_IRQ) { mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs); if (mpu_irq < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); return -EBUSY; @@ -1456,7 +1449,6 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) if (dma1 == SNDRV_AUTO_DMA) { dma1 = snd_legacy_find_free_dma(possible_dma1s); if (dma1 < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to find a free DMA1\n"); return -EBUSY; } @@ -1464,35 +1456,24 @@ static int snd_miro_isa_probe(struct device *devptr, unsigned int n) if (dma2 == SNDRV_AUTO_DMA) { dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4]); if (dma2 < 0) { - snd_card_free(card); snd_printk(KERN_ERR "unable to find a free DMA2\n"); return -EBUSY; } } error = snd_miro_probe(card); - if (error < 0) { - snd_card_free(card); + if (error < 0) return error; - } dev_set_drvdata(devptr, card); return 0; } -static int snd_miro_isa_remove(struct device *devptr, - unsigned int dev) -{ - snd_card_free(dev_get_drvdata(devptr)); - return 0; -} - #define DEV_NAME "miro" static struct isa_driver snd_miro_driver = { .match = snd_miro_isa_match, .probe = snd_miro_isa_probe, - .remove = snd_miro_isa_remove, /* FIXME: suspend/resume */ .driver = { .name = DEV_NAME @@ -1573,39 +1554,31 @@ static int snd_miro_pnp_probe(struct pnp_card_link *pcard, return -EBUSY; if (!isapnp) return -ENODEV; - err = snd_card_new(&pcard->card->dev, index, id, THIS_MODULE, - sizeof(struct snd_miro), &card); + err = snd_devm_card_new(&pcard->card->dev, index, id, THIS_MODULE, + sizeof(struct snd_miro), &card); if (err < 0) return err; - card->private_free = snd_card_miro_free; miro = card->private_data; err = snd_card_miro_pnp(miro, pcard, pid); - if (err) { - snd_card_free(card); + if (err) return err; - } /* only miroSOUND PCM20 and PCM12 == OPTi924 */ err = snd_miro_init(miro, OPTi9XX_HW_82C924); - if (err) { - snd_card_free(card); + if (err) return err; - } - err = snd_miro_opti_check(miro); + err = snd_miro_opti_check(card, miro); if (err) { snd_printk(KERN_ERR "OPTI chip not found\n"); - snd_card_free(card); return err; } err = snd_miro_probe(card); - if (err < 0) { - snd_card_free(card); + if (err < 0) return err; - } pnp_set_card_drvdata(pcard, card); snd_miro_pnp_is_probed = 1; return 0; @@ -1613,8 +1586,6 @@ static int snd_miro_pnp_probe(struct pnp_card_link *pcard, static void snd_miro_pnp_remove(struct pnp_card_link *pcard) { - snd_card_free(pnp_get_card_drvdata(pcard)); - pnp_set_card_drvdata(pcard, NULL); snd_miro_pnp_is_probed = 0; } |