linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	software-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org
Subject: Re: [PATCH] of: spi: Return error from of_spi_register_master on bad "cs-gpios" property
Date: Sat, 02 Mar 2013 22:49:06 +0000	[thread overview]
Message-ID: <20130302224906.369303E2F5C@localhost> (raw)
In-Reply-To: <1360761804-16044-1-git-send-email-andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>

On Wed, 13 Feb 2013 14:23:24 +0100, Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org> wrote:
> This makes sure that an error is returned on an incorrectly formed
> "cs-gpios" property, but reports success when the "cs-gpios" property is
> well formed or missing.
> 
> When holes in the cs-gpios property phandle list is used to indicate
> that some other form of chipselect is to be used it is important that
> failure to read a broken "cs-gpios" property does not silently fail
> leading to the spi controller to use an unintended chipselect.
> 
> Signed-off-by: Andreas Larsson <andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>

Applied, thanks.

g.

> ---
> 
> Can only be applied to devicetree/next as it builds upon the
> "of: Add helper for counting phandle refernces" patch series.
> 
>  drivers/spi/spi.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 21c4748..9b5f024 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1068,8 +1068,11 @@ static int of_spi_register_master(struct spi_master *master)
>  	nb = of_gpio_named_count(np, "cs-gpios");
>  	master->num_chipselect = max(nb, (int)master->num_chipselect);
>  
> -	if (nb < 1)
> +	/* Return error only for an incorrectly formed cs-gpios property */
> +	if (nb == 0 || nb == -ENOENT)
>  		return 0;
> +	else if (nb < 0)
> +		return nb;
>  
>  	cs = devm_kzalloc(&master->dev,
>  			  sizeof(int) * master->num_chipselect,
> -- 
> 1.7.0.4
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

      parent reply	other threads:[~2013-03-02 22:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 13:23 [PATCH] of: spi: Return error from of_spi_register_master on bad "cs-gpios" property Andreas Larsson
     [not found] ` <1360761804-16044-1-git-send-email-andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org>
2013-03-02 22:49   ` Grant Likely [this message]

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=20130302224906.369303E2F5C@localhost \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=andreas-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=software-FkzTOoA/JUlBDgjK7y7TUQ@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).