ALSA: platform: Check CONFIG_PM_SLEEP instead of CONFIG_PM
[linux-3.10.git] / sound / atmel / ac97c.c
index 61dade6..3c8d3ba 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/gpio.h>
+#include <linux/types.h>
 #include <linux/io.h>
 
 #include <sound/core.h>
@@ -990,6 +991,8 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
                        gpio_direction_output(pdata->reset_pin, 1);
                        chip->reset_pin = pdata->reset_pin;
                }
+       } else {
+               chip->reset_pin = -EINVAL;
        }
 
        snd_card_set_dev(card, &pdev->dev);
@@ -1014,16 +1017,28 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
 
        if (cpu_is_at32ap7000()) {
                if (pdata->rx_dws.dma_dev) {
-                       struct dw_dma_slave *dws = &pdata->rx_dws;
                        dma_cap_mask_t mask;
 
-                       dws->rx_reg = regs->start + AC97C_CARHR + 2;
-
                        dma_cap_zero(mask);
                        dma_cap_set(DMA_SLAVE, mask);
 
                        chip->dma.rx_chan = dma_request_channel(mask, filter,
-                                                               dws);
+                                                               &pdata->rx_dws);
+                       if (chip->dma.rx_chan) {
+                               struct dma_slave_config dma_conf = {
+                                       .src_addr = regs->start + AC97C_CARHR +
+                                               2,
+                                       .src_addr_width =
+                                               DMA_SLAVE_BUSWIDTH_2_BYTES,
+                                       .src_maxburst = 1,
+                                       .dst_maxburst = 1,
+                                       .direction = DMA_DEV_TO_MEM,
+                                       .device_fc = false,
+                               };
+
+                               dmaengine_slave_config(chip->dma.rx_chan,
+                                               &dma_conf);
+                       }
 
                        dev_info(&chip->pdev->dev, "using %s for DMA RX\n",
                                dev_name(&chip->dma.rx_chan->dev->device));
@@ -1031,16 +1046,28 @@ static int __devinit atmel_ac97c_probe(struct platform_device *pdev)
                }
 
                if (pdata->tx_dws.dma_dev) {
-                       struct dw_dma_slave *dws = &pdata->tx_dws;
                        dma_cap_mask_t mask;
 
-                       dws->tx_reg = regs->start + AC97C_CATHR + 2;
-
                        dma_cap_zero(mask);
                        dma_cap_set(DMA_SLAVE, mask);
 
                        chip->dma.tx_chan = dma_request_channel(mask, filter,
-                                                               dws);
+                                                               &pdata->tx_dws);
+                       if (chip->dma.tx_chan) {
+                               struct dma_slave_config dma_conf = {
+                                       .dst_addr = regs->start + AC97C_CATHR +
+                                               2,
+                                       .dst_addr_width =
+                                               DMA_SLAVE_BUSWIDTH_2_BYTES,
+                                       .src_maxburst = 1,
+                                       .dst_maxburst = 1,
+                                       .direction = DMA_MEM_TO_DEV,
+                                       .device_fc = false,
+                               };
+
+                               dmaengine_slave_config(chip->dma.tx_chan,
+                                               &dma_conf);
+                       }
 
                        dev_info(&chip->pdev->dev, "using %s for DMA TX\n",
                                dev_name(&chip->dma.tx_chan->dev->device));
@@ -1107,10 +1134,10 @@ err_snd_card_new:
        return retval;
 }
 
-#ifdef CONFIG_PM
-static int atmel_ac97c_suspend(struct platform_device *pdev, pm_message_t msg)
+#ifdef CONFIG_PM_SLEEP
+static int atmel_ac97c_suspend(struct device *pdev)
 {
-       struct snd_card *card = platform_get_drvdata(pdev);
+       struct snd_card *card = dev_get_drvdata(pdev);
        struct atmel_ac97c *chip = card->private_data;
 
        if (cpu_is_at32ap7000()) {
@@ -1124,9 +1151,9 @@ static int atmel_ac97c_suspend(struct platform_device *pdev, pm_message_t msg)
        return 0;
 }
 
-static int atmel_ac97c_resume(struct platform_device *pdev)
+static int atmel_ac97c_resume(struct device *pdev)
 {
-       struct snd_card *card = platform_get_drvdata(pdev);
+       struct snd_card *card = dev_get_drvdata(pdev);
        struct atmel_ac97c *chip = card->private_data;
 
        clk_enable(chip->pclk);
@@ -1138,9 +1165,11 @@ static int atmel_ac97c_resume(struct platform_device *pdev)
        }
        return 0;
 }
+
+static SIMPLE_DEV_PM_OPS(atmel_ac97c_pm, atmel_ac97c_suspend, atmel_ac97c_resume);
+#define ATMEL_AC97C_PM_OPS     &atmel_ac97c_pm
 #else
-#define atmel_ac97c_suspend NULL
-#define atmel_ac97c_resume NULL
+#define ATMEL_AC97C_PM_OPS     NULL
 #endif
 
 static int __devexit atmel_ac97c_remove(struct platform_device *pdev)
@@ -1183,9 +1212,9 @@ static struct platform_driver atmel_ac97c_driver = {
        .remove         = __devexit_p(atmel_ac97c_remove),
        .driver         = {
                .name   = "atmel_ac97c",
+               .owner  = THIS_MODULE,
+               .pm     = ATMEL_AC97C_PM_OPS,
        },
-       .suspend        = atmel_ac97c_suspend,
-       .resume         = atmel_ac97c_resume,
 };
 
 static int __init atmel_ac97c_init(void)