public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] dmaengine; A little cleanup and refactoring
@ 2025-11-09 22:28 Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 1/4] dmaengine: Use dma_request_channel() instead of __dma_request_channel() Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-11-09 22:28 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul

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

Andy Shevchenko (4):
  dmaengine: Use dma_request_channel() instead of
    __dma_request_channel()
  dmaengine: Refactor devm_dma_request_chan() for readability
  dmaengine: Use device_match_of_node() helper
  dmaengine: Sort headers alphabetically

 drivers/dma/dmaengine.c | 52 +++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

-- 
2.50.1


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

* [PATCH v1 1/4] dmaengine: Use dma_request_channel() instead of __dma_request_channel()
  2025-11-09 22:28 [PATCH v1 0/4] dmaengine; A little cleanup and refactoring Andy Shevchenko
@ 2025-11-09 22:28 ` Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 2/4] dmaengine: Refactor devm_dma_request_chan() for readability Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-11-09 22:28 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul

Reduce use of internal __dma_request_channel() function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dmaengine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index ca13cd39330b..cd1c0744bfc0 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -886,7 +886,7 @@ struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
 	if (!mask)
 		return ERR_PTR(-ENODEV);
 
-	chan = __dma_request_channel(mask, NULL, NULL, NULL);
+	chan = dma_request_channel(mask, NULL, NULL);
 	if (!chan) {
 		mutex_lock(&dma_list_mutex);
 		if (list_empty(&dma_device_list))
-- 
2.50.1


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

* [PATCH v1 2/4] dmaengine: Refactor devm_dma_request_chan() for readability
  2025-11-09 22:28 [PATCH v1 0/4] dmaengine; A little cleanup and refactoring Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 1/4] dmaengine: Use dma_request_channel() instead of __dma_request_channel() Andy Shevchenko
@ 2025-11-09 22:28 ` Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 3/4] dmaengine: Use device_match_of_node() helper Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 4/4] dmaengine: Sort headers alphabetically Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-11-09 22:28 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul

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().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dmaengine.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index cd1c0744bfc0..620c5bcff3bf 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -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);
 
-- 
2.50.1


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

* [PATCH v1 3/4] dmaengine: Use device_match_of_node() helper
  2025-11-09 22:28 [PATCH v1 0/4] dmaengine; A little cleanup and refactoring Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 1/4] dmaengine: Use dma_request_channel() instead of __dma_request_channel() Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 2/4] dmaengine: Refactor devm_dma_request_chan() for readability Andy Shevchenko
@ 2025-11-09 22:28 ` Andy Shevchenko
  2025-11-09 22:28 ` [PATCH v1 4/4] dmaengine: Sort headers alphabetically Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-11-09 22:28 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul

Instead of open coding, use device_match_of_node() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dmaengine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 620c5bcff3bf..9e2ce7054e8a 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -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);
-- 
2.50.1


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

* [PATCH v1 4/4] dmaengine: Sort headers alphabetically
  2025-11-09 22:28 [PATCH v1 0/4] dmaengine; A little cleanup and refactoring Andy Shevchenko
                   ` (2 preceding siblings ...)
  2025-11-09 22:28 ` [PATCH v1 3/4] dmaengine: Use device_match_of_node() helper Andy Shevchenko
@ 2025-11-09 22:28 ` Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-11-09 22:28 UTC (permalink / raw)
  To: Andy Shevchenko, dmaengine, linux-kernel; +Cc: Vinod Koul

For better maintenance sort headers alphabetically.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dmaengine.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 9e2ce7054e8a..6d940c4c0c4e 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -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"
 
-- 
2.50.1


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

end of thread, other threads:[~2025-11-09 22:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-09 22:28 [PATCH v1 0/4] dmaengine; A little cleanup and refactoring Andy Shevchenko
2025-11-09 22:28 ` [PATCH v1 1/4] dmaengine: Use dma_request_channel() instead of __dma_request_channel() Andy Shevchenko
2025-11-09 22:28 ` [PATCH v1 2/4] dmaengine: Refactor devm_dma_request_chan() for readability Andy Shevchenko
2025-11-09 22:28 ` [PATCH v1 3/4] dmaengine: Use device_match_of_node() helper Andy Shevchenko
2025-11-09 22:28 ` [PATCH v1 4/4] dmaengine: Sort headers alphabetically Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox