linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] tree-wide: simplify getting .drvdata
@ 2018-04-22  9:14 Wolfram Sang
  2018-04-22  9:14 ` [PATCH 3/6] dmaengine: fsldma: " Wolfram Sang
  2018-04-22 16:11 ` [PATCH 0/6] tree-wide: " Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Wolfram Sang @ 2018-04-22  9:14 UTC (permalink / raw)
  To: dmaengine; +Cc: Wolfram Sang, linux-arm-kernel, linux-kernel, linuxppc-dev

I got tired of fixing this in Renesas drivers manually, so I took the big
hammer. Remove this cumbersome code pattern which got copy-pasted too much
already:

-	struct platform_device *pdev = to_platform_device(dev);
-	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
+	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);

I send this out as one patch per directory per subsystem. I think they should
be applied individually. If you prefer a broken out series per subsystem, I can
provide this as well. Just mail me.

A branch (tested by buildbot; only with all commits squashed into one commit
before) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git coccinelle/get_drvdata

Open for other comments, suggestions, too, of course.

Here is the cocci-script I created:

@@
struct device* d;
identifier pdev;
expression *ptr;
@@
(
-	struct platform_device *pdev = to_platform_device(d);
|
-	struct platform_device *pdev;
	...
-	pdev = to_platform_device(d);
)
	<... when != pdev
-	&pdev->dev
+	d
	...>

	ptr =
-	platform_get_drvdata(pdev)
+	dev_get_drvdata(d)

	<... when != pdev
-	&pdev->dev
+	d
	...>

Kind regards,

   Wolfram


Wolfram Sang (6):
  dmaengine: at_hdmac: simplify getting .drvdata
  dmaengine: at_xdmac: simplify getting .drvdata
  dmaengine: fsldma: simplify getting .drvdata
  dmaengine: idma64: simplify getting .drvdata
  dmaengine: ste_dma40: simplify getting .drvdata
  dmaengine: txx9dmac: simplify getting .drvdata

 drivers/dma/at_hdmac.c  |  9 +++------
 drivers/dma/at_xdmac.c  |  9 +++------
 drivers/dma/fsldma.c    |  6 ++----
 drivers/dma/idma64.c    |  6 ++----
 drivers/dma/ste_dma40.c | 12 ++++--------
 drivers/dma/txx9dmac.c  |  8 +++-----
 6 files changed, 17 insertions(+), 33 deletions(-)

-- 
2.11.0

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

* [PATCH 3/6] dmaengine: fsldma: simplify getting .drvdata
  2018-04-22  9:14 [PATCH 0/6] tree-wide: simplify getting .drvdata Wolfram Sang
@ 2018-04-22  9:14 ` Wolfram Sang
  2018-04-22 16:11 ` [PATCH 0/6] tree-wide: " Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2018-04-22  9:14 UTC (permalink / raw)
  To: dmaengine
  Cc: Wolfram Sang, Li Yang, Zhang Wei, Vinod Koul, Dan Williams,
	linuxppc-dev, linux-kernel

We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Build tested only. buildbot is happy. Please apply to your tree directly.

 drivers/dma/fsldma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 3eaece888e75..1117b5123a6f 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -1328,8 +1328,7 @@ static int fsldma_of_remove(struct platform_device *op)
 #ifdef CONFIG_PM
 static int fsldma_suspend_late(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct fsldma_device *fdev = platform_get_drvdata(pdev);
+	struct fsldma_device *fdev = dev_get_drvdata(dev);
 	struct fsldma_chan *chan;
 	int i;
 
@@ -1360,8 +1359,7 @@ static int fsldma_suspend_late(struct device *dev)
 
 static int fsldma_resume_early(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev);
-	struct fsldma_device *fdev = platform_get_drvdata(pdev);
+	struct fsldma_device *fdev = dev_get_drvdata(dev);
 	struct fsldma_chan *chan;
 	u32 mode;
 	int i;
-- 
2.11.0

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

* Re: [PATCH 0/6] tree-wide: simplify getting .drvdata
  2018-04-22  9:14 [PATCH 0/6] tree-wide: simplify getting .drvdata Wolfram Sang
  2018-04-22  9:14 ` [PATCH 3/6] dmaengine: fsldma: " Wolfram Sang
@ 2018-04-22 16:11 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2018-04-22 16:11 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: dmaengine, linux-arm-kernel, linux-kernel, linuxppc-dev

On Sun, Apr 22, 2018 at 11:14:08AM +0200, Wolfram Sang wrote:
> I got tired of fixing this in Renesas drivers manually, so I took the big
> hammer. Remove this cumbersome code pattern which got copy-pasted too much
> already:
> 
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct ep93xx_keypad *keypad = platform_get_drvdata(pdev);
> +	struct ep93xx_keypad *keypad = dev_get_drvdata(dev);
> 
> I send this out as one patch per directory per subsystem. I think they should
> be applied individually. If you prefer a broken out series per subsystem, I can
> provide this as well. Just mail me.

Applied all, thanks

-- 
~Vinod

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

end of thread, other threads:[~2018-04-22 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-22  9:14 [PATCH 0/6] tree-wide: simplify getting .drvdata Wolfram Sang
2018-04-22  9:14 ` [PATCH 3/6] dmaengine: fsldma: " Wolfram Sang
2018-04-22 16:11 ` [PATCH 0/6] tree-wide: " 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).