vserver 1.9.3
[linux-2.6.git] / sound / pci / korg1212 / korg1212.c
index edd2260..c04462f 100644 (file)
@@ -343,12 +343,6 @@ struct _snd_korg1212 {
         unsigned long inIRQ;
         unsigned long iobase;
 
-       struct resource *res_iomem;
-       struct resource *res_ioport;
-       struct resource *res_iomem2;
-
-       struct snd_dma_device dma_dev;
-
        struct snd_dma_buffer dma_dsp;
         struct snd_dma_buffer dma_play;
         struct snd_dma_buffer dma_rec;
@@ -411,8 +405,7 @@ struct _snd_korg1212 {
 
 MODULE_DESCRIPTION("korg1212");
 MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DEVICES("{{KORG,korg1212}}");
+MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;         /* ID for this card */
@@ -421,13 +414,10 @@ static int boot_devs;
 
 module_param_array(index, int, boot_devs, 0444);
 MODULE_PARM_DESC(index, "Index value for Korg 1212 soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
 module_param_array(id, charp, boot_devs, 0444);
 MODULE_PARM_DESC(id, "ID string for Korg 1212 soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
 module_param_array(enable, bool, boot_devs, 0444);
 MODULE_PARM_DESC(enable, "Enable Korg 1212 soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
 MODULE_AUTHOR("Haroldo Gamal <gamal@alternex.com.br>");
 
 static struct pci_device_id snd_korg1212_ids[] = {
@@ -637,7 +627,7 @@ static void snd_korg1212_SendStopAndWait(korg1212_t *korg1212)
 /* timer callback for checking the ack of stop request */
 static void snd_korg1212_timer_func(unsigned long data)
 {
-        korg1212_t *korg1212 = snd_magic_cast(korg1212_t, (void*)data, return);
+        korg1212_t *korg1212 = (korg1212_t *) data;
        
        spin_lock(&korg1212->lock);
        if (readl(&korg1212->sharedBufferPtr->cardCommand) == 0) {
@@ -1143,7 +1133,7 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212)
 static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
         u32 doorbellValue;
-        korg1212_t *korg1212 = snd_magic_cast(korg1212_t, dev_id, return IRQ_NONE);
+        korg1212_t *korg1212 = dev_id;
 
        if(irq != korg1212->irq)
                return IRQ_NONE;
@@ -1407,7 +1397,7 @@ static void snd_korg1212_free_pcm(snd_pcm_t *pcm)
 static int snd_korg1212_playback_open(snd_pcm_substream_t *substream)
 {
         unsigned long flags;
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
         snd_pcm_runtime_t *runtime = substream->runtime;
 
 #if K1212_DEBUG_LEVEL > 0
@@ -1419,8 +1409,7 @@ static int snd_korg1212_playback_open(snd_pcm_substream_t *substream)
        snd_korg1212_OpenCard(korg1212);
 
         runtime->hw = snd_korg1212_playback_info;
-       runtime->dma_area = (char *) korg1212->playDataBufsPtr;
-       runtime->dma_bytes = K1212_BUF_SIZE;
+       snd_pcm_set_runtime_buffer(substream, &korg1212->dma_play);
 
         spin_lock_irqsave(&korg1212->lock, flags);
 
@@ -1438,7 +1427,7 @@ static int snd_korg1212_playback_open(snd_pcm_substream_t *substream)
 static int snd_korg1212_capture_open(snd_pcm_substream_t *substream)
 {
         unsigned long flags;
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
         snd_pcm_runtime_t *runtime = substream->runtime;
 
 #if K1212_DEBUG_LEVEL > 0
@@ -1450,8 +1439,7 @@ static int snd_korg1212_capture_open(snd_pcm_substream_t *substream)
        snd_korg1212_OpenCard(korg1212);
 
         runtime->hw = snd_korg1212_capture_info;
-       runtime->dma_area = (char *) korg1212->recordDataBufsPtr;
-       runtime->dma_bytes = K1212_BUF_SIZE;
+       snd_pcm_set_runtime_buffer(substream, &korg1212->dma_rec);
 
         spin_lock_irqsave(&korg1212->lock, flags);
 
@@ -1468,7 +1456,7 @@ static int snd_korg1212_capture_open(snd_pcm_substream_t *substream)
 static int snd_korg1212_playback_close(snd_pcm_substream_t *substream)
 {
         unsigned long flags;
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
 
 #if K1212_DEBUG_LEVEL > 0
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", stateName[korg1212->cardState]);
@@ -1490,7 +1478,7 @@ static int snd_korg1212_playback_close(snd_pcm_substream_t *substream)
 static int snd_korg1212_capture_close(snd_pcm_substream_t *substream)
 {
         unsigned long flags;
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
 
 #if K1212_DEBUG_LEVEL > 0
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", stateName[korg1212->cardState]);
@@ -1532,7 +1520,7 @@ static int snd_korg1212_hw_params(snd_pcm_substream_t *substream,
                              snd_pcm_hw_params_t *params)
 {
         unsigned long flags;
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
         int err;
 
 #if K1212_DEBUG_LEVEL > 0
@@ -1560,21 +1548,21 @@ static int snd_korg1212_hw_params(snd_pcm_substream_t *substream,
 
 static int snd_korg1212_prepare(snd_pcm_substream_t *substream)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
        int rc;
 
 #if K1212_DEBUG_LEVEL > 0
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", stateName[korg1212->cardState]);
 #endif
 
-        spin_lock(&korg1212->lock);
+       spin_lock_irq(&korg1212->lock);
 
        /* FIXME: we should wait for ack! */
        if (korg1212->stop_pending_cnt > 0) {
 #if K1212_DEBUG_LEVEL > 0
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", stateName[korg1212->cardState]);
 #endif
-               spin_unlock(&korg1212->lock);
+               spin_unlock_irq(&korg1212->lock);
                return -EAGAIN;
                /*
                writel(0, &korg1212->sharedBufferPtr->cardCommand);
@@ -1587,7 +1575,7 @@ static int snd_korg1212_prepare(snd_pcm_substream_t *substream)
 
         korg1212->currentBuffer = 0;
 
-        spin_unlock(&korg1212->lock);
+        spin_unlock_irq(&korg1212->lock);
 
        return rc ? -EINVAL : 0;
 }
@@ -1595,7 +1583,7 @@ static int snd_korg1212_prepare(snd_pcm_substream_t *substream)
 static int snd_korg1212_trigger(snd_pcm_substream_t *substream,
                            int cmd)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
        int rc;
 
 #if K1212_DEBUG_LEVEL > 0
@@ -1640,7 +1628,7 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream,
 
 static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *substream)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
         snd_pcm_uframes_t pos;
 
        pos = korg1212->currentBuffer * kPlayBufferFrames;
@@ -1655,7 +1643,7 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *subs
 
 static snd_pcm_uframes_t snd_korg1212_capture_pointer(snd_pcm_substream_t *substream)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
         snd_pcm_uframes_t pos;
 
        pos = korg1212->currentBuffer * kPlayBufferFrames;
@@ -1674,7 +1662,7 @@ static int snd_korg1212_playback_copy(snd_pcm_substream_t *substream,
                         void __user *src,
                         snd_pcm_uframes_t count)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
 
 #if K1212_DEBUG_LEVEL > 2
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count);
@@ -1689,7 +1677,7 @@ static int snd_korg1212_playback_silence(snd_pcm_substream_t *substream,
                            snd_pcm_uframes_t pos,
                            snd_pcm_uframes_t count)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
 
 #if K1212_DEBUG_LEVEL > 0
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", stateName[korg1212->cardState]);
@@ -1704,7 +1692,7 @@ static int snd_korg1212_capture_copy(snd_pcm_substream_t *substream,
                         void __user *dst,
                         snd_pcm_uframes_t count)
 {
-        korg1212_t *korg1212 = _snd_pcm_substream_chip(substream);
+        korg1212_t *korg1212 = snd_pcm_substream_chip(substream);
 
 #if K1212_DEBUG_LEVEL > 2
                K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count);
@@ -1749,30 +1737,28 @@ static int snd_korg1212_control_phase_info(snd_kcontrol_t *kcontrol, snd_ctl_ele
 
 static int snd_korg1212_control_phase_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
        int i = kcontrol->private_value;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
         u->value.integer.value[0] = korg1212->volumePhase[i];
 
        if (i >= 8)
                u->value.integer.value[1] = korg1212->volumePhase[i+1];
 
-        spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
 
         return 0;
 }
 
 static int snd_korg1212_control_phase_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
         int change = 0;
         int i, val;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
        i = kcontrol->private_value;
 
@@ -1798,7 +1784,7 @@ static int snd_korg1212_control_phase_put(snd_kcontrol_t *kcontrol, snd_ctl_elem
                }
        }
 
-       spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
 
         return change;
 }
@@ -1814,11 +1800,10 @@ static int snd_korg1212_control_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_el
 
 static int snd_korg1212_control_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
         int i;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
        i = kcontrol->private_value;
         u->value.integer.value[0] = abs(korg1212->sharedBufferPtr->volumeData[i]);
@@ -1826,20 +1811,19 @@ static int snd_korg1212_control_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_ele
        if (i >= 8) 
                 u->value.integer.value[1] = abs(korg1212->sharedBufferPtr->volumeData[i+1]);
 
-        spin_unlock_irqrestore(&korg1212->lock, flags);
+        spin_unlock_irq(&korg1212->lock);
 
         return 0;
 }
 
 static int snd_korg1212_control_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
         int change = 0;
         int i;
        int val;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
        i = kcontrol->private_value;
 
@@ -1859,7 +1843,7 @@ static int snd_korg1212_control_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_ele
                }
        }
 
-       spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
 
         return change;
 }
@@ -1878,11 +1862,10 @@ static int snd_korg1212_control_route_info(snd_kcontrol_t *kcontrol, snd_ctl_ele
 
 static int snd_korg1212_control_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
         int i;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
        i = kcontrol->private_value;
        u->value.enumerated.item[0] = korg1212->sharedBufferPtr->routeData[i];
@@ -1890,18 +1873,17 @@ static int snd_korg1212_control_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem
        if (i >= 8) 
                u->value.enumerated.item[1] = korg1212->sharedBufferPtr->routeData[i+1];
 
-        spin_unlock_irqrestore(&korg1212->lock, flags);
+        spin_unlock_irq(&korg1212->lock);
 
         return 0;
 }
 
 static int snd_korg1212_control_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
         int change = 0, i;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
        i = kcontrol->private_value;
 
@@ -1917,7 +1899,7 @@ static int snd_korg1212_control_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem
                }
        }
 
-       spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
 
         return change;
 }
@@ -1933,26 +1915,24 @@ static int snd_korg1212_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info
 
 static int snd_korg1212_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
         u->value.integer.value[0] = korg1212->leftADCInSens;
         u->value.integer.value[1] = korg1212->rightADCInSens;
 
-        spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
 
         return 0;
 }
 
 static int snd_korg1212_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
         int change = 0;
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
         if (u->value.integer.value[0] != korg1212->leftADCInSens) {
                 korg1212->leftADCInSens = u->value.integer.value[0];
@@ -1963,7 +1943,7 @@ static int snd_korg1212_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value
                 change = 1;
         }
 
-       spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
 
         if (change)
                 snd_korg1212_WriteADCSensitivity(korg1212);
@@ -1985,29 +1965,27 @@ static int snd_korg1212_control_sync_info(snd_kcontrol_t *kcontrol, snd_ctl_elem
 
 static int snd_korg1212_control_sync_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
 
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
 
        ucontrol->value.enumerated.item[0] = korg1212->clkSource;
 
-       spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
        return 0;
 }
 
 static int snd_korg1212_control_sync_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
 {
-       korg1212_t *korg1212 = _snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
+       korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol);
        unsigned int val;
        int change;
 
        val = ucontrol->value.enumerated.item[0] % 3;
-       spin_lock_irqsave(&korg1212->lock, flags);
+       spin_lock_irq(&korg1212->lock);
        change = val != korg1212->clkSource;
         snd_korg1212_SetClockSource(korg1212, val);
-       spin_unlock_irqrestore(&korg1212->lock, flags);
+       spin_unlock_irq(&korg1212->lock);
        return change;
 }
 
@@ -2063,8 +2041,6 @@ static snd_kcontrol_new_t snd_korg1212_controls[] = {
         }
 };
 
-#define K1212_CONTROL_ELEMENTS (sizeof(snd_korg1212_controls) / sizeof(snd_korg1212_controls[0]))
-
 /*
  * proc interface
  */
@@ -2120,29 +2096,13 @@ snd_korg1212_free(korg1212_t *korg1212)
                 korg1212->iobase = 0;
         }
         
-        if (korg1212->res_iomem != NULL) {
-                release_resource(korg1212->res_iomem);
-                kfree_nocheck(korg1212->res_iomem);
-                korg1212->res_iomem = NULL;
-        }
-        
-        if (korg1212->res_ioport != NULL) {
-                release_resource(korg1212->res_ioport);
-                kfree_nocheck(korg1212->res_ioport);
-                korg1212->res_ioport = NULL;
-        }
-        
-        if (korg1212->res_iomem2 != NULL) {
-                release_resource(korg1212->res_iomem2);
-                kfree_nocheck(korg1212->res_iomem2);
-                korg1212->res_iomem2 = NULL;
-        }
+       pci_release_regions(korg1212->pci);
 
         // ----------------------------------------------------
         // free up memory resources used for the DSP download.
         // ----------------------------------------------------
         if (korg1212->dma_dsp.area) {
-               snd_dma_free_pages(&korg1212->dma_dev, &korg1212->dma_dsp);
+               snd_dma_free_pages(&korg1212->dma_dsp);
                korg1212->dma_dsp.area = NULL;
         }
 
@@ -2152,12 +2112,12 @@ snd_korg1212_free(korg1212_t *korg1212)
         // free up memory resources used for the Play/Rec Buffers
         // ------------------------------------------------------
        if (korg1212->dma_play.area) {
-               snd_dma_free_pages(&korg1212->dma_dev, &korg1212->dma_play);
+               snd_dma_free_pages(&korg1212->dma_play);
                korg1212->dma_play.area = NULL;
         }
 
        if (korg1212->dma_rec.area) {
-               snd_dma_free_pages(&korg1212->dma_dev, &korg1212->dma_rec);
+               snd_dma_free_pages(&korg1212->dma_rec);
                korg1212->dma_rec.area = NULL;
         }
 
@@ -2167,17 +2127,17 @@ snd_korg1212_free(korg1212_t *korg1212)
         // free up memory resources used for the Shared Buffers
         // ----------------------------------------------------
        if (korg1212->dma_shared.area) {
-               snd_dma_free_pages(&korg1212->dma_dev, &korg1212->dma_shared);
+               snd_dma_free_pages(&korg1212->dma_shared);
                korg1212->dma_shared.area = NULL;
         }
         
-        snd_magic_kfree(korg1212);
+        kfree(korg1212);
         return 0;
 }
 
 static int snd_korg1212_dev_free(snd_device_t *device)
 {
-        korg1212_t *korg1212 = snd_magic_cast(korg1212_t, device->device_data, return -ENXIO);
+        korg1212_t *korg1212 = device->device_data;
 #if K1212_DEBUG_LEVEL > 0
         K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n");
 #endif
@@ -2201,7 +2161,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
         if ((err = pci_enable_device(pci)) < 0)
                 return err;
 
-        korg1212 = snd_magic_kcalloc(korg1212_t, 0, GFP_KERNEL);
+        korg1212 = kcalloc(1, sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 == NULL)
                 return -ENOMEM;
 
@@ -2232,6 +2192,11 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
         for (i=0; i<kAudioChannels; i++)
                 korg1212->volumePhase[i] = 0;
 
+       if ((err = pci_request_regions(pci, "korg1212")) < 0) {
+               kfree(korg1212);
+               return err;
+       }
+
         korg1212->iomem = pci_resource_start(korg1212->pci, 0);
         korg1212->ioport = pci_resource_start(korg1212->pci, 1);
         korg1212->iomem2 = pci_resource_start(korg1212->pci, 2);
@@ -2252,27 +2217,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
                   stateName[korg1212->cardState]);
 #endif
 
-        korg1212->res_iomem = request_mem_region(korg1212->iomem, iomem_size, "korg1212");
-        if (korg1212->res_iomem == NULL) {
-               snd_printk(KERN_ERR "unable to grab region 0x%lx-0x%lx\n",
-                           korg1212->iomem, korg1212->iomem + iomem_size - 1);
-                return -EBUSY;
-        }
-
-        korg1212->res_ioport = request_region(korg1212->ioport, ioport_size, "korg1212");
-        if (korg1212->res_ioport == NULL) {
-               snd_printk(KERN_ERR "unable to grab region 0x%lx-0x%lx\n",
-                           korg1212->ioport, korg1212->ioport + ioport_size - 1);
-                return -EBUSY;
-        }
-
-        korg1212->res_iomem2 = request_mem_region(korg1212->iomem2, iomem2_size, "korg1212");
-        if (korg1212->res_iomem2 == NULL) {
-               snd_printk(KERN_ERR "unable to grab region 0x%lx-0x%lx\n",
-                           korg1212->iomem2, korg1212->iomem2 + iomem2_size - 1);
-                return -EBUSY;
-        }
-
         if ((korg1212->iobase = (unsigned long) ioremap(korg1212->iomem, iomem_size)) == 0) {
                snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", korg1212->iobase,
                            korg1212->iobase + iomem_size - 1);
@@ -2329,11 +2273,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
                   stateName[korg1212->cardState]);
 #endif
 
-       memset(&korg1212->dma_dev, 0, sizeof(korg1212->dma_dev));
-       korg1212->dma_dev.type = SNDRV_DMA_TYPE_DEV;
-       korg1212->dma_dev.dev = snd_dma_pci_data(korg1212->pci);
-
-       if (snd_dma_alloc_pages(&korg1212->dma_dev, sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) {
+       if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+                               sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) {
                snd_printk(KERN_ERR "can not allocate shared buffer memory (%Zd bytes)\n", sizeof(KorgSharedBuffer));
                 return -ENOMEM;
         }
@@ -2348,7 +2289,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
 
         korg1212->DataBufsSize = sizeof(KorgAudioBuffer) * kNumBuffers;
 
-       if (snd_dma_alloc_pages(&korg1212->dma_dev, korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
+       if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+                               korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
                snd_printk(KERN_ERR "can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
                 return -ENOMEM;
         }
@@ -2360,7 +2302,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
                korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize);
 #endif
 
-       if (snd_dma_alloc_pages(&korg1212->dma_dev, korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
+       if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+                               korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
                snd_printk(KERN_ERR "can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
                 return -ENOMEM;
         }
@@ -2390,7 +2333,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
         korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
                offsetof(KorgSharedBuffer, AdatTimeCode);
 
-       if (snd_dma_alloc_pages(&korg1212->dma_dev, korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) {
+       if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
+                               korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) {
                snd_printk(KERN_ERR "can not allocate dsp code memory (%d bytes)\n", korg1212->dspCodeSize);
                 return -ENOMEM;
         }
@@ -2420,7 +2364,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
                "VolumeTablePhy  = %08x L[%08x]\n"
                "RoutingTablePhy = %08x L[%08x]\n"
                "AdatTimeCodePhy = %08x L[%08x]\n",
-              korg1212->dma_dsp.addr,    UpperWordSwap(korg1212->dma_dsp.addr),
+              (int)korg1212->dma_dsp.addr,    UpperWordSwap(korg1212->dma_dsp.addr),
                korg1212->PlayDataPhy,     LowerWordSwap(korg1212->PlayDataPhy),
                korg1212->RecDataPhy,      LowerWordSwap(korg1212->RecDataPhy),
                korg1212->VolumeTablePhy,  LowerWordSwap(korg1212->VolumeTablePhy),
@@ -2443,7 +2387,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci,
        //snd_pcm_lib_preallocate_pages_for_all(korg1212->pcm,
        //                      K1212_MAX_BUF_SIZE, K1212_MAX_BUF_SIZE, GFP_KERNEL);
 
-        for (i = 0; i < K1212_CONTROL_ELEMENTS; i++) {
+        for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) {
                 err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212));
                 if (err < 0)
                         return err;