[PATCH v1 4/4] dmaengine: Unify checks in dma_request_chan()

Andy Shevchenko posted 4 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH v1 4/4] dmaengine: Unify checks in dma_request_chan()
Posted by Andy Shevchenko 1 month, 3 weeks ago
Use firmware node and unify checks accordingly in dma_request_chan().
As a side effect we get rid of the node dereferencing in struct device.

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

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index dd4224d90f07..758fcd0546d8 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -40,6 +40,8 @@
 #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>
@@ -812,15 +814,13 @@ static const struct dma_slave_map *dma_filter_match(struct dma_device *device,
  */
 struct dma_chan *dma_request_chan(struct device *dev, const char *name)
 {
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	struct dma_device *d, *_d;
 	struct dma_chan *chan = NULL;
 
-	/* If device-tree is present get slave info from here */
-	if (dev->of_node)
-		chan = of_dma_request_slave_channel(dev->of_node, name);
-
-	/* If device was enumerated by ACPI get slave info from here */
-	if (has_acpi_companion(dev) && !chan)
+	if (is_of_node(fwnode))
+		chan = of_dma_request_slave_channel(to_of_node(fwnode), name);
+	else if (is_acpi_device_node(fwnode))
 		chan = acpi_dma_request_slave_chan_by_name(dev, name);
 
 	if (PTR_ERR(chan) == -EPROBE_DEFER)
-- 
2.43.0.rc1.1336.g36b5255a03ac
Re: [PATCH v1 4/4] dmaengine: Unify checks in dma_request_chan()
Posted by Frank Li 1 month, 3 weeks ago
On Mon, Oct 07, 2024 at 06:06:48PM +0300, Andy Shevchenko wrote:
> Use firmware node and unify checks accordingly in dma_request_chan().
> As a side effect we get rid of the node dereferencing in struct device.

suggest:

Use dev_fwnode() to simple check logic for device tree and ACPI in
dma_request_chan().

Frank

>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/dma/dmaengine.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index dd4224d90f07..758fcd0546d8 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -40,6 +40,8 @@
>  #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>
> @@ -812,15 +814,13 @@ static const struct dma_slave_map *dma_filter_match(struct dma_device *device,
>   */
>  struct dma_chan *dma_request_chan(struct device *dev, const char *name)
>  {
> +	struct fwnode_handle *fwnode = dev_fwnode(dev);
>  	struct dma_device *d, *_d;
>  	struct dma_chan *chan = NULL;
>
> -	/* If device-tree is present get slave info from here */
> -	if (dev->of_node)
> -		chan = of_dma_request_slave_channel(dev->of_node, name);
> -
> -	/* If device was enumerated by ACPI get slave info from here */
> -	if (has_acpi_companion(dev) && !chan)
> +	if (is_of_node(fwnode))
> +		chan = of_dma_request_slave_channel(to_of_node(fwnode), name);
> +	else if (is_acpi_device_node(fwnode))
>  		chan = acpi_dma_request_slave_chan_by_name(dev, name);
>
>  	if (PTR_ERR(chan) == -EPROBE_DEFER)
> --
> 2.43.0.rc1.1336.g36b5255a03ac
>
Re: [PATCH v1 4/4] dmaengine: Unify checks in dma_request_chan()
Posted by Andy Shevchenko 1 month, 2 weeks ago
On Mon, Oct 07, 2024 at 12:05:56PM -0400, Frank Li wrote:
> On Mon, Oct 07, 2024 at 06:06:48PM +0300, Andy Shevchenko wrote:
> > Use firmware node and unify checks accordingly in dma_request_chan().
> > As a side effect we get rid of the node dereferencing in struct device.
> 
> suggest:
> 
> Use dev_fwnode() to simple check logic for device tree and ACPI in
> dma_request_chan().

Sure, thanks!


-- 
With Best Regards,
Andy Shevchenko