sound: use DEFINE_PCI_DEVICE_TABLE
[safe/jmp/linux-2.6] / sound / pci / mixart / mixart.c
index 880b824..7e8e7da 100644 (file)
@@ -21,7 +21,6 @@
  */
 
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
@@ -61,8 +60,8 @@ MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
 /*
  */
 
-static struct pci_device_id snd_mixart_ids[] = {
-       { 0x1057, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* MC8240 */
+static DEFINE_PCI_DEVICE_TABLE(snd_mixart_ids) = {
+       { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */
        { 0, }
 };
 
@@ -608,6 +607,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
        /* set the format to the board */
        err = mixart_set_format(stream, format);
        if(err < 0) {
+               mutex_unlock(&mgr->setup_mutex);
                return err;
        }
 
@@ -709,7 +709,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
                pcm_number = MIXART_PCM_ANALOG;
                runtime->hw = snd_mixart_analog_caps;
        } else {
-               snd_assert ( pcm == chip->pcm_dig ); 
+               snd_BUG_ON(pcm != chip->pcm_dig);
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
@@ -784,7 +784,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
                pcm_number = MIXART_PCM_ANALOG;
                runtime->hw = snd_mixart_analog_caps;
        } else {
-               snd_assert ( pcm == chip->pcm_dig ); 
+               snd_BUG_ON(pcm != chip->pcm_dig);
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
@@ -1011,7 +1011,7 @@ static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *
                .dev_free = snd_mixart_chip_dev_free,
        };
 
-       mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (! chip) {
                snd_printk(KERN_ERR "cannot allocate chip\n");
                return -ENOMEM;
@@ -1026,6 +1026,7 @@ static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *
                return err;
        }
 
+       mgr->chip[idx] = chip;
        snd_card_set_dev(card, &mgr->pci->dev);
 
        return 0;
@@ -1290,7 +1291,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        pci_set_master(pci);
 
        /* check if we can restrict PCI DMA transfers to 32 bits */
-       if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) {
+       if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
                snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
@@ -1315,8 +1316,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        }
        for (i = 0; i < 2; i++) {
                mgr->mem[i].phys = pci_resource_start(pci, i);
-               mgr->mem[i].virt = ioremap_nocache(mgr->mem[i].phys,
-                                                  pci_resource_len(pci, i));
+               mgr->mem[i].virt = pci_ioremap_bar(pci, i);
                if (!mgr->mem[i].virt) {
                        printk(KERN_ERR "unable to remap resource 0x%lx\n",
                               mgr->mem[i].phys);
@@ -1366,12 +1366,12 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
                else
                        idx = index[dev] + i;
                snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
-               card = snd_card_new(idx, tmpid, THIS_MODULE, 0);
+               err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card);
 
-               if (! card) {
+               if (err < 0) {
                        snd_printk(KERN_ERR "cannot allocate the card %d\n", i);
                        snd_mixart_free(mgr);
-                       return -ENOMEM;
+                       return err;
                }
 
                strcpy(card->driver, CARD_NAME);
@@ -1379,6 +1379,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
                sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
 
                if ((err = snd_mixart_create(mgr, card, i)) < 0) {
+                       snd_card_free(card);
                        snd_mixart_free(mgr);
                        return err;
                }