vserver 1.9.5.x5
[linux-2.6.git] / sound / pci / azt3328.c
index c3d65d9..6127942 100644 (file)
@@ -165,16 +165,15 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;        /* Enable this card *
 #ifdef SUPPORT_JOYSTICK
 static int joystick[SNDRV_CARDS];
 #endif
-static int boot_devs;
 
-module_param_array(index, int, boot_devs, 0444);
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard.");
-module_param_array(id, charp, boot_devs, 0444);
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for AZF3328 soundcard.");
-module_param_array(enable, bool, boot_devs, 0444);
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard.");
 #ifdef SUPPORT_JOYSTICK
-module_param_array(joystick, bool, boot_devs, 0444);
+module_param_array(joystick, bool, NULL, 0444);
 MODULE_PARM_DESC(joystick, "Enable joystick for AZF3328 soundcard.");
 #endif
 
@@ -215,17 +214,17 @@ static struct pci_device_id snd_azf3328_ids[] = {
 
 MODULE_DEVICE_TABLE(pci, snd_azf3328_ids);
 
-void snd_azf3328_io2_write(azf3328_t *chip, int reg, unsigned char value)
+static inline void snd_azf3328_io2_write(azf3328_t *chip, int reg, unsigned char value)
 {
        outb(value, chip->io2_port + reg);
 }
 
-unsigned char snd_azf3328_io2_read(azf3328_t *chip, int reg)
+static inline unsigned char snd_azf3328_io2_read(azf3328_t *chip, int reg)
 {
        return inb(chip->io2_port + reg);
 }
 
-void snd_azf3328_mixer_write(azf3328_t *chip, int reg, unsigned long value, int type)
+static void snd_azf3328_mixer_write(azf3328_t *chip, int reg, unsigned long value, int type)
 {
        switch(type) {
        case WORD_VALUE:
@@ -240,26 +239,7 @@ void snd_azf3328_mixer_write(azf3328_t *chip, int reg, unsigned long value, int
        }
 }
 
-unsigned long snd_azf3328_mixer_read(azf3328_t *chip, int reg, int type)
-{
-       unsigned long res = 0;
-
-       switch(type) {
-       case WORD_VALUE:
-               res = (unsigned long)inw(chip->mixer_port + reg);
-               break;
-       case DWORD_VALUE:
-               res = (unsigned long)inl(chip->mixer_port + reg);
-               break;
-       case BYTE_VALUE:
-               res = (unsigned long)inb(chip->mixer_port + reg);
-               break;
-       }
-
-       return res;
-}
-
-void snd_azf3328_mixer_set_mute(azf3328_t *chip, int reg, int do_mute)
+static void snd_azf3328_mixer_set_mute(azf3328_t *chip, int reg, int do_mute)
 {
        unsigned char oldval;
 
@@ -273,7 +253,7 @@ void snd_azf3328_mixer_set_mute(azf3328_t *chip, int reg, int do_mute)
        outb(oldval, chip->mixer_port + reg + 1);
 }
 
-void snd_azf3328_mixer_write_volume_gradually(azf3328_t *chip, int reg, unsigned char dst_vol_left, unsigned char dst_vol_right, int chan_sel, int delay)
+static void snd_azf3328_mixer_write_volume_gradually(azf3328_t *chip, int reg, unsigned char dst_vol_left, unsigned char dst_vol_right, int chan_sel, int delay)
 {
        unsigned char curr_vol_left = 0, curr_vol_right = 0;
        int left_done = 0, right_done = 0;
@@ -1269,6 +1249,7 @@ static int snd_azf3328_free(azf3328_t *chip)
         if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
        pci_release_regions(chip->pci);
+       pci_disable_device(chip->pci);
 
         kfree(chip);
         return 0;
@@ -1318,8 +1299,10 @@ static int __devinit snd_azf3328_create(snd_card_t * card,
                return err;
 
        chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
-       if (chip == NULL)
+       if (chip == NULL) {
+               pci_disable_device(pci);
                return -ENOMEM;
+       }
        spin_lock_init(&chip->reg_lock);
        chip->card = card;
        chip->pci = pci;
@@ -1329,11 +1312,13 @@ static int __devinit snd_azf3328_create(snd_card_t * card,
        if (pci_set_dma_mask(pci, 0x00ffffff) < 0 ||
            pci_set_consistent_dma_mask(pci, 0x00ffffff) < 0) {
                snd_printk("architecture does not support 24bit PCI busmaster DMA\n");
+               pci_disable_device(pci);
                return -ENXIO;
        }
 
        if ((err = pci_request_regions(pci, "Aztech AZF3328")) < 0) {
                kfree(chip);
+               pci_disable_device(pci);
                return err;
        }
 
@@ -1359,15 +1344,15 @@ static int __devinit snd_azf3328_create(snd_card_t * card,
        for (tmp=0; tmp <= 0x01; tmp += 1)
                snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp));
 
-       /* create mixer interface & switches */
-       if ((err = snd_azf3328_mixer_new(chip)) < 0)
-               return err;
-
        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
                snd_azf3328_free(chip);
                return err;
        }
 
+       /* create mixer interface & switches */
+       if ((err = snd_azf3328_mixer_new(chip)) < 0)
+               return err;
+
 #if 0
        /* set very low bitrate to reduce noise and power consumption? */
        snd_azf3328_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, 5512, 8, 1);