[PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters

Chen Wang posted 4 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters
Posted by Chen Wang 1 month, 1 week ago
From: Chen Wang <unicorn_wang@outlook.com>

Get the arguments of msi-ranges by specifying nargs directly instead of
using nargs_prop. This only takes one step, unlike the previous two
steps to get the values of all the arguments.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
---
 drivers/irqchip/irq-sg2042-msi.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
index 3b13dbbfdb51..5249afd93b4a 100644
--- a/drivers/irqchip/irq-sg2042-msi.c
+++ b/drivers/irqchip/irq-sg2042-msi.c
@@ -276,17 +276,9 @@ static int sg2042_msi_probe(struct platform_device *pdev)
 	data->doorbell_addr = res->start;
 
 	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges",
-						 "#interrupt-cells", 0, 0, &args);
+						 NULL, 3, 0, &args);
 	if (ret) {
-		dev_err(dev, "Unable to parse MSI vec base\n");
-		return ret;
-	}
-	fwnode_handle_put(args.fwnode);
-
-	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges", NULL,
-						 args.nargs + 1, 0, &args);
-	if (ret) {
-		dev_err(dev, "Unable to parse MSI vec number\n");
+		dev_err(dev, "Unable to parse MSI Ranges\n");
 		return ret;
 	}
 
@@ -298,7 +290,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
 	}
 
 	data->irq_first = (u32)args.args[0];
-	data->num_irqs = (u32)args.args[args.nargs - 1];
+	data->num_irqs = (u32)args.args[2];
 
 	mutex_init(&data->msi_map_lock);
 
-- 
2.34.1
Re: [PATCH 1/4] irqchip/sg2042-msi: Improve the logic of obtaining msi-ranges parameters
Posted by Inochi Amaoto 1 month, 1 week ago
On Mon, Aug 25, 2025 at 02:55:03PM +0800, Chen Wang wrote:
> From: Chen Wang <unicorn_wang@outlook.com>
> 
> Get the arguments of msi-ranges by specifying nargs directly instead of
> using nargs_prop. This only takes one step, unlike the previous two
> steps to get the values of all the arguments.
> 
> Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
> ---
>  drivers/irqchip/irq-sg2042-msi.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
> index 3b13dbbfdb51..5249afd93b4a 100644
> --- a/drivers/irqchip/irq-sg2042-msi.c
> +++ b/drivers/irqchip/irq-sg2042-msi.c
> @@ -276,17 +276,9 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>  	data->doorbell_addr = res->start;
>  

>  	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges",
> -						 "#interrupt-cells", 0, 0, &args);
> +						 NULL, 3, 0, &args);

Why using a fixed range here? I see no improvement. I think using #interrupt-cells
is just OK.

Regards,
Inochi

>  	if (ret) {
> -		dev_err(dev, "Unable to parse MSI vec base\n");
> -		return ret;
> -	}
> -	fwnode_handle_put(args.fwnode);
> -
> -	ret = fwnode_property_get_reference_args(dev_fwnode(dev), "msi-ranges", NULL,
> -						 args.nargs + 1, 0, &args);
> -	if (ret) {
> -		dev_err(dev, "Unable to parse MSI vec number\n");
> +		dev_err(dev, "Unable to parse MSI Ranges\n");
>  		return ret;
>  	}
>  
> @@ -298,7 +290,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>  	}
>  
>  	data->irq_first = (u32)args.args[0];
> -	data->num_irqs = (u32)args.args[args.nargs - 1];
> +	data->num_irqs = (u32)args.args[2];
>  
>  	mutex_init(&data->msi_map_lock);
>  
> -- 
> 2.34.1
>