All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] spi:ls102xqds:Support for compatibility for QSPI and DSPI modules drivers
Date: Fri, 26 Sep 2014 19:58:12 +0200	[thread overview]
Message-ID: <5425A934.90904@suse.de> (raw)
In-Reply-To: <1411718199-27215-1-git-send-email-b44548@freescale.com>

Hi,

Am 26.09.2014 um 09:56 schrieb Chao Fu:
> From: Chao Fu <B44548@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@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

  reply	other threads:[~2014-09-26 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26  7:56 [U-Boot] [PATCH] spi:ls102xqds:Support for compatibility for QSPI and DSPI modules drivers Chao Fu
2014-09-26 17:58 ` Andreas Färber [this message]
2014-10-04  2:46 ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5425A934.90904@suse.de \
    --to=afaerber@suse.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.