All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 01/11] fdt: Allow ft_board_setup() to report failure
Date: Fri, 24 Oct 2014 14:04:32 -0400	[thread overview]
Message-ID: <20141024180432.GY25506@bill-the-cat> (raw)
In-Reply-To: <1414112337-22735-1-git-send-email-sjg@chromium.org>

On Thu, Oct 23, 2014 at 06:58:47PM -0600, Simon Glass wrote:

> This function can fail if the device tree runs out of space. Rather than
> silently booting with an incomplete device tree, allow the failure to be
> detected.
> 
> Unfortunately this involves changing a lot of places in the code. I have
> not changed behvaiour to return an error where one is not currently
> returned, to avoid unexpected breakage.
> 
> Eventually it would be nice to allow boards to register functions to be
> called to update the device tree. This would avoid all the many functions
> to do this. However it's not clear yet if this should be done using driver
> model or with a linker list. This work is left for later.
[snip]
> diff --git a/board/freescale/p1_p2_rdb/p1_p2_rdb.c b/board/freescale/p1_p2_rdb/p1_p2_rdb.c
> index aba4f53..19fef50 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;
> @@ -263,39 +264,41 @@ void ft_board_setup(void *blob, bd_t *bd)
>  		int off = fdt_node_offset_by_compatible(blob, -1,
>  			soc_elbc_compat);
>  		if (off < 0) {
> -			printf("WARNING: could not find compatible node"
> -				" %s: %s.\n", soc_elbc_compat,
> -				fdt_strerror(off));
> -				return;
> +			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));
> +			printf("WARNING: could not remove %s\n",
> +			       soc_elbc_compat);
> +			return err;
>  		}
> -		return;
> +		return 0;
>  	}
>  #endif
>  	/* Delete USB2 node as it is muxed with eLBC */
>  	usb1_off = fdt_node_offset_by_compatible(blob, -1,
>  		soc_usb_compat);
>  	if (usb1_off < 0) {
> -		printf("WARNING: could not find compatible node"
> -			" %s: %s.\n", soc_usb_compat,
> -			fdt_strerror(usb1_off));
> -		return;
> +		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);
>  	if (usb2_off < 0) {
> -		printf("WARNING: could not find compatible node"
> -			" %s: %s.\n", soc_usb_compat,
> -			fdt_strerror(usb2_off));
> -		return;
> +		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));
> +	if (err < 0) {
> +		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..66bc041 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;
> @@ -459,17 +460,17 @@ void ft_board_setup(void *blob, bd_t *bd)
>  		int off = fdt_node_offset_by_compatible(blob, -1,
>  				soc_elbc_compat);
>  		if (off < 0) {
> -			printf("WARNING: could not find compatible node %s: %s.\n",
> -			       soc_elbc_compat,
> -			       fdt_strerror(off));
> -				return;
> +			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));
> +			printf("WARNING: could not remove %s\n",
> +			       soc_elbc_compat);
> +			return err;
>  		}
> -		return;
> +		return 0;
>  	}
>  #endif
>  
> @@ -477,24 +478,23 @@ void ft_board_setup(void *blob, bd_t *bd)
>  	usb1_off = fdt_node_offset_by_compatible(blob, -1,
>  		soc_usb_compat);
>  	if (usb1_off < 0) {
> -		printf("WARNING: could not find compatible node %s: %s.\n",
> -		       soc_usb_compat,
> -		       fdt_strerror(usb1_off));
> -		return;
> +		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);
>  	if (usb2_off < 0) {
> -		printf("WARNING: could not find compatible node %s: %s.\n",
> -		       soc_usb_compat,
> -		       fdt_strerror(usb2_off));
> -		return;
> +		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));
> +		printf("WARNING: could not remove %s\n", soc_usb_compat);
> +		return err;
>  	}
>  
> +	return 0;
>  }
>  #endif

In both of these boards you add <errno.h> but don't make use of it, did
you intend to make something return -FDT_ERR_NOTFOUND and then not need
to after all?  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141024/c914842f/attachment-0001.pgp>

  parent reply	other threads:[~2014-10-24 18:04 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24  0:58 [U-Boot] [PATCH v2 01/11] fdt: Allow ft_board_setup() to report failure Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 02/11] fdt: Report failure of ft_board_setup() Simon Glass
2014-10-24 15:15   ` Anatolij Gustschin
2014-10-24 18:05   ` Tom Rini
2014-11-21  3:24     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 03/11] fdt: Export the fdt_find_or_add_subnode() function Simon Glass
2014-10-24 16:48   ` Anatolij Gustschin
2014-10-24 18:05   ` Tom Rini
2014-11-21  3:24     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 04/11] fdt: Add device tree memory bindings Simon Glass
2014-10-24 18:49   ` Tom Rini
2014-10-24 20:04     ` Simon Glass
2014-10-27 14:24       ` Tom Rini
2014-10-27 18:50         ` Simon Glass
2014-11-12 15:13           ` Simon Glass
2014-11-12 21:42           ` Tom Rini
2014-11-12 22:14             ` Simon Glass
2014-11-20 14:37               ` Tom Rini
2014-11-20 17:42                 ` Simon Glass
2014-12-10  5:31                   ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 05/11] fdt: Use the correct return types for fdtdec_decode_region() Simon Glass
2014-10-24 18:07   ` Tom Rini
2014-11-21  3:25     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 06/11] fdt: Enhance flashmap function to deal with region properties Simon Glass
2014-10-24 18:08   ` Tom Rini
2014-11-21  3:25     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 07/11] fdt: Tidy up error handling in image_setup_libfdt() Simon Glass
2014-10-24 18:09   ` Tom Rini
2014-11-21  3:25     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 08/11] fdt: Add ft_system_setup() function for system device tree additions Simon Glass
2014-10-24 18:50   ` Tom Rini
2014-11-13  2:40     ` Simon Glass
2014-11-21  3:25       ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 09/11] fdt: Change fdt_pack_reg() to static and fix types Simon Glass
2014-10-24 18:49   ` Tom Rini
2014-11-21  3:25     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 10/11] fdt: Add a function to decode a named memory region Simon Glass
2014-10-24 18:49   ` Tom Rini
2014-11-21  3:26     ` Simon Glass
2014-10-24  0:58 ` [U-Boot] [PATCH v2 11/11] fdt: Try to use fdt_address_cells()/fdt_size_cells() Simon Glass
2014-10-24 18:49   ` Tom Rini
2014-11-21  3:26     ` Simon Glass
2014-10-24 15:50 ` [U-Boot] [PATCH v2 01/11] fdt: Allow ft_board_setup() to report failure Anatolij Gustschin
2014-10-24 18:04 ` Tom Rini [this message]
2014-10-24 19:56   ` Simon Glass
2014-11-21  3:24     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141024180432.GY25506@bill-the-cat \
    --to=trini@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.