mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2] imx-bbu-nand-fcb: fix build on MX28 only
@ 2017-11-17 18:14 Lucas Stach
  2017-11-21  7:18 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2017-11-17 18:14 UTC (permalink / raw)
  To: barebox

This code may be compiled without ARCH_IMX6 present, so it must not
depend on any functions provided by the architecture support.

Fixes: a2618c215bff (imx-bbu-nand-fcb: add support for imx6ul)
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
v2: Remove ifdeffery by introducing a dedicated function, as
    suggested by Sascha.
---
 common/imx-bbu-nand-fcb.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 89b404884ae8..2c8ca979266c 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -38,9 +38,21 @@
 #include <io.h>
 #include <crc.h>
 #include <mach/generic.h>
-#include <mach/imx6.h>
 #include <mtd/mtd-peb.h>
 
+#ifdef CONFIG_ARCH_IMX6
+#include <mach/imx6.h>
+static inline int fcb_is_bch_encoded(void)
+{
+       return cpu_is_mx6ul() || cpu_is_mx6ull();
+}
+#else
+static inline int fcb_is_bch_encoded(void)
+{
+       return 0;
+}
+#endif
+
 struct dbbt_block {
 	uint32_t Checksum;
 	uint32_t FingerPrint;
@@ -441,7 +453,7 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
 		goto err;
 	}
 
-	if (cpu_is_mx6ul() || cpu_is_mx6ull())
+	if (fcb_is_bch_encoded())
 		fcb = read_fcb_bch(rawpage, 40);
 	else
 		fcb = read_fcb_hamming_13_8(rawpage);
@@ -899,7 +911,7 @@ static int imx_bbu_write_fcbs_dbbts(struct mtd_info *mtd, struct fcb_block *fcb)
 
 	fcb_raw_page = xzalloc(mtd->writesize + mtd->oobsize);
 
-	if (cpu_is_mx6ul() || cpu_is_mx6ull()) {
+	if (fcb_is_bch_encoded()) {
 		/* 40 bit BCH, for i.MX6UL(L) */
 		encode_bch_ecc(fcb_raw_page + 32, fcb, 40);
 	} else {
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] imx-bbu-nand-fcb: fix build on MX28 only
  2017-11-17 18:14 [PATCH v2] imx-bbu-nand-fcb: fix build on MX28 only Lucas Stach
@ 2017-11-21  7:18 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2017-11-21  7:18 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Fri, Nov 17, 2017 at 07:14:26PM +0100, Lucas Stach wrote:
> This code may be compiled without ARCH_IMX6 present, so it must not
> depend on any functions provided by the architecture support.
> 
> Fixes: a2618c215bff (imx-bbu-nand-fcb: add support for imx6ul)
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> v2: Remove ifdeffery by introducing a dedicated function, as
>     suggested by Sascha.
> ---
>  common/imx-bbu-nand-fcb.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
> index 89b404884ae8..2c8ca979266c 100644
> --- a/common/imx-bbu-nand-fcb.c
> +++ b/common/imx-bbu-nand-fcb.c
> @@ -38,9 +38,21 @@
>  #include <io.h>
>  #include <crc.h>
>  #include <mach/generic.h>
> -#include <mach/imx6.h>
>  #include <mtd/mtd-peb.h>
>  
> +#ifdef CONFIG_ARCH_IMX6
> +#include <mach/imx6.h>
> +static inline int fcb_is_bch_encoded(void)
> +{
> +       return cpu_is_mx6ul() || cpu_is_mx6ull();
> +}
> +#else
> +static inline int fcb_is_bch_encoded(void)
> +{
> +       return 0;
> +}
> +#endif
> +
>  struct dbbt_block {
>  	uint32_t Checksum;
>  	uint32_t FingerPrint;
> @@ -441,7 +453,7 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
>  		goto err;
>  	}
>  
> -	if (cpu_is_mx6ul() || cpu_is_mx6ull())
> +	if (fcb_is_bch_encoded())
>  		fcb = read_fcb_bch(rawpage, 40);
>  	else
>  		fcb = read_fcb_hamming_13_8(rawpage);
> @@ -899,7 +911,7 @@ static int imx_bbu_write_fcbs_dbbts(struct mtd_info *mtd, struct fcb_block *fcb)
>  
>  	fcb_raw_page = xzalloc(mtd->writesize + mtd->oobsize);
>  
> -	if (cpu_is_mx6ul() || cpu_is_mx6ull()) {
> +	if (fcb_is_bch_encoded()) {
>  		/* 40 bit BCH, for i.MX6UL(L) */
>  		encode_bch_ecc(fcb_raw_page + 32, fcb, 40);
>  	} else {
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-21  7:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 18:14 [PATCH v2] imx-bbu-nand-fcb: fix build on MX28 only Lucas Stach
2017-11-21  7:18 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox