]> err.no Git - linux-2.6/blobdiff - sound/isa/es18xx.c
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6] / sound / isa / es18xx.c
index 1d832b2adb7ca34ad93863927d3c2ec03413db4a..970e2aaade27dba67a660795849e5eece98769b0 100644 (file)
@@ -173,7 +173,7 @@ static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val)
                         outb(val, chip->port + 0x0C);
                         return 0;
                 }
-        snd_printk("dsp_command: timeout (0x%x)\n", val);
+       snd_printk(KERN_ERR "dsp_command: timeout (0x%x)\n", val);
         return -EINVAL;
 }
 
@@ -184,7 +184,8 @@ static int snd_es18xx_dsp_get_byte(es18xx_t *chip)
         for(i = MILLISECOND/10; i; i--)
                 if (inb(chip->port + 0x0C) & 0x40)
                         return inb(chip->port + 0x0A);
-        snd_printk("dsp_get_byte failed: 0x%lx = 0x%x!!!\n", chip->port + 0x0A, inb(chip->port + 0x0A));
+       snd_printk(KERN_ERR "dsp_get_byte failed: 0x%lx = 0x%x!!!\n",
+                  chip->port + 0x0A, inb(chip->port + 0x0A));
         return -ENODEV;
 }
 
@@ -204,7 +205,7 @@ static int snd_es18xx_write(es18xx_t *chip,
  end:
         spin_unlock_irqrestore(&chip->reg_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Reg %02x set to %02x\n", reg, data);
+       snd_printk(KERN_DEBUG "Reg %02x set to %02x\n", reg, data);
 #endif
        return ret;
 }
@@ -223,7 +224,7 @@ static int snd_es18xx_read(es18xx_t *chip, unsigned char reg)
        data = snd_es18xx_dsp_get_byte(chip);
        ret = data;
 #ifdef REG_DEBUG
-       snd_printk("Reg %02x now is %02x (%d)\n", reg, data, ret);
+       snd_printk(KERN_DEBUG "Reg %02x now is %02x (%d)\n", reg, data, ret);
 #endif
  end:
         spin_unlock_irqrestore(&chip->reg_lock, flags);
@@ -259,7 +260,8 @@ static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg,
                if (ret < 0)
                        goto end;
 #ifdef REG_DEBUG
-               snd_printk("Reg %02x was %02x, set to %02x (%d)\n", reg, old, new, ret);
+               snd_printk(KERN_DEBUG "Reg %02x was %02x, set to %02x (%d)\n",
+                          reg, old, new, ret);
 #endif
        }
        ret = oval;
@@ -277,7 +279,7 @@ static inline void snd_es18xx_mixer_write(es18xx_t *chip,
         outb(data, chip->port + 0x05);
         spin_unlock_irqrestore(&chip->mixer_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Mixer reg %02x set to %02x\n", reg, data);
+       snd_printk(KERN_DEBUG "Mixer reg %02x set to %02x\n", reg, data);
 #endif
 }
 
@@ -290,7 +292,7 @@ static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg)
        data = inb(chip->port + 0x05);
         spin_unlock_irqrestore(&chip->mixer_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Mixer reg %02x now is %02x\n", reg, data);
+       snd_printk(KERN_DEBUG "Mixer reg %02x now is %02x\n", reg, data);
 #endif
         return data;
 }
@@ -309,7 +311,8 @@ static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg,
                new = (old & ~mask) | (val & mask);
                outb(new, chip->port + 0x05);
 #ifdef REG_DEBUG
-               snd_printk("Mixer reg %02x was %02x, set to %02x\n", reg, old, new);
+               snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x\n",
+                          reg, old, new);
 #endif
        }
         spin_unlock_irqrestore(&chip->mixer_lock, flags);
@@ -329,7 +332,8 @@ static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg,
        new = inb(chip->port + 0x05);
         spin_unlock_irqrestore(&chip->mixer_lock, flags);
 #ifdef REG_DEBUG
-       snd_printk("Mixer reg %02x was %02x, set to %02x, now is %02x\n", reg, old, expected, new);
+       snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x, now is %02x\n",
+                  reg, old, expected, new);
 #endif
        return expected == new;
 }
@@ -1281,7 +1285,7 @@ static void __devinit snd_es18xx_config_write(es18xx_t *chip,
        outb(reg, chip->ctrl_port);
        outb(data, chip->ctrl_port + 1);
 #ifdef REG_DEBUG
-       snd_printk("Config reg %02x set to %02x\n", reg, data);
+       snd_printk(KERN_DEBUG "Config reg %02x set to %02x\n", reg, data);
 #endif
 }
 
@@ -1346,7 +1350,7 @@ static int __devinit snd_es18xx_initialize(es18xx_t *chip)
                        irqmask = 3;
                        break;
                default:
-                       snd_printk("invalid irq %d\n", chip->irq);
+                       snd_printk(KERN_ERR "invalid irq %d\n", chip->irq);
                        return -ENODEV;
                }
                switch (chip->dma1) {
@@ -1360,7 +1364,7 @@ static int __devinit snd_es18xx_initialize(es18xx_t *chip)
                        dma1mask = 3;
                        break;
                default:
-                       snd_printk("invalid dma1 %d\n", chip->dma1);
+                       snd_printk(KERN_ERR "invalid dma1 %d\n", chip->dma1);
                        return -ENODEV;
                }
                switch (chip->dma2) {
@@ -1377,7 +1381,7 @@ static int __devinit snd_es18xx_initialize(es18xx_t *chip)
                        dma2mask = 3;
                        break;
                default:
-                       snd_printk("invalid dma2 %d\n", chip->dma2);
+                       snd_printk(KERN_ERR "invalid dma2 %d\n", chip->dma2);
                        return -ENODEV;
                }
 
@@ -1440,7 +1444,7 @@ static int __devinit snd_es18xx_identify(es18xx_t *chip)
 
        /* reset */
        if (snd_es18xx_reset(chip) < 0) {
-                snd_printk("reset at 0x%lx failed!!!\n", chip->port);
+               snd_printk(KERN_ERR "reset at 0x%lx failed!!!\n", chip->port);
                return -ENODEV;
        }
 
@@ -1527,7 +1531,7 @@ static int __devinit snd_es18xx_probe(es18xx_t *chip)
                chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME | ES18XX_HWV;
                break;
        default:
-                snd_printk("[0x%lx] unsupported chip ES%x\n",
+               snd_printk(KERN_ERR "[0x%lx] unsupported chip ES%x\n",
                            chip->port, chip->version);
                 return -ENODEV;
         }
@@ -1640,18 +1644,9 @@ static int snd_es18xx_resume(snd_card_t *card)
 
 static int snd_es18xx_free(es18xx_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
-       if (chip->res_ctrl_port) {
-               release_resource(chip->res_ctrl_port);
-               kfree_nocheck(chip->res_ctrl_port);
-       }
-       if (chip->res_mpu_port) {
-               release_resource(chip->res_mpu_port);
-               kfree_nocheck(chip->res_mpu_port);
-       }
+       release_and_free_resource(chip->res_port);
+       release_and_free_resource(chip->res_ctrl_port);
+       release_and_free_resource(chip->res_mpu_port);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
        if (chip->dma1 >= 0) {
@@ -1686,7 +1681,7 @@ static int __devinit snd_es18xx_new_device(snd_card_t * card,
        int err;
 
        *rchip = NULL;
-        chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
+        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (chip == NULL)
                return -ENOMEM;
        spin_lock_init(&chip->reg_lock);
@@ -1988,6 +1983,12 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard,
 }
 #endif /* CONFIG_PNP */
 
+#ifdef CONFIG_PNP
+#define is_isapnp_selected(dev)                isapnp[dev]
+#else
+#define is_isapnp_selected(dev)                0
+#endif
+
 static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
                                          const struct pnp_card_device_id *pid)
 {
@@ -1996,7 +1997,6 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
        int xirq, xdma1, xdma2;
        snd_card_t *card;
        struct snd_audiodrive *acard;
-       snd_rawmidi_t *rmidi = NULL;
        es18xx_t *chip;
        opl3_t *opl3;
        int err;
@@ -2019,25 +2019,25 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
        xirq = irq[dev];
        if (xirq == SNDRV_AUTO_IRQ) {
                if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
-                       snd_card_free(card);
-                       snd_printk("unable to find a free IRQ\n");
-                       return -EBUSY;
+                       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_card_free(card);
-                        snd_printk("unable to find a free DMA1\n");
-                        return -EBUSY;
+                       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_card_free(card);
-                        snd_printk("unable to find a free DMA2\n");
-                        return -EBUSY;
+                       snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
+                       err = -EBUSY;
+                       goto _err;
                 }
         }
 
@@ -2046,10 +2046,8 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
                                         mpu_port[dev],
                                         fm_port[dev],
                                         xirq, xdma1, xdma2,
-                                        &chip)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
+                                        &chip)) < 0)
+               goto _err;
 
        sprintf(card->driver, "ES%x", chip->version);
        sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version);
@@ -2064,23 +2062,18 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
                        chip->port,
                        xirq, xdma1);
 
-       if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
-       if ((err = snd_es18xx_mixer(chip)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
+       if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0)
+               goto _err;
+
+       if ((err = snd_es18xx_mixer(chip)) < 0)
+               goto _err;
 
        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
                if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) {
-                       snd_printk(KERN_ERR PFX "opl3 not detected at 0x%lx\n", chip->fm_port);
+                       snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port);
                } else {
-                       if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
-                               snd_card_free(card);
-                               return err;
-                       }
+                       if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
+                               goto _err;
                }
        }
 
@@ -2088,25 +2081,28 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard,
                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
                                               chip->mpu_port, 0,
                                               xirq, 0,
-                                              &rmidi)) < 0) {
-                       snd_card_free(card);
-                       return err;
-               }
-               chip->rmidi = rmidi;
+                                              &chip->rmidi)) < 0)
+                       goto _err;
        }
 
+       if ((err = snd_card_set_generic_dev(card)) < 0)
+               goto _err;
+
        /* Power Management */
        snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip);
 
-       if ((err = snd_card_register(card)) < 0) {
-               snd_card_free(card);
-               return err;
-       }
+       if ((err = snd_card_register(card)) < 0)
+               goto _err;
+
        if (pcard)
                pnp_set_card_drvdata(pcard, card);
        else
                snd_audiodrive_legacy[dev] = card;
        return 0;
+
+ _err:
+       snd_card_free(card);
+       return err;
 }
 
 static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport)
@@ -2117,10 +2113,8 @@ static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport)
        for ( ; dev < SNDRV_CARDS; dev++) {
                if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT)
                        continue;
-#ifdef CONFIG_PNP
-               if (isapnp[dev])
+               if (is_isapnp_selected(dev))
                        continue;
-#endif
                port[dev] = xport;
                res = snd_audiodrive_probe(dev, NULL, NULL);
                if (res < 0)
@@ -2177,10 +2171,8 @@ static int __init alsa_card_es18xx_init(void)
        for (dev = 0; dev < SNDRV_CARDS; dev++) {
                if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT)
                        continue;
-#ifdef CONFIG_PNP
-               if (isapnp[dev])
+               if (is_isapnp_selected(dev))
                        continue;
-#endif
                if (snd_audiodrive_probe(dev, NULL, NULL) >= 0)
                        cards++;
        }