Make it possible to write barebox image to multiple partitions like xload partitions. Signed-off-by: Teresa Remmet <t.remmet@xxxxxxxxx> --- arch/arm/boards/phytec-som-am335x/board.c | 7 ++++- arch/arm/mach-omap/am33xx_bbu_nand.c | 50 +++++++++++++++++-------------- arch/arm/mach-omap/include/mach/bbu.h | 7 +++-- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c index ca325b5..d5c27e2 100644 --- a/arch/arm/boards/phytec-som-am335x/board.c +++ b/arch/arm/boards/phytec-som-am335x/board.c @@ -60,6 +60,10 @@ static char *xloadslots[] = { "/dev/nand0.xload_backup3.bb" }; +static char *nandslots[] = { + "/dev/nand0.barebox.bb", +}; + static int physom_devices_init(void) { if (!of_machine_is_compatible("phytec,am335x-som")) @@ -105,7 +109,8 @@ static int physom_devices_init(void) am33xx_bbu_spi_nor_register_handler("spi", "/dev/m25p0.barebox"); am33xx_bbu_nand_xloadslots_register_handler("MLO.nand", xloadslots, ARRAY_SIZE(xloadslots)); - am33xx_bbu_nand_register_handler("nand", "/dev/nand0.barebox.bb"); + am33xx_bbu_nand_slots_register_handler("nand", nandslots, + ARRAY_SIZE(nandslots)); if (IS_ENABLED(CONFIG_SHELL_NONE)) return am33xx_of_register_bootdevice(); diff --git a/arch/arm/mach-omap/am33xx_bbu_nand.c b/arch/arm/mach-omap/am33xx_bbu_nand.c index 25f0e79..7785d40 100644 --- a/arch/arm/mach-omap/am33xx_bbu_nand.c +++ b/arch/arm/mach-omap/am33xx_bbu_nand.c @@ -62,21 +62,15 @@ static int write_image(const char *devfile, const void *image, size_t size) } /* - * This handler updates all given xload slots in nand with an image. + * Upate given nand partitions with an image */ -static int nand_xloadslots_update_handler(struct bbu_handler *handler, - struct bbu_data *data) +static int nand_slot_update_handler(struct bbu_handler *handler, + struct bbu_data *data) { - int ret = 0; + int ret, i; + struct nand_bbu_handler *nh; const void *image = data->image; size_t size = data->len; - struct nand_bbu_handler *nh; - int i = 0; - - if (file_detect_type(image, size) != filetype_ch_image) { - pr_err("%s is not a valid ch-image\n", data->imagefile); - return -EINVAL; - } nh = container_of(handler, struct nand_bbu_handler, bbu_handler); @@ -100,6 +94,23 @@ static int nand_xloadslots_update_handler(struct bbu_handler *handler, return 0; } +/* + * This handler updates all given xload slots in nand with an image. + */ +static int nand_xloadslots_update_handler(struct bbu_handler *handler, + struct bbu_data *data) +{ + const void *image = data->image; + size_t size = data->len; + + if (file_detect_type(image, size) != filetype_ch_image) { + pr_err("%s is not a valid ch-image\n", data->imagefile); + return -EINVAL; + } + + return nand_slot_update_handler(handler, data); +} + int am33xx_bbu_nand_xloadslots_register_handler(const char *name, char **devicefile, int num_devicefiles) @@ -124,32 +135,27 @@ int am33xx_bbu_nand_xloadslots_register_handler(const char *name, static int nand_update_handler(struct bbu_handler *handler, struct bbu_data *data) { - int ret = 0; const void *image = data->image; size_t size = data->len; - struct nand_bbu_handler *nh; if (file_detect_type(image, size) != filetype_arm_barebox) { pr_err("%s is not a valid barebox image\n", data->imagefile); return -EINVAL; } - nh = container_of(handler, struct nand_bbu_handler, bbu_handler); - - ret = bbu_confirm(data); - if (ret != 0) - return ret; - - return write_image(data->devicefile, image, size); + return nand_slot_update_handler(handler, data); } -int am33xx_bbu_nand_register_handler(const char *name, char *devicefile) +int am33xx_bbu_nand_slots_register_handler(const char *name, char **devicefile, + int num_devicefiles) { struct nand_bbu_handler *handler; int ret; handler = xzalloc(sizeof(*handler)); - handler->bbu_handler.devicefile = devicefile; + handler->devicefile = devicefile; + handler->num_devicefiles = num_devicefiles; + handler->bbu_handler.devicefile = devicefile[0]; handler->bbu_handler.handler = nand_update_handler; handler->bbu_handler.name = name; diff --git a/arch/arm/mach-omap/include/mach/bbu.h b/arch/arm/mach-omap/include/mach/bbu.h index 7c5dcbd..c8b0a55 100644 --- a/arch/arm/mach-omap/include/mach/bbu.h +++ b/arch/arm/mach-omap/include/mach/bbu.h @@ -21,7 +21,8 @@ static inline int am33xx_bbu_spi_nor_register_handler(const char *name, char *de int am33xx_bbu_nand_xloadslots_register_handler(const char *name, char **devicefile, int num_devicefiles); -int am33xx_bbu_nand_register_handler(const char *name, char *devicefile); +int am33xx_bbu_nand_slots_register_handler(const char *name, char **devicefile, + int num_devicefiles); #else static inline int am33xx_bbu_nand_xloadslots_register_handler(const char *name, char **devicefile, @@ -30,7 +31,9 @@ static inline int am33xx_bbu_nand_xloadslots_register_handler(const char *name, return 0; } -static inline int am33xx_bbu_nand_register_handler(const char *name, char *devicefile) +static inline int am33xx_bbu_nand_slots_register_handler(const char *name, + char **devicefile, + int num_devicefiles) { return 0; } -- 1.9.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox