[PATCH] PCI: removed unneeded .owner field from struct pci_driver
[safe/jmp/linux-2.6] / sound / pci / via82xx_modem.c
index 5872d43..b83660b 100644 (file)
@@ -26,7 +26,7 @@
 /*
  * Changes:
  *
- * Sep. 2,  2004  Sasha Khapyorsky <sashak@smlink.com>
+ * Sep. 2,  2004  Sasha Khapyorsky <sashak@alsa-project.org>
  *      Modified from original audio driver 'via82xx.c' to support AC97
  *      modems.
  */
@@ -55,20 +55,21 @@ MODULE_DESCRIPTION("VIA VT82xx modem");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C modem,pci}}");
 
-static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
-static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
-static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
-static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000};
+static int index = -2; /* Exclude the first card */
+static char *id = SNDRV_DEFAULT_STR1;  /* ID for this card */
+static int ac97_clock = 48000;
 
-module_param_array(index, int, NULL, 0444);
+module_param(index, int, 0444);
 MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge.");
-module_param_array(id, charp, NULL, 0444);
+module_param(id, charp, 0444);
 MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge.");
-module_param_array(enable, bool, NULL, 0444);
-MODULE_PARM_DESC(enable, "Enable modem part of VIA 82xx bridge.");
-module_param_array(ac97_clock, int, NULL, 0444);
+module_param(ac97_clock, int, 0444);
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
 
+/* just for backward compatibility */
+static int enable;
+module_param(enable, bool, 0444);
+
 
 /*
  *  Direct registers
@@ -569,7 +570,7 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u
                res = viadev->lastpos;
        } else if (check_invalid_pos(viadev, res)) {
 #ifdef POINTER_DEBUG
-               printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count);
+               printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count);
 #endif
                if (count && size < count) {
                        snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n");
@@ -832,6 +833,7 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip)
                return err;
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via686_playback_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops);
+       pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
        pcm->private_data = chip;
        strcpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
@@ -878,7 +880,6 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip)
                return err;
        chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus;
        chip->ac97_bus->clock = chip->ac97_clock;
-       chip->ac97_bus->shared_type = AC97_SHARED_TYPE_VIA;
 
        memset(&ac97, 0, sizeof(ac97));
        ac97.private_data = chip;
@@ -967,12 +968,11 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
                pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval);
                if (pval & VIA_ACLINK_C00_READY) /* primary codec ready */
                        break;
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_uninterruptible(1);
        } while (time_before(jiffies, end_time));
 
        if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
-               snd_printk("AC'97 codec is not ready [0x%x]\n", val);
+               snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val);
 
        snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
                                 VIA_REG_AC97_SECONDARY_VALID |
@@ -986,8 +986,7 @@ static int snd_via82xx_chip_init(via82xx_t *chip)
                        chip->ac97_secondary = 1;
                        goto __ac97_ok2;
                }
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_interruptible(1);
        } while (time_before(jiffies, end_time));
        /* This is ok, the most of motherboards have only one codec */
 
@@ -1083,7 +1082,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
        if ((err = pci_enable_device(pci)) < 0)
                return err;
 
-       if ((chip = kcalloc(1, sizeof(*chip), GFP_KERNEL)) == NULL) {
+       if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) {
                pci_disable_device(pci);
                return -ENOMEM;
        }
@@ -1101,7 +1100,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
        chip->port = pci_resource_start(pci, 0);
        if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ,
                        card->driver, (void *)chip)) {
-               snd_printk("unable to grab IRQ %d\n", pci->irq);
+               snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                snd_via82xx_free(chip);
                return -EBUSY;
        }
@@ -1135,7 +1134,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
 static int __devinit snd_via82xx_probe(struct pci_dev *pci,
                                       const struct pci_device_id *pci_id)
 {
-       static int dev;
        snd_card_t *card;
        via82xx_t *chip;
        unsigned char revision;
@@ -1143,14 +1141,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
        unsigned int i;
        int err;
 
-       if (dev >= SNDRV_CARDS)
-               return -ENODEV;
-       if (!enable[dev]) {
-               dev++;
-               return -ENOENT;
-       }
-
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
+       card = snd_card_new(index, id, THIS_MODULE, 0);
        if (card == NULL)
                return -ENOMEM;
 
@@ -1167,7 +1158,8 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
                goto __error;
        }
                
-       if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0)
+       if ((err = snd_via82xx_create(card, pci, chip_type, revision,
+                                     ac97_clock, &chip)) < 0)
                goto __error;
        if ((err = snd_via82xx_mixer_new(chip)) < 0)
                goto __error;
@@ -1191,7 +1183,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
                return err;
        }
        pci_set_drvdata(pci, card);
-       dev++;
        return 0;
 
  __error: