linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Guennadi Liakhovetski
	<g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 2/2] spi: bitbang: support the new SPI_BOARD_FLAG_RELEASE_CS flag
Date: Sat, 17 Mar 2012 22:42:13 +0000	[thread overview]
Message-ID: <20120317224213.ED0FF3E03CC@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.1203152230190.2988-0199iw4Nj15frtckUFj5Ag@public.gmane.org>

On Thu, 15 Mar 2012 22:32:14 +0100 (CET), Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org> wrote:
> By supporting the new SPI_BOARD_FLAG_RELEASE_CS flag we let underlying
> hardware drivers implement more efficient runtime power-management.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
> ---
>  drivers/spi/spi-bitbang.c |   22 ++++++++++------------
>  1 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
> index fe06e1b..c895d85 100644
> --- a/drivers/spi/spi-bitbang.c
> +++ b/drivers/spi/spi-bitbang.c
> @@ -347,17 +347,14 @@ static void bitbang_work(struct work_struct *work)
>  			if (t->delay_usecs)
>  				udelay(t->delay_usecs);
>  
> -			if (!cs_change)
> -				continue;
> -			if (t->transfer_list.next == &m->transfers)
> -				break;
> -
> -			/* sometimes a short mid-message deselect of the chip
> -			 * may be needed to terminate a mode or command
> -			 */
> -			ndelay(nsecs);
> -			bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
> -			ndelay(nsecs);
> +			if (cs_change && !list_is_last(&t->transfer_list, &m->transfers)) {
> +				/* sometimes a short mid-message deselect of the chip
> +				 * may be needed to terminate a mode or command
> +				 */
> +				ndelay(nsecs);
> +				bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
> +				ndelay(nsecs);
> +			}
>  		}
>  
>  		m->status = status;
> @@ -367,7 +364,8 @@ static void bitbang_work(struct work_struct *work)
>  		 * cs_change has hinted that the next message will probably
>  		 * be for this chip too.
>  		 */
> -		if (!(status == 0 && cs_change)) {
> +		if (!(status == 0 && cs_change) ||
> +		    spi->flags & SPI_BOARD_FLAG_RELEASE_CS) {

That's rather heavy handed, and will probably break drivers that lock the spi
bus to guarantee concurrent messages (like the MMC layer).  I don't think you
can do it this way.

It might be okay to force CS disable if the spi bus hasn't been exclusively
locked.  I know the comment talks about hinting (possibly for performance reasonse),
but I'm more interested in correctness at this point.

g.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

  parent reply	other threads:[~2012-03-17 22:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 21:32 [PATCH 1/2] spi: add an SPI-device flag for systems, preferring power-efficiency Guennadi Liakhovetski
     [not found] ` <Pine.LNX.4.64.1203152228430.2988-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-15 21:32   ` [PATCH 2/2] spi: bitbang: support the new SPI_BOARD_FLAG_RELEASE_CS flag Guennadi Liakhovetski
     [not found]     ` <Pine.LNX.4.64.1203152230190.2988-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-17 22:42       ` Grant Likely [this message]
2012-04-13 14:43         ` Guennadi Liakhovetski
     [not found]           ` <Pine.LNX.4.64.1204131625230.16773-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-04-27 17:02             ` 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=20120317224213.ED0FF3E03CC@localhost \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=g.liakhovetski-Mmb7MZpHnFY@public.gmane.org \
    --cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@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).