linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	David Brownell
	<dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	Michael Hennerich
	<michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
Subject: Re: [PATCH 1/2] spi/bfin_spi: only request GPIO on first load
Date: Fri, 22 Oct 2010 00:30:04 -0600	[thread overview]
Message-ID: <20101022063004.GA3311@angua.secretlab.ca> (raw)
In-Reply-To: <1287727308-26653-1-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>

On Fri, Oct 22, 2010 at 02:01:47AM -0400, Mike Frysinger wrote:
> From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> The gpiolib code does not allow people to do gpio_request() on a GPIO
> once it has already been requested.  So make sure we only request the
> pin on the first setup of a SPI device.  Otherwise, if you attempts to
> reconfigure a SPI device on the fly (like change bit sizes), the setup
> function incorrectly fails.
> 
> Signed-off-by: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>

Doesn't that mean that the gpio pin be requested at device probe time
instead of in a function that can be repeatedly called?

g.

> ---
>  drivers/spi/spi_bfin5xx.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
> index ab483a0..a8f276d 100644
> --- a/drivers/spi/spi_bfin5xx.c
> +++ b/drivers/spi/spi_bfin5xx.c
> @@ -1099,12 +1099,15 @@ static int bfin_spi_setup(struct spi_device *spi)
>  	}
>  
>  	if (chip->chip_select_num >= MAX_CTRL_CS) {
> -		ret = gpio_request(chip->cs_gpio, spi->modalias);
> -		if (ret) {
> -			dev_err(&spi->dev, "gpio_request() error\n");
> -			goto pin_error;
> +		/* Only request on first setup */
> +		if (spi_get_ctldata(spi) == NULL) {
> +			ret = gpio_request(chip->cs_gpio, spi->modalias);
> +			if (ret) {
> +				dev_err(&spi->dev, "gpio_request() error\n");
> +				goto pin_error;
> +			}
> +			gpio_direction_output(chip->cs_gpio, 1);
>  		}
> -		gpio_direction_output(chip->cs_gpio, 1);
>  	}
>  
>  	dev_dbg(&spi->dev, "setup spi chip %s, width is %d, dma is %d\n",
> -- 
> 1.7.3.1
> 

  parent reply	other threads:[~2010-10-22  6:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  6:01 [PATCH 1/2] spi/bfin_spi: only request GPIO on first load Mike Frysinger
     [not found] ` <1287727308-26653-1-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2010-10-22  6:01   ` [PATCH 2/2] spi/bfin_spi: handle error/status changes after data interrupts Mike Frysinger
     [not found]     ` <1287727308-26653-2-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2010-10-22  7:28       ` Grant Likely
2010-10-22  6:30   ` Grant Likely [this message]
     [not found]     ` <20101022063004.GA3311-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-10-22  6:41       ` [PATCH 1/2] spi/bfin_spi: only request GPIO on first load Mike Frysinger
     [not found]         ` <AANLkTi=-yDBTJPhSgP7XjaKpqp7T+=inf5F1DCMZT4CZ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-22  7:25           ` [Uclinux-dist-devel] " Grant Likely
     [not found]             ` <20101022072545.GA8205-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-10-22  7:33               ` Mike Frysinger
     [not found]                 ` <AANLkTinFwZrtzPARy65oTnFgn2gxpniPXvONfWzjzF8z-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-31  4:07                   ` Grant Likely
2010-10-22  7:27   ` Grant Likely

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=20101022063004.GA3311@angua.secretlab.ca \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org \
    --cc=vapier-aBrp7R+bbdUdnm+yROfE0A@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).