imx-bbu-nand-fcb: do not use hardcoded devicefile
Subsystems (2)
PATCH 1/2 imx-bbu-nand-fcb: do not use hardcoded devicefile
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature of
imx6_bbu_nand_register_handler()imx7_bbu_nand_register_handler()imx28_bbu_nand_register_handler()
with the other bbu register functions in order to take the devicefile as parameter.
--- common/imx-bbu-nand-fcb.c | 23 ++++++++++++++++------- include/bbu.h | 18 ++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-)
common/imx-bbu-nand-fcb.c +16 -7
@@ -1219,6 +1219,7 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *datint used =0 ;int fw_orig_len =0 ;int used_refresh =0 , unused_refresh =0 ; +const char *devname = handler->devicefile;if (data->image) { filetype =file_detect_type (data->image, data->len);
@@ -1230,7 +1231,12 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *datreturn -EINVAL ; } - bcb_cdev =cdev_by_name (handler->devicefile); +/* Support both boot /dev/nand0.barebox and boot nand0.barebox */ + devname +=str_has_prefix (devname,"/dev/" ); + +device_detect_by_name (devname); + + bcb_cdev =cdev_by_name (devname);if (!bcb_cdev) {pr_err ("%s: No FCB device!\n" , __func__);return -ENODEV ;
@@ -1432,7 +1438,8 @@ static void imx6_fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler, fcb->MetadataBytes =10 ; } -int imx6_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx6_bbu_nand_register_handler (const char *name, +const char *devicefile,unsigned long flags) {struct imx_nand_fcb_bbu_handler *imx_handler;struct bbu_handler *handler;
@@ -1451,7 +1458,7 @@ int imx6_bbu_nand_register_handler(const char *name, unsigned long flags) } handler = &imx_handler->handler; - handler->devicefile ="nand0.barebox" ; + handler->devicefile = devicefile; handler->name = name; handler->flags = flags |BBU_HANDLER_CAN_REFRESH ; handler->handler = imx_bbu_nand_update;
@@ -1526,7 +1533,8 @@ static void imx28_fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler, fcb->EraseThreshold =readl (bch_regs +BCH_MODE ); } -int imx28_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx28_bbu_nand_register_handler (const char *name, +const char *devicefile,unsigned long flags) {struct imx_nand_fcb_bbu_handler *imx_handler;struct bbu_handler *handler;
@@ -1540,7 +1548,7 @@ int imx28_bbu_nand_register_handler(const char *name, unsigned long flags) imx_handler->filetype = filetype_mxs_bootstream; handler = &imx_handler->handler; - handler->devicefile ="nand0.barebox" ; + handler->devicefile = devicefile; handler->name = name; handler->flags = flags |BBU_HANDLER_CAN_REFRESH ; handler->handler = imx_bbu_nand_update;
@@ -1599,7 +1607,8 @@ static int imx7_fcb_write(struct mtd_info *mtd, int block, struct fcb_block *fcbreturn mxs_nand_write_fcb_bch62 (block, fcb,sizeof (*fcb)); } -int imx7_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx7_bbu_nand_register_handler(const char *name + const char *devicefile, unsigned long flags) {struct imx_nand_fcb_bbu_handler *imx_handler;struct bbu_handler *handler;
@@ -1612,7 +1621,7 @@ int imx7_bbu_nand_register_handler(const char *name, unsigned long flags) imx_handler->filetype = filetype_arm_barebox; handler = &imx_handler->handler; - handler->devicefile ="nand0.barebox" ; + handler->devicefile = devicefile; handler->name = name; handler->flags = flags |BBU_HANDLER_CAN_REFRESH ; handler->handler = imx_bbu_nand_update;
include/bbu.h +12 -6
@@ -98,19 +98,25 @@ static inline int bbu_mmcboot_register_handler(const char *name,#endif #if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB ) -int imx6_bbu_nand_register_handler (const char *name,unsigned long flags); -int imx7_bbu_nand_register_handler (const char *name,unsigned long flags); -int imx28_bbu_nand_register_handler (const char *name,unsigned long flags); +int imx6_bbu_nand_register_handler (const char *name,const char *devicefile,unsigned long flags); +int imx7_bbu_nand_register_handler (const char *name,const char *devicefile,unsigned long flags); +int imx28_bbu_nand_register_handler (const char *name,const char *devicefile,unsigned long flags);#else -static inline int imx6_bbu_nand_register_handler (const char *name,unsigned long flags) +static inline int imx6_bbu_nand_register_handler (const char *name, +const char *devicefile, +unsigned long flags) {return -ENOSYS ; } -static inline int imx7_bbu_nand_register_handler (const char *name,unsigned long flags) +static inline int imx7_bbu_nand_register_handler (const char *name, +const char *devicefile, +unsigned long flags) {return -ENOSYS ; } -static inline int imx28_bbu_nand_register_handler (const char *name,unsigned long flags) +static inline int imx28_bbu_nand_register_handler (const char *name, +const char *devicefile, +unsigned long flags) {return -ENOSYS ; }
Signature · 1 line
2.25.1
PATCH 2/2 ARM: boards: fix nand bbu_handler device paths
The bbu handler for nand now takes the device
path as parameter and no longer use the hardcoded
value.
Make the change accordingly to all the boards
using it.
--- arch/arm/boards/digi-ccimx6ulsom/board.c | 3 ++- arch/arm/boards/gateworks-ventana/board.c | 4 +++- arch/arm/boards/karo-tx6x/board.c | 3 ++- arch/arm/boards/phytec-som-imx6/board.c | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-)
arch/arm/boards/digi-ccimx6ulsom/board.c +2 -1
@@ -11,7 +11,8 @@ static int digi_ccimx6ulsbcpro_device_init(void)if (!of_machine_is_compatible ("digi,ccimx6ulsbcpro" ))return 0 ; -imx6_bbu_nand_register_handler ("nand" ,BBU_HANDLER_FLAG_DEFAULT ); +imx6_bbu_nand_register_handler ("nand" ,"/dev/nand0.barebox" , +BBU_HANDLER_FLAG_DEFAULT );barebox_set_hostname ("ccimx6ulsbcpro" );
arch/arm/boards/gateworks-ventana/board.c +3 -1
@@ -72,7 +72,9 @@ static int gw54xx_devices_init(void)if (gsc_get_rev (&client) <'E' )of_register_fixup (gw54xx_wdog_of_fixup,NULL ); -imx6_bbu_nand_register_handler ("nand" ,BBU_HANDLER_FLAG_DEFAULT ); +imx6_bbu_nand_register_handler ("nand" , +"/dev/nand0.barebox" , +BBU_HANDLER_FLAG_DEFAULT );barebox_set_hostname ("gw54xx" );
arch/arm/boards/karo-tx6x/board.c +2 -1
@@ -110,7 +110,8 @@ static int tx6x_devices_init(void)* this board has eMMC or NAND. */ if (sbmr1 & (1 <<7 )) { -imx6_bbu_nand_register_handler ("nand" ,BBU_HANDLER_FLAG_DEFAULT ); +imx6_bbu_nand_register_handler ("nand" ,"/dev/nand0.barebox" , +BBU_HANDLER_FLAG_DEFAULT );of_device_enable_and_register_by_name ("environment-nand" );of_device_enable_and_register_by_alias ("nand" ); }else {
arch/arm/boards/phytec-som-imx6/board.c +3 -1
@@ -259,7 +259,9 @@ static int physom_imx6_probe(struct device *dev)imx6_bbu_internal_mmcboot_register_handler ("mmc1-boot" ,"mmc1" ,0 ); }else { -imx6_bbu_nand_register_handler ("nand" ,BBU_HANDLER_FLAG_DEFAULT ); +imx6_bbu_nand_register_handler ("nand" , +"/dev/nand0.barebox" , +BBU_HANDLER_FLAG_DEFAULT ); }defaultenv_append_directory (defaultenv_physom_imx6);
Signature · 1 line
2.25.1
Hello Stefano,
Quoted 9 lines · Stefano Manni
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature of
imx6_bbu_nand_register_handler()imx7_bbu_nand_register_handler()imx28_bbu_nand_register_handler()with the other bbu register functions in order to take the devicefile as parameter.
Is this this the sole motivation behind the patch or do you intend to actually make use of the ability of varying the devicefile?
Thanks,
Ahmad
Quoted 126 lines
Signed-off-by Stefano Manni <[email protected]>--- common/imx-bbu-nand-fcb.c | 23 ++++++++++++++++------- include/bbu.h | 18 ++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-)common/imx-bbu-nand-fcb.c +16
-7@@ -1219,6 +1219,7 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *datint used =0 ;int fw_orig_len =0 ;int used_refresh =0 , unused_refresh =0 ; +const char *devname = handler->devicefile;if (data->image) { filetype =file_detect_type (data->image, data->len);@@ -1230,7 +1231,12 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *datreturn -EINVAL ; } - bcb_cdev =cdev_by_name (handler->devicefile); +/* Support both boot /dev/nand0.barebox and boot nand0.barebox */ + devname +=str_has_prefix (devname,"/dev/" ); + +device_detect_by_name (devname); + + bcb_cdev =cdev_by_name (devname);if (!bcb_cdev) {pr_err ("%s: No FCB device!\n" , __func__);return -ENODEV ;@@ -1432,7 +1438,8 @@ static void imx6_fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler, fcb->MetadataBytes =10 ; } -int imx6_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx6_bbu_nand_register_handler (const char *name, +const char *devicefile,unsigned long flags) {struct imx_nand_fcb_bbu_handler *imx_handler;struct bbu_handler *handler;@@ -1451,7 +1458,7 @@ int imx6_bbu_nand_register_handler(const char *name, unsigned long flags) } handler = &imx_handler->handler; - handler->devicefile ="nand0.barebox" ; + handler->devicefile = devicefile; handler->name = name; handler->flags = flags |BBU_HANDLER_CAN_REFRESH ; handler->handler = imx_bbu_nand_update;@@ -1526,7 +1533,8 @@ static void imx28_fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler, fcb->EraseThreshold =readl (bch_regs +BCH_MODE ); } -int imx28_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx28_bbu_nand_register_handler (const char *name, +const char *devicefile,unsigned long flags) {struct imx_nand_fcb_bbu_handler *imx_handler;struct bbu_handler *handler;@@ -1540,7 +1548,7 @@ int imx28_bbu_nand_register_handler(const char *name, unsigned long flags) imx_handler->filetype = filetype_mxs_bootstream; handler = &imx_handler->handler; - handler->devicefile ="nand0.barebox" ; + handler->devicefile = devicefile; handler->name = name; handler->flags = flags |BBU_HANDLER_CAN_REFRESH ; handler->handler = imx_bbu_nand_update;@@ -1599,7 +1607,8 @@ static int imx7_fcb_write(struct mtd_info *mtd, int block, struct fcb_block *fcbreturn mxs_nand_write_fcb_bch62 (block, fcb,sizeof (*fcb)); } -int imx7_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx7_bbu_nand_register_handler(const char *name + const char *devicefile, unsigned long flags) {struct imx_nand_fcb_bbu_handler *imx_handler;struct bbu_handler *handler;@@ -1612,7 +1621,7 @@ int imx7_bbu_nand_register_handler(const char *name, unsigned long flags) imx_handler->filetype = filetype_arm_barebox; handler = &imx_handler->handler; - handler->devicefile ="nand0.barebox" ; + handler->devicefile = devicefile; handler->name = name; handler->flags = flags |BBU_HANDLER_CAN_REFRESH ; handler->handler = imx_bbu_nand_update;include/bbu.h +12
-6@@ -98,19 +98,25 @@ static inline int bbu_mmcboot_register_handler(const char *name,#endif #if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB ) -int imx6_bbu_nand_register_handler (const char *name,unsigned long flags); -int imx7_bbu_nand_register_handler (const char *name,unsigned long flags); -int imx28_bbu_nand_register_handler (const char *name,unsigned long flags); +int imx6_bbu_nand_register_handler (const char *name,const char *devicefile,unsigned long flags); +int imx7_bbu_nand_register_handler (const char *name,const char *devicefile,unsigned long flags); +int imx28_bbu_nand_register_handler (const char *name,const char *devicefile,unsigned long flags);#else -static inline int imx6_bbu_nand_register_handler (const char *name,unsigned long flags) +static inline int imx6_bbu_nand_register_handler (const char *name, +const char *devicefile, +unsigned long flags) {return -ENOSYS ; } -static inline int imx7_bbu_nand_register_handler (const char *name,unsigned long flags) +static inline int imx7_bbu_nand_register_handler (const char *name, +const char *devicefile, +unsigned long flags) {return -ENOSYS ; } -static inline int imx28_bbu_nand_register_handler (const char *name,unsigned long flags) +static inline int imx28_bbu_nand_register_handler (const char *name, +const char *devicefile, +unsigned long flags) {return -ENOSYS ; }
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hello Ahmad,
Quoted 10 lines · Ahmad Fatoum
Hello Stefano,
Quoted 7 lines · Stefano Manni
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature of
imx6_bbu_nand_register_handler()
imx7_bbu_nand_register_handler()
imx28_bbu_nand_register_handler()
Quoted 6 lines
Quoted 2 lines
with the other bbu register functions in order to take the devicefile as parameter.
Is this this the sole motivation behind the patch or do you intend to actually make use of the ability of varying the devicefile?
my purpose is to let people use a device/partition different from the hardcoded one.
Quoted 3 lines
Thanks,
Ahmad
Quoted 13 lines · Stefano Manni
Hello Ahmad,
Quoted 10 lines · Ahmad Fatoum
Hello Stefano,
Quoted 7 lines · Stefano Manni
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature ofimx6_bbu_nand_register_handler()
imx7_bbu_nand_register_handler()
imx28_bbu_nand_register_handler()
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
with the other bbu register functions in order to take the devicefile as parameter.
Is this this the sole motivation behind the patch or do you intend to actually make use of the ability of varying the devicefile?
my purpose is to let people use a device/partition different from the hardcoded one.
Can you have multiple NANDs? But yes, customizing partition name can be useful.
Thanks,
Ahmad
Quoted 7 lines
Quoted 4 lines
Thanks,
Ahmad
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hello Ahmad,
Quoted 22 lines · Ahmad Fatoum
Quoted 21 lines · Stefano Manni
Hello Ahmad,
Quoted 16 lines · Ahmad Fatoum
Hello Stefano,
Quoted 9 lines · Stefano Manni
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature of
imx6_bbu_nand_register_handler()
imx7_bbu_nand_register_handler()
imx28_bbu_nand_register_handler()with the other bbu register functions in order to take the devicefile as parameter.
Is this this the sole motivation behind the patch or do you intend to actually make use of the ability of varying the devicefile?
Quoted 6 lines
Quoted 2 lines
my purpose is to let people use a device/partition different from
the hardcoded one.Can you have multiple NANDs? But yes, customizing partition name can be useful.
for sure I cannot have multiple NANDs but I can have a different partition name.
Anyway drop the patch if you consider it not necessary.
Best,
Stefano
Quoted 2 lines
Thanks,
Ahmad
Quoted 28 lines · Stefano Manni
Hello Ahmad,
Quoted 23 lines · Ahmad Fatoum
Quoted 21 lines · Stefano Manni
Hello Ahmad,
Quoted 10 lines · Ahmad Fatoum
Hello Stefano,
Quoted 7 lines · Stefano Manni
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature of
imx6_bbu_nand_register_handler()
imx7_bbu_nand_register_handler()
imx28_bbu_nand_register_handler()Quoted 6 lines
Quoted 2 lines
with the other bbu register functions in order to take the devicefile as parameter.
Is this this the sole motivation behind the patch or do you intend to actually make use of the ability of varying the devicefile?
my purpose is to let people use a device/partition different from the hardcoded one.
Quoted 7 lines
Quoted 3 lines
Can you have multiple NANDs? But yes, customizing partition name can be useful.
for sure I cannot have multiple NANDs but I can have a different partition name.
Anyway drop the patch if you consider it not necessary.
I think the patch is ok.
Cheers,
Ahmad
Quoted 9 lines
Best,
StefanoQuoted 2 lines
Thanks,
Ahmad
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Stefano,
I merged both patches into one to avoid intermediate breakage.
common/imx-bbu-nand-fcb.c static int imx7_fcb_write(struct mtd_info *mtd, int block, struct fcb_block *fcb · line 1612
Quoted 8 lines · Stefano Manni
common/imx-bbu-nand-fcb.c +2
-1@@ -1599,7 +1607,8 @@ static int imx7_fcb_write(struct mtd_info *mtd, int block, struct fcb_block *fcbreturn mxs_nand_write_fcb_bch62 (block, fcb,sizeof (*fcb)); } -int imx7_bbu_nand_register_handler (const char *name,unsigned long flags) +int imx7_bbu_nand_register_handler(const char *name + const char *devicefile, unsigned long flags) {
Also added the missing comma after *name
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 8 lines · Stefano Manni
Device file was hardcoded to "nand0.barebox".
This patch harmonize the signature of
imx6_bbu_nand_register_handler()imx7_bbu_nand_register_handler()imx28_bbu_nand_register_handler()[...]
Applied, thanks!
[1/2] imx-bbu-nand-fcb: do not use hardcoded devicefile
https://git.pengutronix.de/cgit/barebox/commit/?id=e377e1a068db (link may not be stable)
[2/2] ARM: boards: fix nand bbu_handler device paths
(no commit info)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>