diff mbox series

[3/5] power: reset: brcmstb: Use syscon_regmap_lookup_by_phandle_args() helper

Message ID 20240610142836.168603-3-afd@ti.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series [1/5] power: reset: brcmstb: Use normal driver register function | expand

Commit Message

Andrew Davis June 10, 2024, 2:28 p.m. UTC
Simplify probe by fetching the regmap and its arguments in one call.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/power/reset/brcmstb-reboot.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

Comments

Dhruva Gole June 11, 2024, 6:15 a.m. UTC | #1
Hi,

On Jun 10, 2024 at 09:28:34 -0500, Andrew Davis wrote:
> Simplify probe by fetching the regmap and its arguments in one call.
> 
> Signed-off-by: Andrew Davis <afd@ti.com>
> ---
>  drivers/power/reset/brcmstb-reboot.c | 22 ++++------------------
>  1 file changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c
> index db5b7120eadd0..94ea317f61ef4 100644
> --- a/drivers/power/reset/brcmstb-reboot.c
> +++ b/drivers/power/reset/brcmstb-reboot.c
> @@ -18,9 +18,6 @@
>  #include <linux/smp.h>
>  #include <linux/mfd/syscon.h>
>  
> -#define RESET_SOURCE_ENABLE_REG 1
> -#define SW_MASTER_RESET_REG 2
> -
>  static struct regmap *regmap;
>  static u32 rst_src_en;
>  static u32 sw_mstr_rst;
> @@ -87,6 +84,7 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
>  {
>  	int rc;
>  	struct device_node *np = pdev->dev.of_node;
> +	unsigned int args[2];

You can also call it syscon_args, but I'm fine either way.

>  
>  	reset_masks = device_get_match_data(&pdev->dev);
>  	if (!reset_masks) {
> @@ -94,25 +92,13 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> +	regmap = syscon_regmap_lookup_by_phandle_args(np, "syscon", 2, args);
>  	if (IS_ERR(regmap)) {
>  		pr_err("failed to get syscon phandle\n");
>  		return -EINVAL;
>  	}
> -
> -	rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG,
> -					&rst_src_en);
> -	if (rc) {
> -		pr_err("can't get rst_src_en offset (%d)\n", rc);
> -		return -EINVAL;
> -	}
> -
> -	rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG,
> -					&sw_mstr_rst);
> -	if (rc) {
> -		pr_err("can't get sw_mstr_rst offset (%d)\n", rc);
> -		return -EINVAL;
> -	}
> +	rst_src_en = args[0];
> +	sw_mstr_rst = args[1];

Reviewed-by: Dhruva Gole <d-gole@ti.com>
Florian Fainelli June 16, 2024, 12:30 p.m. UTC | #2
On 6/10/2024 3:28 PM, Andrew Davis wrote:
> Simplify probe by fetching the regmap and its arguments in one call.
> 
> Signed-off-by: Andrew Davis <afd@ti.com>
> ---
>   drivers/power/reset/brcmstb-reboot.c | 22 ++++------------------
>   1 file changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c
> index db5b7120eadd0..94ea317f61ef4 100644
> --- a/drivers/power/reset/brcmstb-reboot.c
> +++ b/drivers/power/reset/brcmstb-reboot.c
> @@ -18,9 +18,6 @@
>   #include <linux/smp.h>
>   #include <linux/mfd/syscon.h>
>   
> -#define RESET_SOURCE_ENABLE_REG 1
> -#define SW_MASTER_RESET_REG 2
> -
>   static struct regmap *regmap;
>   static u32 rst_src_en;
>   static u32 sw_mstr_rst;
> @@ -87,6 +84,7 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
>   {
>   	int rc;
>   	struct device_node *np = pdev->dev.of_node;
> +	unsigned int args[2];
>   
>   	reset_masks = device_get_match_data(&pdev->dev);
>   	if (!reset_masks) {
> @@ -94,25 +92,13 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
>   		return -EINVAL;
>   	}
>   
> -	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> +	regmap = syscon_regmap_lookup_by_phandle_args(np, "syscon", 2, args);

Not that this is likely to change, but I would use ARRAY_SIZE(args) 
here. With that:

Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c
index db5b7120eadd0..94ea317f61ef4 100644
--- a/drivers/power/reset/brcmstb-reboot.c
+++ b/drivers/power/reset/brcmstb-reboot.c
@@ -18,9 +18,6 @@ 
 #include <linux/smp.h>
 #include <linux/mfd/syscon.h>
 
-#define RESET_SOURCE_ENABLE_REG 1
-#define SW_MASTER_RESET_REG 2
-
 static struct regmap *regmap;
 static u32 rst_src_en;
 static u32 sw_mstr_rst;
@@ -87,6 +84,7 @@  static int brcmstb_reboot_probe(struct platform_device *pdev)
 {
 	int rc;
 	struct device_node *np = pdev->dev.of_node;
+	unsigned int args[2];
 
 	reset_masks = device_get_match_data(&pdev->dev);
 	if (!reset_masks) {
@@ -94,25 +92,13 @@  static int brcmstb_reboot_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+	regmap = syscon_regmap_lookup_by_phandle_args(np, "syscon", 2, args);
 	if (IS_ERR(regmap)) {
 		pr_err("failed to get syscon phandle\n");
 		return -EINVAL;
 	}
-
-	rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG,
-					&rst_src_en);
-	if (rc) {
-		pr_err("can't get rst_src_en offset (%d)\n", rc);
-		return -EINVAL;
-	}
-
-	rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG,
-					&sw_mstr_rst);
-	if (rc) {
-		pr_err("can't get sw_mstr_rst offset (%d)\n", rc);
-		return -EINVAL;
-	}
+	rst_src_en = args[0];
+	sw_mstr_rst = args[1];
 
 	rc = register_restart_handler(&brcmstb_restart_nb);
 	if (rc)