[U-Boot] [PATCH 01/11] fdt: Allow ft_board_setup() to report failure

Anatolij Gustschin agust at denx.de
Fri Oct 17 22:19:56 CEST 2014


Hi Simon,

some comments on return values and error reporting below:

On Wed, 15 Oct 2014 02:05:31 -0600
Simon Glass <sjg at chromium.org> wrote:
...
> diff --git a/board/amcc/sequoia/sequoia.c b/board/amcc/sequoia/sequoia.c
> index 53f9b34..afac3f9 100644
> --- a/board/amcc/sequoia/sequoia.c
> +++ b/board/amcc/sequoia/sequoia.c
> @@ -10,6 +10,7 @@
>   */
>  
>  #include <common.h>
> +#include <errno.h>
>  #include <libfdt.h>
>  #include <fdt_support.h>
>  #include <asm/ppc4xx.h>
> @@ -363,7 +364,7 @@ void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
>   * On NAND-booting sequoia, we need to patch the chips select numbers
>   * in the dtb (CS0 - NAND, CS3 - NOR)
>   */
> -void ft_board_setup(void *blob, bd_t *bd)
> +int ft_board_setup(void *blob, bd_t *bd)
>  {
>  	int rc;
>  	int len;
> @@ -381,7 +382,7 @@ void ft_board_setup(void *blob, bd_t *bd)
>  	prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
>  	if (prop == NULL) {
>  		printf("Unable to update NOR chip select for NAND booting\n");
> -		return;
> +		return -ENOSPC;

return -FDT_ERR_NOSPACE;

otherwise failure reporting of ft_board_setup() as added in the next
patch will output "<unknown error>".

...
> @@ -389,7 +390,7 @@ void ft_board_setup(void *blob, bd_t *bd)
>  	if (rc) {
>  		printf("Unable to update property NOR mappings, err=%s\n",
>  		       fdt_strerror(rc));
> -		return;
> +		return -ENOSPC;

since the failure reporting will be added, it should be removed here:

printf("Unable to update property NOR mappings\n");
return rc;

...
> @@ -398,7 +399,7 @@ void ft_board_setup(void *blob, bd_t *bd)
>  	prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
>  	if (prop == NULL) {
>  		printf("Unable to update NDFC chip select for NAND booting\n");
> -		return;
> +		return -ENOSPC;

return -FDT_ERR_NOSPACE;

...
> @@ -406,7 +407,9 @@ void ft_board_setup(void *blob, bd_t *bd)
>  	if (rc) {
>  		printf("Unable to update property NDFC mappings, err=%s\n",
>  		       fdt_strerror(rc));
> -		return;
> +		return -ENOSPC;

printf("Unable to update property NDFC mappings\n");
return rc;

...
> diff --git a/board/freescale/p1_p2_rdb/p1_p2_rdb.c b/board/freescale/p1_p2_rdb/p1_p2_rdb.c
> index aba4f53..e1883ea 100644
> --- a/board/freescale/p1_p2_rdb/p1_p2_rdb.c
> +++ b/board/freescale/p1_p2_rdb/p1_p2_rdb.c
> @@ -6,6 +6,7 @@
>  
>  #include <common.h>
>  #include <command.h>
> +#include <errno.h>
>  #include <asm/processor.h>
>  #include <asm/mmu.h>
>  #include <asm/cache.h>
> @@ -234,7 +235,7 @@ int board_eth_init(bd_t *bis)
>  #if defined(CONFIG_OF_BOARD_SETUP)
>  extern void ft_pci_board_setup(void *blob);
>  
> -void ft_board_setup(void *blob, bd_t *bd)
> +int ft_board_setup(void *blob, bd_t *bd)
>  {
>  	const char *soc_usb_compat = "fsl-usb2-dr";
>  	int err, usb1_off, usb2_off;
> @@ -266,14 +267,14 @@ void ft_board_setup(void *blob, bd_t *bd)
>  			printf("WARNING: could not find compatible node"
>  				" %s: %s.\n", soc_elbc_compat,
>  				fdt_strerror(off));
> -				return;
> +				return -ENOENT;

printf("WARNING: could not find compatible node %s\n", soc_elbc_compat);
return off;

>  		}
>  		err = fdt_del_node(blob, off);
>  		if (err < 0) {
>  			printf("WARNING: could not remove %s: %s.\n",
>  				soc_elbc_compat, fdt_strerror(err));
>  		}
> -		return;
> +		return -ENOSPC;

if (err < 0) {
	printf("WARNING: could not remove %s\n", soc_elbc_compat);
	return err;
}

return 0;


>  	}
>  #endif
>  	/* Delete USB2 node as it is muxed with eLBC */
> @@ -283,7 +284,7 @@ void ft_board_setup(void *blob, bd_t *bd)
>  		printf("WARNING: could not find compatible node"
>  			" %s: %s.\n", soc_usb_compat,
>  			fdt_strerror(usb1_off));
> -		return;
> +		return -ENOSPC;

printf("WARNING: could not find compatible node %s\n", soc_usb_compat);
return usb1_off;

>  	}
>  	usb2_off = fdt_node_offset_by_compatible(blob, usb1_off,
>  			soc_usb_compat);
> @@ -291,11 +292,16 @@ void ft_board_setup(void *blob, bd_t *bd)
>  		printf("WARNING: could not find compatible node"
>  			" %s: %s.\n", soc_usb_compat,
>  			fdt_strerror(usb2_off));
> -		return;
> +		return -ENOSPC;

printf("WARNING: could not find compatible node %s\n", soc_usb_compat);
return usb2_off;

>  	}
>  	err = fdt_del_node(blob, usb2_off);
> -	if (err < 0)
> +	if (err < 0) {
>  		printf("WARNING: could not remove %s: %s.\n",
>  			soc_usb_compat, fdt_strerror(err));
> +		return -EINVAL;

printf("WARNING: could not remove %s\n", soc_usb_compat);
return err;

> +	}
> +
> +	return 0;
>  }
> +
>  #endif

...
> diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
> index a6756c6..5a0b41d 100644
> --- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
> +++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
> @@ -6,6 +6,7 @@
>  
>  #include <common.h>
>  #include <command.h>
> +#include <errno.h>
>  #include <hwconfig.h>
>  #include <pci.h>
>  #include <i2c.h>
> @@ -424,7 +425,7 @@ static void fdt_board_fixup_qe_pins(void *blob)
>  #endif
>  
>  #ifdef CONFIG_OF_BOARD_SETUP
> -void ft_board_setup(void *blob, bd_t *bd)
> +int ft_board_setup(void *blob, bd_t *bd)
>  {
>  	phys_addr_t base;
>  	phys_size_t size;
> @@ -462,14 +463,15 @@ void ft_board_setup(void *blob, bd_t *bd)
>  			printf("WARNING: could not find compatible node %s: %s.\n",
>  			       soc_elbc_compat,
>  			       fdt_strerror(off));
> -				return;
> +				return -ENOENT;

printf("WARNING: could not find compatible node %s\n", soc_elbc_compat);
return off;

>  		}
>  		err = fdt_del_node(blob, off);
>  		if (err < 0) {
>  			printf("WARNING: could not remove %s: %s.\n",
>  			       soc_elbc_compat, fdt_strerror(err));
> +			return -EINVAL;

printf("WARNING: could not remove %s\n", soc_elbc_compat);
return err;

>  		}
> -		return;
> +		return 0;
>  	}
>  #endif
>  
> @@ -480,7 +482,7 @@ void ft_board_setup(void *blob, bd_t *bd)
>  		printf("WARNING: could not find compatible node %s: %s.\n",
>  		       soc_usb_compat,
>  		       fdt_strerror(usb1_off));
> -		return;
> +		return -ENOENT;

printf("WARNING: could not find compatible node %s\n", soc_usb_compat);
return usb1_off;

>  	}
>  	usb2_off = fdt_node_offset_by_compatible(blob, usb1_off,
>  			soc_usb_compat);
> @@ -488,13 +490,15 @@ void ft_board_setup(void *blob, bd_t *bd)
>  		printf("WARNING: could not find compatible node %s: %s.\n",
>  		       soc_usb_compat,
>  		       fdt_strerror(usb2_off));
> -		return;
> +		return -ENOENT;

printf("WARNING: could not find compatible node %s\n", soc_usb_compat);
return usb2_off;

>  	}
>  	err = fdt_del_node(blob, usb2_off);
>  	if (err < 0) {
>  		printf("WARNING: could not remove %s: %s.\n",
>  		       soc_usb_compat, fdt_strerror(err));
> +		return -EINVAL;

printf("WARNING: could not remove %s\n", soc_usb_compat);
return err;


Thanks,

Anatolij


More information about the U-Boot mailing list