ARM: i.MX: bbu-internal: call detect for mmc devices
Subsystems (3)
PATCH 1/1 ARM: i.MX: bbu-internal: call detect for mmc devices
For the MMC update_handler it makes sense to probe the device before writing to it. If the device is not probed yet, you get errors like
$ barebox_update -y -t mmc0 /mnt/tftp/barebox.bin
barebox_update: Read-only file systemThe code is nearly equivalent to
$ detect mmc0
$ barebox_update -y -t mmc0 /mnt/tftp/barebox.binThe function device_detect_by_name also handles device names with partition suffix like "/dev/mmc3.boot0".
While at it, use the macro BIT for the bit field.
--- arch/arm/mach-imx/imx-bbu-internal.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx-bbu-internal.c +19 -4
@@ -34,9 +34,10 @@#define FLASH_HEADER_OFFSET_MMC 0x400 -#define IMX_INTERNAL_FLAG_NAND (1 << 0) -#define IMX_INTERNAL_FLAG_KEEP_DOSPART (1 << 1) -#define IMX_INTERNAL_FLAG_ERASE (1 << 2) +#define IMX_INTERNAL_FLAG_NAND BIT(0) +#define IMX_INTERNAL_FLAG_KEEP_DOSPART BIT(1) +#define IMX_INTERNAL_FLAG_ERASE BIT(2) +#define IMX_INTERNAL_FLAG_PROBE BIT(3)struct imx_internal_bbu_handler {struct bbu_handler handler;
@@ -52,8 +53,21 @@ struct imx_internal_bbu_handler {static int imx_bbu_write_device (struct imx_internal_bbu_handler *imx_handler,struct bbu_data *data,void *buf,int image_len) { +const char *devname;int fd, ret; +if (imx_handler->flags &IMX_INTERNAL_FLAG_PROBE ) { + devname = data->devicefile; +if (!strncmp (devname,"/dev/" ,5 )) + devname +=5 ; + ret =device_detect_by_name (devname); +if (ret) { +printf ("Detecting device %s failed: %s\n" , devname, +strerror (-ret)); +return ret; + } + } + fd =open (data->devicefile,O_RDWR |O_CREAT );if (fd <0 )return fd;
@@ -487,7 +501,8 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile, imx_handler =__init_handler (name, devicefile, flags); imx_handler->flash_header_offset =FLASH_HEADER_OFFSET_MMC ; - imx_handler->flags =IMX_INTERNAL_FLAG_KEEP_DOSPART ; + imx_handler->flags =IMX_INTERNAL_FLAG_KEEP_DOSPART | +IMX_INTERNAL_FLAG_PROBE ; imx_handler->handler.handler = imx_bbu_internal_v2_update;return __register_handler (imx_handler);
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
*ping
Mit freundlichen Grüßen / Kind regards,
Stefan Christ
Quoted 79 lines · Stefan Christ
For the MMC
update_handlerit makes sense to probe the device before writing to it. If the device is not probed yet, you get errors like$ barebox_update -y -t mmc0 /mnt/tftp/barebox.bin barebox_update: Read-only file systemThe code is nearly equivalent to
$ detect mmc0 $ barebox_update -y -t mmc0 /mnt/tftp/barebox.binThe function
device_detect_by_namealso handles device names with partition suffix like "/dev/mmc3.boot0".While at it, use the macro BIT for the bit field.
Signed-off-by Stefan Christ <[email protected]>--- arch/arm/mach-imx/imx-bbu-internal.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-imx/imx-bbu-internal.c +19
-4@@ -34,9 +34,10 @@#define FLASH_HEADER_OFFSET_MMC 0x400 -#define IMX_INTERNAL_FLAG_NAND (1 << 0) -#define IMX_INTERNAL_FLAG_KEEP_DOSPART (1 << 1) -#define IMX_INTERNAL_FLAG_ERASE (1 << 2) +#define IMX_INTERNAL_FLAG_NAND BIT(0) +#define IMX_INTERNAL_FLAG_KEEP_DOSPART BIT(1) +#define IMX_INTERNAL_FLAG_ERASE BIT(2) +#define IMX_INTERNAL_FLAG_PROBE BIT(3)struct imx_internal_bbu_handler {struct bbu_handler handler;@@ -52,8 +53,21 @@ struct imx_internal_bbu_handler {static int imx_bbu_write_device (struct imx_internal_bbu_handler *imx_handler,struct bbu_data *data,void *buf,int image_len) { +const char *devname;int fd, ret; +if (imx_handler->flags &IMX_INTERNAL_FLAG_PROBE ) { + devname = data->devicefile; +if (!strncmp (devname,"/dev/" ,5 )) + devname +=5 ; + ret =device_detect_by_name (devname); +if (ret) { +printf ("Detecting device %s failed: %s\n" , devname, +strerror (-ret)); +return ret; + } + } + fd =open (data->devicefile,O_RDWR |O_CREAT );if (fd <0 )return fd;@@ -487,7 +501,8 @@ int imx6_bbu_internal_mmc_register_handler(const char *name, char *devicefile, imx_handler =__init_handler (name, devicefile, flags); imx_handler->flash_header_offset =FLASH_HEADER_OFFSET_MMC ; - imx_handler->flags =IMX_INTERNAL_FLAG_KEEP_DOSPART ; + imx_handler->flags =IMX_INTERNAL_FLAG_KEEP_DOSPART | +IMX_INTERNAL_FLAG_PROBE ; imx_handler->handler.handler = imx_bbu_internal_v2_update;return __register_handler (imx_handler);Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerHi Stefan,
Quoted 40 lines · Stefan Christ
For the MMC
update_handlerit makes sense to probe the device before writing to it. If the device is not probed yet, you get errors like$ barebox_update -y -t mmc0 /mnt/tftp/barebox.bin barebox_update: Read-only file systemThe code is nearly equivalent to
$ detect mmc0 $ barebox_update -y -t mmc0 /mnt/tftp/barebox.binThe function
device_detect_by_namealso handles device names with partition suffix like "/dev/mmc3.boot0".While at it, use the macro BIT for the bit field.
Signed-off-by Stefan Christ <[email protected]>--- arch/arm/mach-imx/imx-bbu-internal.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-imx/imx-bbu-internal.c +4
-3@@ -34,9 +34,10 @@#define FLASH_HEADER_OFFSET_MMC 0x400 -#define IMX_INTERNAL_FLAG_NAND (1 << 0) -#define IMX_INTERNAL_FLAG_KEEP_DOSPART (1 << 1) -#define IMX_INTERNAL_FLAG_ERASE (1 << 2) +#define IMX_INTERNAL_FLAG_NAND BIT(0) +#define IMX_INTERNAL_FLAG_KEEP_DOSPART BIT(1) +#define IMX_INTERNAL_FLAG_ERASE BIT(2) +#define IMX_INTERNAL_FLAG_PROBE BIT(3)struct imx_internal_bbu_handler {struct bbu_handler handler;
arch/arm/mach-imx/imx-bbu-internal.c struct imx_internal_bbu_handler { · line 59
Quoted 7 lines
arch/arm/mach-imx/imx-bbu-internal.c +2
-0@@ -52,8 +53,21 @@ struct imx_internal_bbu_handler {static int imx_bbu_write_device (struct imx_internal_bbu_handler *imx_handler,struct bbu_data *data,void *buf,int image_len) { +const char *devname;int fd, ret; +if (imx_handler->flags &IMX_INTERNAL_FLAG_PROBE ) {
device_detect_by_name() should be safe to call, I don't think we need this additional flag. Just always call device_detect_by_name(). We have to drop the return value checking though.
In fact we have the following patch in one of our internal customer trees, this should be suitable for your issue, right?
Sascha
-------------------------------8<-----------------------------
From 5770640f4b06730bfd71eadce60bd411e437832b Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Fri, 26 Jul 2013 12:41:55 +0200
Subject: [PATCH] ARM: i.MX: bbu-internal: detect device before writing to it
--- arch/arm/mach-imx/imx-bbu-internal.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-imx/imx-bbu-internal.c +3 -0
@@ -132,6 +132,9 @@ static int imx_bbu_check_prereq(struct bbu_data *data)if (ret)return ret; +if (!strncmp (data->devicefile,"/dev/" ,5 )) +device_detect_by_name (data->devicefile +5 ); +return 0 ; }
Signature · 13 lines
2.7.0 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Stefan Christ
Tested-byHi Sascha,
Quoted 6 lines
device_detect_by_name()should be safe to call, I don't think we need this additional flag. Just always calldevice_detect_by_name(). We have to drop the return value checking though.In fact we have the following patch in one of our internal customer trees, this should be suitable for your issue, right?
Yep. These two lines of code are sufficent for our use case ;-) Here is my:
Will you apply that patch to master?
Mit freundlichen Grüßen / Kind regards,
Stefan Christ
Quoted 95 lines · Sascha Hauer
Hi Stefan,
Quoted 40 lines · Stefan Christ
For the MMC
update_handlerit makes sense to probe the device before writing to it. If the device is not probed yet, you get errors like$ barebox_update -y -t mmc0 /mnt/tftp/barebox.bin barebox_update: Read-only file systemThe code is nearly equivalent to
$ detect mmc0 $ barebox_update -y -t mmc0 /mnt/tftp/barebox.binThe function
device_detect_by_namealso handles device names with partition suffix like "/dev/mmc3.boot0".While at it, use the macro BIT for the bit field.
Signed-off-by Stefan Christ <[email protected]>--- arch/arm/mach-imx/imx-bbu-internal.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)arch/arm/mach-imx/imx-bbu-internal.c +4
-3@@ -34,9 +34,10 @@#define FLASH_HEADER_OFFSET_MMC 0x400 -#define IMX_INTERNAL_FLAG_NAND (1 << 0) -#define IMX_INTERNAL_FLAG_KEEP_DOSPART (1 << 1) -#define IMX_INTERNAL_FLAG_ERASE (1 << 2) +#define IMX_INTERNAL_FLAG_NAND BIT(0) +#define IMX_INTERNAL_FLAG_KEEP_DOSPART BIT(1) +#define IMX_INTERNAL_FLAG_ERASE BIT(2) +#define IMX_INTERNAL_FLAG_PROBE BIT(3)struct imx_internal_bbu_handler {struct bbu_handler handler;arch/arm/mach-imx/imx-bbu-internal.c struct imx_internal_bbu_handler { · line 59
Quoted 7 lines
arch/arm/mach-imx/imx-bbu-internal.c +2
-0@@ -52,8 +53,21 @@ struct imx_internal_bbu_handler {static int imx_bbu_write_device (struct imx_internal_bbu_handler *imx_handler,struct bbu_data *data,void *buf,int image_len) { +const char *devname;int fd, ret; +if (imx_handler->flags &IMX_INTERNAL_FLAG_PROBE ) {
device_detect_by_name()should be safe to call, I don't think we need this additional flag. Just always calldevice_detect_by_name(). We have to drop the return value checking though.In fact we have the following patch in one of our internal customer trees, this should be suitable for your issue, right?
Sascha
-------------------------------8<-----------------------------
From
5770640f4b06730bfd71eadce60bd411e437832bMon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Fri, 26 Jul 2013 12:41:55 +0200
Subject: [PATCH] ARM: i.MX: bbu-internal: detect device before writing to itSigned-off-by Sascha Hauer <[email protected]>--- arch/arm/mach-imx/imx-bbu-internal.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-imx/imx-bbu-internal.c +3
-0@@ -132,6 +132,9 @@ static int imx_bbu_check_prereq(struct bbu_data *data)if (ret)return ret; +if (!strncmp (data->devicefile,"/dev/" ,5 )) +device_detect_by_name (data->devicefile +5 ); +return 0 ; }Signature · 8 lines
2.7.0 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerQuoted 6 lines · Stefan Christ
Hi Sascha,
Quoted 4 lines
device_detect_by_name()should be safe to call, I don't think we need this additional flag. Just always calldevice_detect_by_name(). We have to drop the return value checking though.
Quoted 8 lines
Quoted 2 lines
In fact we have the following patch in one of our internal customer trees, this should be suitable for your issue, right?
Yep. These two lines of code are sufficent for our use case ;-) Here is my:
Tested-by Stefan Christ <[email protected]>Will you apply that patch to master?
As it's not a regression or serious bug I applied it to next and not to master.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Sascha,
Quoted 2 lines
As it's not a regression or serious bug I applied it to next and not to master.
Oh. yes of course. Sry my typing was faster than my thinking. The next branch is the correct place for it.
Mit freundlichen Grüßen / Kind regards,
Stefan Christ
Quoted 12 lines · Sascha Hauer
Quoted 11 lines · Stefan Christ
Hi Sascha,
Quoted 6 lines
device_detect_by_name()should be safe to call, I don't think we need this additional flag. Just always calldevice_detect_by_name(). We have to drop the return value checking though.In fact we have the following patch in one of our internal customer trees, this should be suitable for your issue, right?
Yep. These two lines of code are sufficent for our use case ;-) Here is my:
Quoted 14 lines
Quoted 3 lines
Tested-by Stefan Christ <[email protected]>Will you apply that patch to master?
As it's not a regression or serious bug I applied it to next and not to master.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox