| From 50fef689bcf05080c672ffdf30c05e491afcf8b0 Mon Sep 17 00:00:00 2001 |
| From: Mika Westerberg <mika.westerberg@linux.intel.com> |
| Date: Mon, 13 May 2013 13:45:10 +0300 |
| Subject: spi/pxa2xx: convert to dma_request_slave_channel_compat() |
| |
| Now that we have these nice DMA API helper functions we can take advantage |
| of those instead of open-coding the channel/request line extraction from |
| ACPI. Use the _compat version which still allows passing the |
| channel/request line from platform data. |
| |
| Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> |
| Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| (cherry picked from commit cddb339badb03dd96a5272195eec17e7899df154) |
| Signed-off-by: Darren Hart <dvhart@linux.intel.com> |
| --- |
| drivers/spi/spi-pxa2xx-dma.c | 11 ++++++----- |
| drivers/spi/spi-pxa2xx.c | 34 ++-------------------------------- |
| 2 files changed, 8 insertions(+), 37 deletions(-) |
| |
| --- a/drivers/spi/spi-pxa2xx-dma.c |
| +++ b/drivers/spi/spi-pxa2xx-dma.c |
| @@ -327,22 +327,23 @@ void pxa2xx_spi_dma_start(struct driver_ |
| int pxa2xx_spi_dma_setup(struct driver_data *drv_data) |
| { |
| struct pxa2xx_spi_master *pdata = drv_data->master_info; |
| + struct device *dev = &drv_data->pdev->dev; |
| dma_cap_mask_t mask; |
| |
| dma_cap_zero(mask); |
| dma_cap_set(DMA_SLAVE, mask); |
| |
| - drv_data->dummy = devm_kzalloc(&drv_data->pdev->dev, SZ_2K, GFP_KERNEL); |
| + drv_data->dummy = devm_kzalloc(dev, SZ_2K, GFP_KERNEL); |
| if (!drv_data->dummy) |
| return -ENOMEM; |
| |
| - drv_data->tx_chan = dma_request_channel(mask, pxa2xx_spi_dma_filter, |
| - pdata); |
| + drv_data->tx_chan = dma_request_slave_channel_compat(mask, |
| + pxa2xx_spi_dma_filter, pdata, dev, "tx"); |
| if (!drv_data->tx_chan) |
| return -ENODEV; |
| |
| - drv_data->rx_chan = dma_request_channel(mask, pxa2xx_spi_dma_filter, |
| - pdata); |
| + drv_data->rx_chan = dma_request_slave_channel_compat(mask, |
| + pxa2xx_spi_dma_filter, pdata, dev, "rx"); |
| if (!drv_data->rx_chan) { |
| dma_release_channel(drv_data->tx_chan); |
| drv_data->tx_chan = NULL; |
| --- a/drivers/spi/spi-pxa2xx.c |
| +++ b/drivers/spi/spi-pxa2xx.c |
| @@ -1044,32 +1044,10 @@ static void cleanup(struct spi_device *s |
| } |
| |
| #ifdef CONFIG_ACPI |
| -static int pxa2xx_spi_acpi_add_dma(struct acpi_resource *res, void *data) |
| -{ |
| - struct pxa2xx_spi_master *pdata = data; |
| - |
| - if (res->type == ACPI_RESOURCE_TYPE_FIXED_DMA) { |
| - const struct acpi_resource_fixed_dma *dma; |
| - |
| - dma = &res->data.fixed_dma; |
| - if (pdata->tx_slave_id < 0) { |
| - pdata->tx_slave_id = dma->request_lines; |
| - pdata->tx_chan_id = dma->channels; |
| - } else if (pdata->rx_slave_id < 0) { |
| - pdata->rx_slave_id = dma->request_lines; |
| - pdata->rx_chan_id = dma->channels; |
| - } |
| - } |
| - |
| - /* Tell the ACPI core to skip this resource */ |
| - return 1; |
| -} |
| - |
| static struct pxa2xx_spi_master * |
| pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) |
| { |
| struct pxa2xx_spi_master *pdata; |
| - struct list_head resource_list; |
| struct acpi_device *adev; |
| struct ssp_device *ssp; |
| struct resource *res; |
| @@ -1107,15 +1085,7 @@ pxa2xx_spi_acpi_get_pdata(struct platfor |
| ssp->port_id = devid; |
| |
| pdata->num_chipselect = 1; |
| - pdata->rx_slave_id = -1; |
| - pdata->tx_slave_id = -1; |
| - |
| - INIT_LIST_HEAD(&resource_list); |
| - acpi_dev_get_resources(adev, &resource_list, pxa2xx_spi_acpi_add_dma, |
| - pdata); |
| - acpi_dev_free_resource_list(&resource_list); |
| - |
| - pdata->enable_dma = pdata->rx_slave_id >= 0 && pdata->tx_slave_id >= 0; |
| + pdata->enable_dma = true; |
| |
| return pdata; |
| } |
| @@ -1218,7 +1188,7 @@ static int pxa2xx_spi_probe(struct platf |
| if (platform_info->enable_dma) { |
| status = pxa2xx_spi_dma_setup(drv_data); |
| if (status) { |
| - dev_warn(dev, "failed to setup DMA, using PIO\n"); |
| + dev_dbg(dev, "no DMA channels available, using PIO\n"); |
| platform_info->enable_dma = false; |
| } |
| } |