From e895a4b06f9062f052d438df7f4766b3decdb3d4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 23 Oct 2014 18:58:47 -0600 Subject: fdt: Allow ft_board_setup() to report failure 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. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin --- board/amcc/canyonlands/canyonlands.c | 6 ++++-- board/amcc/sequoia/sequoia.c | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'board/amcc') diff --git a/board/amcc/canyonlands/canyonlands.c b/board/amcc/canyonlands/canyonlands.c index 79d4bab..c5cc4ff 100644 --- a/board/amcc/canyonlands/canyonlands.c +++ b/board/amcc/canyonlands/canyonlands.c @@ -490,9 +490,9 @@ int misc_init_r(void) #endif /* !defined(CONFIG_ARCHES) */ #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) -extern void __ft_board_setup(void *blob, bd_t *bd); +extern int __ft_board_setup(void *blob, bd_t *bd); -void ft_board_setup(void *blob, bd_t *bd) +int ft_board_setup(void *blob, bd_t *bd) { __ft_board_setup(blob, bd); @@ -515,5 +515,7 @@ void ft_board_setup(void *blob, bd_t *bd) fdt_find_and_setprop(blob, "/plb/sata@bffd1000", "status", "disabled", sizeof("disabled"), 1); } + + return 0; } #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ diff --git a/board/amcc/sequoia/sequoia.c b/board/amcc/sequoia/sequoia.c index 53f9b34..91c6cbf 100644 --- a/board/amcc/sequoia/sequoia.c +++ b/board/amcc/sequoia/sequoia.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -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,15 +382,14 @@ 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 -FDT_ERR_NOTFOUND; } reg = (u32 *)&prop->data[0]; reg[0] = 3; rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1); if (rc) { - printf("Unable to update property NOR mappings, err=%s\n", - fdt_strerror(rc)); - return; + printf("Unable to update property NOR mappings\n"); + return rc; } /* And now configure NAND chip select to 0 instead of 3 */ @@ -398,15 +398,16 @@ 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 len; } reg = (u32 *)&prop->data[0]; reg[0] = 0; rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1); if (rc) { - printf("Unable to update property NDFC mappings, err=%s\n", - fdt_strerror(rc)); - return; + printf("Unable to update property NDFC mapping\n"); + return rc; } + + return 0; } #endif /* CONFIG_SYS_RAMBOOT */ -- cgit v1.1