diff mbox series

[u-boot-marvell,02/11] treewide: Use fdt_create_phandle() where appropriate

Message ID 20211103020244.25428-3-kabel@kernel.org
State Superseded
Delegated to: Stefan Roese
Headers show
Series Some mvebu comphy + mox + fdt_support changes | expand

Commit Message

Marek Behún Nov. 3, 2021, 2:02 a.m. UTC
From: Marek Behún <marek.behun@nic.cz>

Replace fdt_alloc_phandle() with subsequent fdt_set_phandle() by
fdt_create_phandle().

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 board/Marvell/octeon_ebb7304/board.c |  5 ++---
 drivers/misc/fsl_portals.c           | 10 ++++------
 2 files changed, 6 insertions(+), 9 deletions(-)

Comments

Stefan Roese Nov. 12, 2021, 12:40 p.m. UTC | #1
On 11/3/21 03:02, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
> 
> Replace fdt_alloc_phandle() with subsequent fdt_set_phandle() by
> fdt_create_phandle().
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/Marvell/octeon_ebb7304/board.c |  5 ++---
>   drivers/misc/fsl_portals.c           | 10 ++++------
>   2 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/board/Marvell/octeon_ebb7304/board.c b/board/Marvell/octeon_ebb7304/board.c
> index e8e2d547c1..c6c7c13483 100644
> --- a/board/Marvell/octeon_ebb7304/board.c
> +++ b/board/Marvell/octeon_ebb7304/board.c
> @@ -205,7 +205,7 @@ static int fdt_fix_mix(const void *fdt)
>   		int env_lmac = -1;
>   		int lmac_fdt_node = -1;
>   		int mix_fdt_node = -1;
> -		int lmac_phandle;
> +		unsigned int lmac_phandle;
>   		char *compat;
>   
>   		/* Get the lmac for this environment variable */
> @@ -229,8 +229,7 @@ static int fdt_fix_mix(const void *fdt)
>   			}
>   		}
>   
> -		lmac_phandle = fdt_alloc_phandle((void *)fdt);
> -		fdt_set_phandle((void *)fdt, lmac_fdt_node, lmac_phandle);
> +		lmac_phandle = fdt_create_phandle((void *)fdt, lmac_fdt_node);
>   
>   		/* Get the fdt mix node corresponding to this lmac */
>   		mix_fdt_node = get_mix_fdt_node(fdt, env_node, env_lmac);
> diff --git a/drivers/misc/fsl_portals.c b/drivers/misc/fsl_portals.c
> index 632430e420..02bc3f86ca 100644
> --- a/drivers/misc/fsl_portals.c
> +++ b/drivers/misc/fsl_portals.c
> @@ -106,7 +106,7 @@ static int fdt_qportal(void *blob, int off, int id, char *name,
>   		       enum fsl_dpaa_dev dev, int create)
>   {
>   	int childoff, dev_off, ret = 0;
> -	u32 dev_handle;
> +	unsigned int dev_handle;
>   #ifdef CONFIG_FSL_CORENET
>   	int num;
>   	u32 liodns[2];
> @@ -142,11 +142,9 @@ static int fdt_qportal(void *blob, int off, int id, char *name,
>   		if (childoff > 0) {
>   			dev_handle = fdt_get_phandle(blob, dev_off);
>   			if (dev_handle <= 0) {
> -				dev_handle = fdt_alloc_phandle(blob);
> -				ret = fdt_set_phandle(blob, dev_off,
> -						      dev_handle);
> -				if (ret < 0)
> -					return ret;
> +				dev_handle = fdt_create_phandle(blob, dev_off);
> +				if (!dev_handle)
> +					return -FDT_ERR_NOPHANDLES;
>   			}
>   
>   			ret = fdt_setprop(blob, childoff, "dev-handle",
> 

Viele Grüße,
Stefan Roese
diff mbox series

Patch

diff --git a/board/Marvell/octeon_ebb7304/board.c b/board/Marvell/octeon_ebb7304/board.c
index e8e2d547c1..c6c7c13483 100644
--- a/board/Marvell/octeon_ebb7304/board.c
+++ b/board/Marvell/octeon_ebb7304/board.c
@@ -205,7 +205,7 @@  static int fdt_fix_mix(const void *fdt)
 		int env_lmac = -1;
 		int lmac_fdt_node = -1;
 		int mix_fdt_node = -1;
-		int lmac_phandle;
+		unsigned int lmac_phandle;
 		char *compat;
 
 		/* Get the lmac for this environment variable */
@@ -229,8 +229,7 @@  static int fdt_fix_mix(const void *fdt)
 			}
 		}
 
-		lmac_phandle = fdt_alloc_phandle((void *)fdt);
-		fdt_set_phandle((void *)fdt, lmac_fdt_node, lmac_phandle);
+		lmac_phandle = fdt_create_phandle((void *)fdt, lmac_fdt_node);
 
 		/* Get the fdt mix node corresponding to this lmac */
 		mix_fdt_node = get_mix_fdt_node(fdt, env_node, env_lmac);
diff --git a/drivers/misc/fsl_portals.c b/drivers/misc/fsl_portals.c
index 632430e420..02bc3f86ca 100644
--- a/drivers/misc/fsl_portals.c
+++ b/drivers/misc/fsl_portals.c
@@ -106,7 +106,7 @@  static int fdt_qportal(void *blob, int off, int id, char *name,
 		       enum fsl_dpaa_dev dev, int create)
 {
 	int childoff, dev_off, ret = 0;
-	u32 dev_handle;
+	unsigned int dev_handle;
 #ifdef CONFIG_FSL_CORENET
 	int num;
 	u32 liodns[2];
@@ -142,11 +142,9 @@  static int fdt_qportal(void *blob, int off, int id, char *name,
 		if (childoff > 0) {
 			dev_handle = fdt_get_phandle(blob, dev_off);
 			if (dev_handle <= 0) {
-				dev_handle = fdt_alloc_phandle(blob);
-				ret = fdt_set_phandle(blob, dev_off,
-						      dev_handle);
-				if (ret < 0)
-					return ret;
+				dev_handle = fdt_create_phandle(blob, dev_off);
+				if (!dev_handle)
+					return -FDT_ERR_NOPHANDLES;
 			}
 
 			ret = fdt_setprop(blob, childoff, "dev-handle",