Skip to contentSkip to conversation

dmaengine: A little cleanup and refactoring

PATCH Applied Andy Shevchenko 4 participants 8 messages Jan 9 – Feb 25 dmaengine

lore
Share & tools
lore
#0 lore raw

v3 cover dmaengine: A little cleanup and refactoring

This just a set of small almost ad-hoc cleanups and refactoring. Nothing special and nothing that changes behaviour.

Changelog v3:
- fixed checkpatch warning (mixed tabs and spaces) (Vinod)

v2: [email protected]

Changelog v2:
- dropped not very good (and not compilable) change (LKP)

Andy Shevchenko (3):
dmaengine: Refactor devm_dma_request_chan() for readability
dmaengine: Use device_match_of_node() helper
dmaengine: Sort headers alphabetically

 drivers/dma/dmaengine.c | 50 +++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 24 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH v3 1/3 dmaengine: Refactor devm_dma_request_chan() for readability

Yes, while it's a bit longer in terms of LoCs, it's more readable when we use the usual patter to check for errors, and not for a success). This eliminates unneeded assignment and moves the needed one closer to its user which is better programming pattern because it allows avoiding potential errors in case the variable is getting reused. Also note that the same pattern have been used already in dmaenginem_async_device_register().

---
 drivers/dma/dmaengine.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/dma/dmaengine.c +6 -4
index ca13cd39330b..8fe552c74eb8 100644
@@ -943,12 +943,14 @@ static void dmaenginem_release_channel(void *chan)
 
 struct dma_chan *devm_dma_request_chan(struct device *dev, const char *name)
 {
-	struct dma_chan *chan = dma_request_chan(dev, name);
-	int ret = 0;
+	struct dma_chan *chan;
+	int ret;
 
-	if (!IS_ERR(chan))
-		ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan);
+	chan = dma_request_chan(dev, name);
+	if (IS_ERR(chan))
+		return chan;
 
+	ret = devm_add_action_or_reset(dev, dmaenginem_release_channel, chan);
 	if (ret)
 		return ERR_PTR(ret);
 
Signature · 1 line
2.50.1
#2 lore raw

PATCH v3 2/3 dmaengine: Use device_match_of_node() helper

In reply to Andy Shevchenko

Instead of open coding, use device_match_of_node() helper.

---
 drivers/dma/dmaengine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dmaengine.c +1 -1
index 8fe552c74eb8..ca1723a34779 100644
@@ -765,7 +765,7 @@ struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
 	mutex_lock(&dma_list_mutex);
 	list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
 		/* Finds a DMA controller with matching device node */
-		if (np && device->dev->of_node && np != device->dev->of_node)
+		if (np && !device_match_of_node(device->dev, np))
 			continue;
 
 		chan = find_candidate(device, mask, fn, fn_param);
Signature · 1 line
2.50.1
#3 lore raw

PATCH v3 3/3 dmaengine: Sort headers alphabetically

In reply to Andy Shevchenko

For better maintenance sort headers alphabetically.

---
 drivers/dma/dmaengine.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/dma/dmaengine.c +19 -19
index ca1723a34779..45af455ab2be 100644
@@ -31,29 +31,29 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/platform_device.h>
-#include <linux/dma-mapping.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/mm.h>
-#include <linux/device.h>
-#include <linux/dmaengine.h>
-#include <linux/hardirq.h>
-#include <linux/spinlock.h>
-#include <linux/of.h>
-#include <linux/property.h>
-#include <linux/percpu.h>
-#include <linux/rcupdate.h>
-#include <linux/mutex.h>
-#include <linux/jiffies.h>
-#include <linux/rculist.h>
-#include <linux/idr.h>
-#include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/acpi_dma.h>
-#include <linux/of_dma.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/dmaengine.h>
+#include <linux/hardirq.h>
+#include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
 #include <linux/mempool.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/numa.h>
+#include <linux/of.h>
+#include <linux/of_dma.h>
+#include <linux/percpu.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/rculist.h>
+#include <linux/rcupdate.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
 
 #include "dmaengine.h"
 
Signature · 1 line
2.50.1
Reviewed-by on the v3 series
#4 lore raw
In reply to Andy Shevchenko
Quoted 11 lines · Andy Shevchenko

This just a set of small almost ad-hoc cleanups and refactoring. Nothing special and nothing that changes behaviour.

Changelog v3:
- fixed checkpatch warning (mixed tabs and spaces) (Vinod)

v2: [email protected]

Changelog v2:
- dropped not very good (and not compilable) change (LKP)

Quoted 8 lines

Andy Shevchenko (3):
dmaengine: Refactor devm_dma_request_chan() for readability
dmaengine: Use device_match_of_node() helper
dmaengine: Sort headers alphabetically

 drivers/dma/dmaengine.c | 50 +++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 24 deletions(-)

for the series

Reviewed-by on the v3 series
#5 lore raw
In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

This just a set of small almost ad-hoc cleanups and refactoring. Nothing special and nothing that changes behaviour.

Changelog v3:
- fixed checkpatch warning (mixed tabs and spaces) (Vinod)

v2: [email protected]

Quoted 7 lines

Changelog v2:
- dropped not very good (and not compilable) change (LKP)

Andy Shevchenko (3):
dmaengine: Refactor devm_dma_request_chan() for readability
dmaengine: Use device_match_of_node() helper
dmaengine: Sort headers alphabetically

Quoted 7 lines
 drivers/dma/dmaengine.c | 50 +++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 24 deletions(-)

--
2.50.1

#6 lore raw
Quoted 10 lines · Frank Li
Quoted 7 lines · Andy Shevchenko

This just a set of small almost ad-hoc cleanups and refactoring. Nothing special and nothing that changes behaviour.

Changelog v3:
- fixed checkpatch warning (mixed tabs and spaces) (Vinod)

v2: [email protected]

Thank you! Vinod, since we seems will have an -rc8 this cycle, can this series be applied now?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#7 lore raw
In reply to Andy Shevchenko
Quoted 9 lines · Andy Shevchenko

This just a set of small almost ad-hoc cleanups and refactoring. Nothing special and nothing that changes behaviour.

Changelog v3:
- fixed checkpatch warning (mixed tabs and spaces) (Vinod)

v2: [email protected]

[...]

Applied, thanks!

[1/3] dmaengine: Refactor devm_dma_request_chan() for readability

      commit: 4dd56ef8a26190f1735de9dddb854f175adbc6cd
[2/3] dmaengine: Use device_match_of_node() helper
      commit: db4709e19ba3d50ceeba9e01db373f672698ff1f
[3/3] dmaengine: Sort headers alphabetically
      commit: 9a07b4bb2c6019a8c585f48ee9b87fc843840e6e

Best regards,

Signature · 1 line
~Vinod