ASoC: AIC23: Fixing writes to non-existing registers in resume function
[safe/jmp/linux-2.6] / sound / pci / maestro3.c
index b258297..75283fb 100644 (file)
@@ -1175,7 +1175,8 @@ snd_m3_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
        struct m3_dma *s = subs->runtime->private_data;
        int err = -EINVAL;
 
-       snd_assert(s != NULL, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
 
        spin_lock(&chip->reg_lock);
        switch (cmd) {
@@ -1487,7 +1488,8 @@ snd_m3_pcm_prepare(struct snd_pcm_substream *subs)
        struct snd_pcm_runtime *runtime = subs->runtime;
        struct m3_dma *s = runtime->private_data;
 
-       snd_assert(s != NULL, return -ENXIO);
+       if (snd_BUG_ON(!s))
+               return -ENXIO;
 
        if (runtime->format != SNDRV_PCM_FORMAT_U8 &&
            runtime->format != SNDRV_PCM_FORMAT_S16_LE)
@@ -1546,7 +1548,9 @@ snd_m3_pcm_pointer(struct snd_pcm_substream *subs)
        struct snd_m3 *chip = snd_pcm_substream_chip(subs);
        unsigned int ptr;
        struct m3_dma *s = subs->runtime->private_data;
-       snd_assert(s != NULL, return 0);
+
+       if (snd_BUG_ON(!s))
+               return 0;
 
        spin_lock(&chip->reg_lock);
        ptr = snd_m3_get_pointer(chip, s, subs);
@@ -1666,7 +1670,7 @@ static irqreturn_t snd_m3_interrupt(int irq, void *dev_id)
                return IRQ_NONE;
 
        if (status & HV_INT_PENDING)
-               tasklet_hi_schedule(&chip->hwvol_tq);
+               tasklet_schedule(&chip->hwvol_tq);
 
        /*
         * ack an assp int if its running
@@ -2269,6 +2273,29 @@ snd_m3_amp_enable(struct snd_m3 *chip, int enable)
        outw(0xffff, io + GPIO_MASK);
 }
 
+static void
+snd_m3_hv_init(struct snd_m3 *chip)
+{
+       unsigned long io = chip->iobase;
+       u16 val = GPI_VOL_DOWN | GPI_VOL_UP;
+
+       if (!chip->is_omnibook)
+               return;
+
+       /*
+        * Volume buttons on some HP OmniBook laptops
+        * require some GPIO magic to work correctly.
+        */
+       outw(0xffff, io + GPIO_MASK);
+       outw(0x0000, io + GPIO_DATA);
+
+       outw(~val, io + GPIO_MASK);
+       outw(inw(io + GPIO_DIRECTION) & ~val, io + GPIO_DIRECTION);
+       outw(val, io + GPIO_MASK);
+
+       outw(0xffff, io + GPIO_MASK);
+}
+
 static int
 snd_m3_chip_init(struct snd_m3 *chip)
 {
@@ -2284,21 +2311,6 @@ snd_m3_chip_init(struct snd_m3 *chip)
               DISABLE_LEGACY);
        pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w);
 
-       if (chip->is_omnibook) {
-               /*
-                * Volume buttons on some HP OmniBook laptops don't work
-                * correctly. This makes them work for the most part.
-                *
-                * Volume up and down buttons on the laptop side work.
-                * Fn+cursor_up (volme up) works.
-                * Fn+cursor_down (volume down) doesn't work.
-                * Fn+F7 (mute) works acts as volume up.
-                */
-               outw(~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_MASK);
-               outw(inw(io + GPIO_DIRECTION) & ~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DIRECTION);
-               outw((GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DATA);
-               outw(0xffff, io + GPIO_MASK);
-       }
        pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n);
        n &= ~(HV_CTRL_ENABLE | REDUCED_DEBOUNCE | HV_BUTTON_FROM_GD);
        n |= chip->hv_config;
@@ -2482,6 +2494,8 @@ static int m3_resume(struct pci_dev *pci)
        snd_m3_enable_ints(chip);
        snd_m3_amp_enable(chip, 1);
 
+       snd_m3_hv_init(chip);
+
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
        return 0;
 }
@@ -2516,8 +2530,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
                return -EIO;
 
        /* check, if we can restrict PCI DMA transfers to 28 bits */
-       if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 ||
-           pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) {
+       if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
+           pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
                snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
@@ -2611,6 +2625,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
 
        snd_m3_amp_enable(chip, 1);
 
+       snd_m3_hv_init(chip);
+
        tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip);
 
        if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED,
@@ -2675,9 +2691,9 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
                return -ENOENT;
        }
 
-       card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
-       if (card == NULL)
-               return -ENOMEM;
+       err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
+       if (err < 0)
+               return err;
 
        switch (pci->device) {
        case PCI_DEVICE_ID_ESS_ALLEGRO: