[PATCH v2 2/3] dmaengine: Use device_match_of_node() helper

Andy Shevchenko posted 3 patches 3 months ago
There is a newer version of this series
[PATCH v2 2/3] dmaengine: Use device_match_of_node() helper
Posted by Andy Shevchenko 3 months ago
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 eb27a72cd4c5..e89280587d5d 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
Re: [PATCH v2 2/3] dmaengine: Use device_match_of_node() helper
Posted by Praveen Kumar 2 months, 4 weeks ago
On Mon, Nov 10, 2025 at 09:47:44AM +0100, Andy Shevchenko wrote:
> 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 eb27a72cd4c5..e89280587d5d 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))

I see a difference in what device_match_of_node does vs what was
happening in the previous check. And, we have an unwanted double
check of np.

int device_match_of_node(struct device *dev, const void *np)
{
        return np && dev->of_node == np;
}

Instead, I would recommend,

        if (device->dev->of_node && !device_match_of_node(device->dev, np))
                continue;

Regards,
Praveen Kumar.

>  			continue;
>  
>  		chan = find_candidate(device, mask, fn, fn_param);
> -- 
> 2.50.1
>
Re: [PATCH v2 2/3] dmaengine: Use device_match_of_node() helper
Posted by Andy Shevchenko 2 months, 4 weeks ago
On Mon, Nov 10, 2025 at 11:20:33AM +0100, Praveen Kumar wrote:
> On Mon, Nov 10, 2025 at 09:47:44AM +0100, Andy Shevchenko wrote:
> > Instead of open coding, use device_match_of_node() helper.

...

> > -		if (np && device->dev->of_node && np != device->dev->of_node)
> > +		if (np && !device_match_of_node(device->dev, np))
> 
> I see a difference in what device_match_of_node does vs what was
> happening in the previous check. And, we have an unwanted double
> check of np.

Nope.

> int device_match_of_node(struct device *dev, const void *np)
> {
>         return np && dev->of_node == np;
> }
> 
> Instead, I would recommend,
> 
>         if (device->dev->of_node && !device_match_of_node(device->dev, np))
>                 continue;

This will be the wrong check. Think about it, yeah, it's not so trivial check
and hence the change.

-- 
With Best Regards,
Andy Shevchenko