Re: [PATCH 2/2] imx-bbu-nand-fcb: fix build on MX28 only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lucas.

On Fri, Sep 15, 2017 at 11:07:08AM +0200, 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@xxxxxxxxxxxxxx>
> ---
>  common/imx-bbu-nand-fcb.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
> index 7218c5e1ccda..bd539bafa7f7 100644
> --- a/common/imx-bbu-nand-fcb.c
> +++ b/common/imx-bbu-nand-fcb.c
> @@ -38,9 +38,12 @@
>  #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>
> +#endif
> +
>  struct dbbt_block {
>  	uint32_t Checksum;
>  	uint32_t FingerPrint;
> @@ -141,7 +144,8 @@ static uint8_t reverse_bit(uint8_t b)
>  	return b;
>  }
>  
> -static void encode_bch_ecc(void *buf, struct fcb_block *fcb, int eccbits)
> +static void __maybe_unused encode_bch_ecc(void *buf, struct fcb_block *fcb,
> +					  int eccbits)
>  {
>  	int i, j, m = 13;
>  	int blocksize = 128;
> @@ -441,9 +445,11 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
>  		goto err;
>  	}
>  
> +#if IS_ENABLED(CONFIG_ARCH_IMX6)
>  	if (cpu_is_mx6ul() || cpu_is_mx6ull())
>  		fcb = read_fcb_bch(rawpage, 40);
>  	else
> +#endif
>  		fcb = read_fcb_hamming_13_8(rawpage);

ifdef out an if else like this is ugly and confusing.

Consider using the much more readable variant:
	if (IS_ENABLED(CONFIG_ARCH_IMX6) && (cpu_is_mx6ul() || cpu_is_mx6ull()))
		fcb = read_fcb_bch(rawpage, 40);
	else
		fcb = read_fcb_hamming_13_8(rawpage);

Same goes for next chunk in this patch.

	Sam

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



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux