public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/2] spi: mxs: Introduce spi_cs_is_valid()
Date: Mon, 23 Apr 2012 23:27:15 +0200	[thread overview]
Message-ID: <201204232327.15912.marex@denx.de> (raw)
In-Reply-To: <1335205850-26575-1-git-send-email-fabio.estevam@freescale.com>

Dear Fabio Estevam,

> Introduce spi_cs_is_valid() for validating spi bus and chip select numbers.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Acked-by: Marek Vasut <marex@denx.de>
> ---
> Changes since v1:
> - Newly introduced in v2
> 
>  drivers/spi/mxs_spi.c |   13 +++++++++++--
>  1 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
> index 4e6f14e..e7237e7 100644
> --- a/drivers/spi/mxs_spi.c
> +++ b/drivers/spi/mxs_spi.c
> @@ -51,14 +51,23 @@ void spi_init(void)
>  {
>  }
> 
> +int spi_cs_is_valid(unsigned int bus, unsigned int cs)
> +{
> +	/* MXS SPI: 4 ports and 3 chip selects maximum */
> +	if (bus > 3 || cs > 2)
> +		return 0;
> +	else
> +		return 1;
> +}
> +
>  struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>  				  unsigned int max_hz, unsigned int mode)
>  {
>  	struct mxs_spi_slave *mxs_slave;
>  	uint32_t addr;
> 
> -	if (bus > 3) {
> -		printf("MXS SPI: Max bus number is 3\n");
> +	if (!spi_cs_is_valid(bus, cs)) {
> +		printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
>  		return NULL;
>  	}

Best regards,
Marek Vasut

  parent reply	other threads:[~2012-04-23 21:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 18:30 [U-Boot] [PATCH v2 1/2] spi: mxs: Introduce spi_cs_is_valid() Fabio Estevam
2012-04-23 18:30 ` [U-Boot] [PATCH v2 2/2] spi: mxs: Allow other chip selects to work Fabio Estevam
2012-04-23 21:27   ` Marek Vasut
2012-05-09  9:53   ` Stefano Babic
2012-04-23 21:27 ` Marek Vasut [this message]
2012-04-23 21:51 ` [U-Boot] [PATCH v2 1/2] spi: mxs: Introduce spi_cs_is_valid() Mike Frysinger
2012-05-09  9:53 ` Stefano Babic

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=201204232327.15912.marex@denx.de \
    --to=marex@denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox