[U-Boot] [PATCH] spi:ls102xqds:Support for compatibility for QSPI and DSPI modules drivers

Andreas Färber afaerber at suse.de
Fri Sep 26 19:58:12 CEST 2014


Hi,

Am 26.09.2014 um 09:56 schrieb Chao Fu:
> From: Chao Fu <B44548 at freescale.com>
> 
> Useage:
> For exmaple(ls1021 ls1021aqds):
> 
> 	SPI bus defination can be find in
> 	arch/arm/include/asm/arch-ls102xa/config.h
> 
> 	SPI_BUS_FSL_QSPI                                0
> 	SPI_BUS_FSL_DSPI1                               1
> 	SPI_BUS_FSL_DSPI2                               2
> 
> 	and SPI devices info:
> 	AT45DB021 is on spi bus 1 cs 0
> 	S25FL064  is on spi bus 2 cs 0
> 	S25FL128S is on spi bus 0 cs 0
> 
> 	Before using any SPI bus and SPI flash, execute sf probe bus:cs in uboot cmdline
> 	Such as use S25FL064, sf probe 2:0

This could use some spellchecking... (usage, example, definition, found)

> 
> Signed-off-by: Chao Fu <B44548 at freescale.com>
> ---
>  arch/arm/include/asm/arch-ls102xa/config.h |   5 +-
>  board/freescale/ls1021aqds/ls1021aqds.c    |  33 ++++
>  drivers/spi/Makefile                       |   1 +
>  drivers/spi/fsl_dspi.c                     |  78 +++------
>  drivers/spi/fsl_qspi.c                     |  35 ++--
>  drivers/spi/fsl_spi_interface.c            | 267 +++++++++++++++++++++++++++++
>  6 files changed, 339 insertions(+), 80 deletions(-)
>  create mode 100644 drivers/spi/fsl_spi_interface.c
[...]
> diff --git a/board/freescale/ls1021aqds/ls1021aqds.c b/board/freescale/ls1021aqds/ls1021aqds.c
> index 12e83f7..5db2126 100644
> --- a/board/freescale/ls1021aqds/ls1021aqds.c
> +++ b/board/freescale/ls1021aqds/ls1021aqds.c
> @@ -230,6 +230,39 @@ int board_init(void)
>  	return 0;
>  }
>  
> +int board_spi_find_bus(unsigned int bus, unsigned int cs)
> +{
> +	switch (bus) {
> +	case SPI_BUS_FSL_DSPI1:
> +	case SPI_BUS_FSL_DSPI2:
> +	case SPI_BUS_FSL_QSPI:
> +		break;
> +	default:
> +		return -1;
> +	}
> +
> +	switch (bus) {
> +	case SPI_BUS_FSL_DSPI1:
> +		if (cs == 0)
> +			return 0;
> +	case SPI_BUS_FSL_DSPI2:
> +		if (cs == 0)
> +			return 0;
> +	case SPI_BUS_FSL_QSPI:
> +		if (cs == 0)
> +			return 0;
> +	default:
> +		return -1;
> +	}
> +}
[snip]

This code is both redundant and potentially dangerous. In the cs != 0
case, it falls through to the next case label, where the same if is
being executed - no harm done, but someone might want to touch that code
in the future. Why not simply move a single if+return into the first switch?

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg


More information about the U-Boot mailing list