LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code
@ 2014-12-29 17:20 Fabio Estevam
  2014-12-29 17:20 ` [PATCH 2/3] dmaengine: imx-sdma: Use devm functions Fabio Estevam
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Fabio Estevam @ 2014-12-29 17:20 UTC (permalink / raw)
  To: vinod.koul; +Cc: linux-kernel, shawn.guo, kernel, Fabio Estevam, Maxime Ripard

From: Fabio Estevam <fabio.estevam@freescale.com>

Since ecc19d17868be9c ("dmaengine: Add a warning for drivers not using the
generic slave caps retrieval") the following warning is observed:

[    0.224981] ------------[ cut here ]------------
[    0.225013] WARNING: CPU: 0 PID: 1 at drivers/dma/dmaengine.c:830 dma_async_device_register+0x2a0/0x4c8()
[    0.225023] this driver doesn't support generic slave capabilities reporting

Declare the slave capabilities to avoid such warning.

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/dma/imx-sdma.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index e3dd85a..facb4162 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1595,6 +1595,10 @@ static int sdma_probe(struct platform_device *pdev)
 	sdma->dma_device.device_prep_dma_cyclic = sdma_prep_dma_cyclic;
 	sdma->dma_device.device_config = sdma_config;
 	sdma->dma_device.device_terminate_all = sdma_disable_channel;
+	sdma->dma_device.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
+	sdma->dma_device.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
+	sdma->dma_device.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
+	sdma->dma_device.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
 	sdma->dma_device.device_issue_pending = sdma_issue_pending;
 	sdma->dma_device.dev->dma_parms = &sdma->dma_parms;
 	dma_set_max_seg_size(sdma->dma_device.dev, 65535);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] dmaengine: imx-sdma: Use devm functions
  2014-12-29 17:20 [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Fabio Estevam
@ 2014-12-29 17:20 ` Fabio Estevam
  2014-12-29 17:20 ` [PATCH 3/3] dmaengine: imx-sdma: Return a proper error code in platform_get_irq() Fabio Estevam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2014-12-29 17:20 UTC (permalink / raw)
  To: vinod.koul; +Cc: linux-kernel, shawn.guo, kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

By using devm functions we can make the code shorter and cleaner.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/dma/imx-sdma.c | 62 +++++++++++++-------------------------------------
 1 file changed, 16 insertions(+), 46 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index facb4162..6ac61ba 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1472,7 +1472,7 @@ static int sdma_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	sdma = kzalloc(sizeof(*sdma), GFP_KERNEL);
+	sdma = devm_kzalloc(&pdev->dev, sizeof(*sdma), GFP_KERNEL);
 	if (!sdma)
 		return -ENOMEM;
 
@@ -1481,48 +1481,34 @@ static int sdma_probe(struct platform_device *pdev)
 	sdma->dev = &pdev->dev;
 	sdma->drvdata = drvdata;
 
-	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq = platform_get_irq(pdev, 0);
-	if (!iores || irq < 0) {
-		ret = -EINVAL;
-		goto err_irq;
-	}
+	if (irq < 0)
+		return -EINVAL;
 
-	if (!request_mem_region(iores->start, resource_size(iores), pdev->name)) {
-		ret = -EBUSY;
-		goto err_request_region;
-	}
+	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	sdma->regs = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(sdma->regs))
+		return PTR_ERR(sdma->regs);
 
 	sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
-	if (IS_ERR(sdma->clk_ipg)) {
-		ret = PTR_ERR(sdma->clk_ipg);
-		goto err_clk;
-	}
+	if (IS_ERR(sdma->clk_ipg))
+		return PTR_ERR(sdma->clk_ipg);
 
 	sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
-	if (IS_ERR(sdma->clk_ahb)) {
-		ret = PTR_ERR(sdma->clk_ahb);
-		goto err_clk;
-	}
+	if (IS_ERR(sdma->clk_ahb))
+		return PTR_ERR(sdma->clk_ahb);
 
 	clk_prepare(sdma->clk_ipg);
 	clk_prepare(sdma->clk_ahb);
 
-	sdma->regs = ioremap(iores->start, resource_size(iores));
-	if (!sdma->regs) {
-		ret = -ENOMEM;
-		goto err_ioremap;
-	}
-
-	ret = request_irq(irq, sdma_int_handler, 0, "sdma", sdma);
+	ret = devm_request_irq(&pdev->dev, irq, sdma_int_handler, 0, "sdma",
+			       sdma);
 	if (ret)
-		goto err_request_irq;
+		return ret;
 
 	sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL);
-	if (!sdma->script_addrs) {
-		ret = -ENOMEM;
-		goto err_alloc;
-	}
+	if (!sdma->script_addrs)
+		return -ENOMEM;
 
 	/* initially no scripts available */
 	saddr_arr = (s32 *)sdma->script_addrs;
@@ -1627,38 +1613,22 @@ err_register:
 	dma_async_device_unregister(&sdma->dma_device);
 err_init:
 	kfree(sdma->script_addrs);
-err_alloc:
-	free_irq(irq, sdma);
-err_request_irq:
-	iounmap(sdma->regs);
-err_ioremap:
-err_clk:
-	release_mem_region(iores->start, resource_size(iores));
-err_request_region:
-err_irq:
-	kfree(sdma);
 	return ret;
 }
 
 static int sdma_remove(struct platform_device *pdev)
 {
 	struct sdma_engine *sdma = platform_get_drvdata(pdev);
-	struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	int irq = platform_get_irq(pdev, 0);
 	int i;
 
 	dma_async_device_unregister(&sdma->dma_device);
 	kfree(sdma->script_addrs);
-	free_irq(irq, sdma);
-	iounmap(sdma->regs);
-	release_mem_region(iores->start, resource_size(iores));
 	/* Kill the tasklet */
 	for (i = 0; i < MAX_DMA_CHANNELS; i++) {
 		struct sdma_channel *sdmac = &sdma->channel[i];
 
 		tasklet_kill(&sdmac->tasklet);
 	}
-	kfree(sdma);
 
 	platform_set_drvdata(pdev, NULL);
 	dev_info(&pdev->dev, "Removed...\n");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] dmaengine: imx-sdma: Return a proper error code in platform_get_irq()
  2014-12-29 17:20 [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Fabio Estevam
  2014-12-29 17:20 ` [PATCH 2/3] dmaengine: imx-sdma: Use devm functions Fabio Estevam
@ 2014-12-29 17:20 ` Fabio Estevam
  2015-01-06 15:33 ` [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Maxime Ripard
  2015-01-13 18:21 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Fabio Estevam @ 2014-12-29 17:20 UTC (permalink / raw)
  To: vinod.koul; +Cc: linux-kernel, shawn.guo, kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

There is no need to return a 'fake' value upon platform_get_irq() failure.

Just propagate the real error instead.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/dma/imx-sdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 6ac61ba..18c0a13 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1483,7 +1483,7 @@ static int sdma_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
-		return -EINVAL;
+		return irq;
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	sdma->regs = devm_ioremap_resource(&pdev->dev, iores);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code
  2014-12-29 17:20 [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Fabio Estevam
  2014-12-29 17:20 ` [PATCH 2/3] dmaengine: imx-sdma: Use devm functions Fabio Estevam
  2014-12-29 17:20 ` [PATCH 3/3] dmaengine: imx-sdma: Return a proper error code in platform_get_irq() Fabio Estevam
@ 2015-01-06 15:33 ` Maxime Ripard
  2015-01-13 18:21 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2015-01-06 15:33 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: vinod.koul, linux-kernel, shawn.guo, kernel, Fabio Estevam

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

Hi,

On Mon, Dec 29, 2014 at 03:20:51PM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Since ecc19d17868be9c ("dmaengine: Add a warning for drivers not using the
> generic slave caps retrieval") the following warning is observed:
> 
> [    0.224981] ------------[ cut here ]------------
> [    0.225013] WARNING: CPU: 0 PID: 1 at drivers/dma/dmaengine.c:830 dma_async_device_register+0x2a0/0x4c8()
> [    0.225023] this driver doesn't support generic slave capabilities reporting
> 
> Declare the slave capabilities to avoid such warning.
> 
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code
  2014-12-29 17:20 [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Fabio Estevam
                   ` (2 preceding siblings ...)
  2015-01-06 15:33 ` [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Maxime Ripard
@ 2015-01-13 18:21 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2015-01-13 18:21 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: linux-kernel, shawn.guo, kernel, Fabio Estevam, Maxime Ripard

On Mon, Dec 29, 2014 at 03:20:51PM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Since ecc19d17868be9c ("dmaengine: Add a warning for drivers not using the
> generic slave caps retrieval") the following warning is observed:
> 
> [    0.224981] ------------[ cut here ]------------
> [    0.225013] WARNING: CPU: 0 PID: 1 at drivers/dma/dmaengine.c:830 dma_async_device_register+0x2a0/0x4c8()
> [    0.225023] this driver doesn't support generic slave capabilities reporting
> 
> Declare the slave capabilities to avoid such warning.
Applied all, thanks

-- 
~Vinod


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-13 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-29 17:20 [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Fabio Estevam
2014-12-29 17:20 ` [PATCH 2/3] dmaengine: imx-sdma: Use devm functions Fabio Estevam
2014-12-29 17:20 ` [PATCH 3/3] dmaengine: imx-sdma: Return a proper error code in platform_get_irq() Fabio Estevam
2015-01-06 15:33 ` [PATCH 1/3] dmaengine: imx-sdma: Declare slave capabilities for the generic code Maxime Ripard
2015-01-13 18:21 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).