vserver 1.9.3
[linux-2.6.git] / sound / pci / vx222 / vx222.c
index 9f4ef46..4dd658d 100644 (file)
 #include <sound/initval.h>
 #include "vx222.h"
 
-#define chip_t vx_core_t
-
 #define CARD_NAME "VX222"
 
 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
 MODULE_DESCRIPTION("Digigram VX222 V2/Mic");
 MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DEVICES("{{Digigram," CARD_NAME "}}");
+MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}");
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
@@ -47,19 +44,14 @@ static int boot_devs;
 
 module_param_array(index, int, boot_devs, 0444);
 MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
 module_param_array(id, charp, boot_devs, 0444);
 MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
 module_param_array(enable, bool, boot_devs, 0444);
 MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
 module_param_array(mic, bool, boot_devs, 0444);
 MODULE_PARM_DESC(mic, "Enable Microphone.");
-MODULE_PARM_SYNTAX(mic, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
 module_param_array(ibl, int, boot_devs, 0444);
 MODULE_PARM_DESC(ibl, "Capture IBL size.");
-MODULE_PARM_SYNTAX(ibl, SNDRV_ENABLED);
 
 /*
  */
@@ -119,24 +111,19 @@ static struct snd_vx_hardware vx222_mic_hw = {
  */
 static int snd_vx222_free(vx_core_t *chip)
 {
-       int i;
        struct snd_vx222 *vx = (struct snd_vx222 *)chip;
 
        if (chip->irq >= 0)
                free_irq(chip->irq, (void*)chip);
-       for (i = 0; i < 2; i++) {
-               if (vx->port_res[i]) {
-                       release_resource(vx->port_res[i]);
-                       kfree_nocheck(vx->port_res[i]);
-               }
-       }
-       snd_magic_kfree(chip);
+       if (vx->port[0])
+               pci_release_regions(vx->pci);
+       kfree(chip);
        return 0;
 }
 
 static int snd_vx222_dev_free(snd_device_t *device)
 {
-       vx_core_t *chip = snd_magic_cast(vx_core_t, device->device_data, return -ENXIO);
+       vx_core_t *chip = device->device_data;
        return snd_vx222_free(chip);
 }
 
@@ -164,21 +151,14 @@ static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci,
        if (! chip)
                return -ENOMEM;
        vx = (struct snd_vx222 *)chip;
+       vx->pci = pci;
 
-       for (i = 0; i < 2; i++) {
-               if (!(pci_resource_flags(pci, i + 1) & IORESOURCE_IO)) {
-                       snd_printk(KERN_ERR "invalid i/o resource %d\n", i + 1);
-                       snd_vx222_free(chip);
-                       return -ENOMEM;
-               }
-               vx->port[i] = pci_resource_start(pci, i + 1);
-               if ((vx->port_res[i] = request_region(vx->port[i], 0x60,
-                                                     CARD_NAME)) == NULL) {
-                       snd_printk(KERN_ERR "unable to grab port 0x%lx\n", vx->port[i]);
-                       snd_vx222_free(chip);
-                       return -EBUSY;
-               }
+       if ((err = pci_request_regions(pci, CARD_NAME)) < 0) {
+               snd_vx222_free(chip);
+               return err;
        }
+       for (i = 0; i < 2; i++)
+               vx->port[i] = pci_resource_start(pci, i + 1);
 
        if (request_irq(pci->irq, snd_vx_irq_handler, SA_INTERRUPT|SA_SHIRQ,
                        CARD_NAME, (void *) chip)) {