Skip to contentSkip to conversation

spi/pxa2xx: fix compile warning in pxa2xx_spi_acpi_get_pdata()

PATCH Applied Mika Westerberg 2 participants 4 messages May 13, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 spi/pxa2xx: fix compile warning in pxa2xx_spi_acpi_get_pdata()

Commit cbfd6a21b6f (spi/pxa2xx: Convert to devm_ioremap_resource()) converted the driver to use devm_ioremap_resource(). However it causes following warning to be emitted:

drivers/spi/spi-pxa2xx.c: In function ‘pxa2xx_spi_acpi_get_pdata’:
drivers/spi/spi-pxa2xx.c:1094:3: warning: return makes pointer from integer without a cast [enabled by default]

Fix this by returning NULL as it was done previously (error printing is already done by devm_ioremap_resource()).

---
 drivers/spi/spi-pxa2xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-pxa2xx.c +1 -1
index f5d84d6..e5d7823 100644
@@ -1091,7 +1091,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
 	ssp->phys_base = res->start;
 	ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(ssp->mmio_base))
-		return PTR_ERR(ssp->mmio_base);
+		return NULL;
 
 	ssp->clk = devm_clk_get(&pdev->dev, NULL);
 	ssp->irq = platform_get_irq(pdev, 0);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/3 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.

---
 drivers/spi/spi-pxa2xx-dma.c |   11 ++++++-----
 drivers/spi/spi-pxa2xx.c     |   34 ++--------------------------------
 2 files changed, 8 insertions(+), 37 deletions(-)
drivers/spi/spi-pxa2xx-dma.c +6 -5
index c735c5a..f4cb744 100644
@@ -327,22 +327,23 @@ void pxa2xx_spi_dma_start(struct driver_data *drv_data)
 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;
drivers/spi/spi-pxa2xx.c +2 -32
index e5d7823..d20b31a 100644
@@ -1040,32 +1040,10 @@ static void cleanup(struct spi_device *spi)
 }
 
 #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;
@@ -1103,15 +1081,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
 		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;
 }
@@ -1214,7 +1184,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
 	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;
 		}
 	}
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 3/3 spi/pxa2xx: add Intel BayTrail ACPI ID

In reply to Mika Westerberg

Intel BayTrail has one general purpose SPI controller that is compatible with Intel Low Power Subsystem SPI. The controller is enumerated from ACPI namespace with ACPI ID 80860F0E.

---
 drivers/spi/spi-pxa2xx.c |    1 +
 1 file changed, 1 insertion(+)
drivers/spi/spi-pxa2xx.c +1 -0
index d20b31a..f669953 100644
@@ -1089,6 +1089,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
 static struct acpi_device_id pxa2xx_spi_acpi_match[] = {
 	{ "INT33C0", 0 },
 	{ "INT33C1", 0 },
+	{ "80860F0E", 0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
Signature · 1 line
1.7.10.4
maintainer Applied
#3 lore raw
In reply to Mika Westerberg
Quoted 3 lines · Mika Westerberg

Commit cbfd6a21b6f (spi/pxa2xx: Convert to devm_ioremap_resource()) converted the driver to use devm_ioremap_resource(). However it causes following warning to be emitted:

Applied all, thanks.