diff options
Diffstat (limited to '')
-rw-r--r-- | sound/isa/opti9xx/opti92x-ad1848.c | 124 |
1 files changed, 49 insertions, 75 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index d06b29693c85..4beeb32fe2a7 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -36,17 +36,11 @@ MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); MODULE_LICENSE("GPL"); #ifdef OPTi93X MODULE_DESCRIPTION("OPTi93X"); -MODULE_SUPPORTED_DEVICE("{{OPTi,82C931/3}}"); #else /* OPTi93X */ #ifdef CS4231 MODULE_DESCRIPTION("OPTi92X - CS4231"); -MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (CS4231)}," - "{OPTi,82C925 (CS4231)}}"); #else /* CS4231 */ MODULE_DESCRIPTION("OPTi92X - AD1848"); -MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)}," - "{OPTi,82C925 (AD1848)}," - "{OAK,Mozart}}"); #endif /* CS4231 */ #endif /* OPTi93X */ @@ -249,7 +243,7 @@ static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip, retval = inb(chip->mc_base + 9); break; } - /* Fall through */ + fallthrough; case OPTi9XX_HW_82C928: case OPTi9XX_HW_82C929: @@ -292,7 +286,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, outb(value, chip->mc_base + 9); break; } - /* Fall through */ + fallthrough; case OPTi9XX_HW_82C928: case OPTi9XX_HW_82C929: @@ -317,10 +311,13 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, } -#define snd_opti9xx_write_mask(chip, reg, value, mask) \ - snd_opti9xx_write(chip, reg, \ - (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) +static inline void snd_opti9xx_write_mask(struct snd_opti9xx *chip, + unsigned char reg, unsigned char value, unsigned char mask) +{ + unsigned char oldval = snd_opti9xx_read(chip, reg); + snd_opti9xx_write(chip, reg, (oldval & ~mask) | (value & mask)); +} static int snd_opti9xx_configure(struct snd_opti9xx *chip, long port, @@ -340,7 +337,7 @@ static int snd_opti9xx_configure(struct snd_opti9xx *chip, snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc); /* enable wave audio */ snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); - /* Fall through */ + fallthrough; case OPTi9XX_HW_82C925: /* enable WSS mode */ @@ -377,7 +374,8 @@ static int snd_opti9xx_configure(struct snd_opti9xx *chip, case OPTi9XX_HW_82C931: /* disable 3D sound (set GPIO1 as output, low) */ snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(20), 0x04, 0x0c); - /* fall through */ + fallthrough; + case OPTi9XX_HW_82C933: /* * The BTC 1817DW has QS1000 wavetable which is connected @@ -389,7 +387,8 @@ static int snd_opti9xx_configure(struct snd_opti9xx *chip, * or digital input signal. */ snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(26), 0x01, 0x01); - /* fall through */ + fallthrough; + case OPTi9XX_HW_82C930: snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x03); snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0x00, 0xff); @@ -655,16 +654,18 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) #endif /* OPTi93X */ -static int snd_opti9xx_read_check(struct snd_opti9xx *chip) +static int snd_opti9xx_read_check(struct snd_card *card, + struct snd_opti9xx *chip) { unsigned char value; #ifdef OPTi93X unsigned long flags; #endif - chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, - "OPTi9xx MC"); - if (chip->res_mc_base == NULL) + chip->res_mc_base = + devm_request_region(card->dev, chip->mc_base, + chip->mc_base_size, "OPTi9xx MC"); + if (!chip->res_mc_base) return -EBUSY; #ifndef OPTi93X value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); @@ -672,9 +673,10 @@ static int snd_opti9xx_read_check(struct snd_opti9xx *chip) if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) return 0; #else /* OPTi93X */ - chip->res_mc_indir = request_region(chip->mc_indir_index, 2, - "OPTi93x MC"); - if (chip->res_mc_indir == NULL) + chip->res_mc_indir = + devm_request_region(card->dev, chip->mc_indir_index, 2, + "OPTi93x MC"); + if (!chip->res_mc_indir) return -EBUSY; spin_lock_irqsave(&chip->lock, flags); @@ -687,10 +689,10 @@ static int snd_opti9xx_read_check(struct snd_opti9xx *chip) if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) return 0; - release_and_free_resource(chip->res_mc_indir); + devm_release_resource(card->dev, chip->res_mc_indir); chip->res_mc_indir = NULL; #endif /* OPTi93X */ - release_and_free_resource(chip->res_mc_base); + devm_release_resource(card->dev, chip->res_mc_base); chip->res_mc_base = NULL; return -ENODEV; @@ -710,7 +712,7 @@ static int snd_card_opti9xx_detect(struct snd_card *card, if (err < 0) return err; - err = snd_opti9xx_read_check(chip); + err = snd_opti9xx_read_check(card, chip); if (err == 0) return 1; #ifdef OPTi93X @@ -790,22 +792,6 @@ static int snd_card_opti9xx_pnp(struct snd_opti9xx *chip, } #endif /* CONFIG_PNP */ -static void snd_card_opti9xx_free(struct snd_card *card) -{ - struct snd_opti9xx *chip = card->private_data; - - if (chip) { -#ifdef OPTi93X - if (chip->irq > 0) { - disable_irq(chip->irq); - free_irq(chip->irq, chip); - } - release_and_free_resource(chip->res_mc_indir); -#endif - release_and_free_resource(chip->res_mc_base); - } -} - static int snd_opti9xx_probe(struct snd_card *card) { static const long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; @@ -861,8 +847,8 @@ static int snd_opti9xx_probe(struct snd_card *card) return error; #endif #ifdef OPTi93X - error = request_irq(irq, snd_opti93x_interrupt, - 0, DEV_NAME" - WSS", chip); + error = devm_request_irq(card->dev, irq, snd_opti93x_interrupt, + 0, DEV_NAME" - WSS", chip); if (error < 0) { snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq); return error; @@ -932,11 +918,10 @@ static int snd_opti9xx_card_new(struct device *pdev, struct snd_card **cardp) struct snd_card *card; int err; - err = snd_card_new(pdev, index, id, THIS_MODULE, - sizeof(struct snd_opti9xx), &card); + err = snd_devm_card_new(pdev, index, id, THIS_MODULE, + sizeof(struct snd_opti9xx), &card); if (err < 0) return err; - card->private_free = snd_card_opti9xx_free; *cardp = card; return 0; } @@ -971,32 +956,37 @@ static int snd_opti9xx_isa_probe(struct device *devptr, #endif /* CS4231 || OPTi93X */ if (mpu_port == SNDRV_AUTO_PORT) { - if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { + mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2); + if (mpu_port < 0) { snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); return -EBUSY; } } if (irq == SNDRV_AUTO_IRQ) { - if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { + irq = snd_legacy_find_free_irq(possible_irqs); + if (irq < 0) { snd_printk(KERN_ERR "unable to find a free IRQ\n"); return -EBUSY; } } if (mpu_irq == SNDRV_AUTO_IRQ) { - if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { + mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs); + if (mpu_irq < 0) { snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); return -EBUSY; } } if (dma1 == SNDRV_AUTO_DMA) { - if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { + dma1 = snd_legacy_find_free_dma(possible_dma1s); + if (dma1 < 0) { snd_printk(KERN_ERR "unable to find a free DMA1\n"); return -EBUSY; } } #if defined(CS4231) || defined(OPTi93X) if (dma2 == SNDRV_AUTO_DMA) { - if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) { + dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4]); + if (dma2 < 0) { snd_printk(KERN_ERR "unable to find a free DMA2\n"); return -EBUSY; } @@ -1007,25 +997,16 @@ static int snd_opti9xx_isa_probe(struct device *devptr, if (error < 0) return error; - if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) { - snd_card_free(card); + error = snd_card_opti9xx_detect(card, card->private_data); + if (error < 0) return error; - } - if ((error = snd_opti9xx_probe(card)) < 0) { - snd_card_free(card); + error = snd_opti9xx_probe(card); + if (error < 0) return error; - } dev_set_drvdata(devptr, card); return 0; } -static int snd_opti9xx_isa_remove(struct device *devptr, - unsigned int dev) -{ - snd_card_free(dev_get_drvdata(devptr)); - return 0; -} - #ifdef CONFIG_PM static int snd_opti9xx_suspend(struct snd_card *card) { @@ -1070,7 +1051,6 @@ static int snd_opti9xx_isa_resume(struct device *dev, unsigned int n) static struct isa_driver snd_opti9xx_driver = { .match = snd_opti9xx_isa_match, .probe = snd_opti9xx_isa_probe, - .remove = snd_opti9xx_isa_remove, #ifdef CONFIG_PM .suspend = snd_opti9xx_isa_suspend, .resume = snd_opti9xx_isa_resume, @@ -1109,24 +1089,20 @@ static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, hw = OPTi9XX_HW_82C931; break; default: - snd_card_free(card); return -ENODEV; } - if ((error = snd_opti9xx_init(chip, hw))) { - snd_card_free(card); + error = snd_opti9xx_init(chip, hw); + if (error) return error; - } - error = snd_opti9xx_read_check(chip); + error = snd_opti9xx_read_check(card, chip); if (error) { snd_printk(KERN_ERR "OPTI chip not found\n"); - snd_card_free(card); return error; } - if ((error = snd_opti9xx_probe(card)) < 0) { - snd_card_free(card); + error = snd_opti9xx_probe(card); + if (error < 0) return error; - } pnp_set_card_drvdata(pcard, card); snd_opti9xx_pnp_is_probed = 1; return 0; @@ -1134,8 +1110,6 @@ static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, static void snd_opti9xx_pnp_remove(struct pnp_card_link *pcard) { - snd_card_free(pnp_get_card_drvdata(pcard)); - pnp_set_card_drvdata(pcard, NULL); snd_opti9xx_pnp_is_probed = 0; } |