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>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: spi-bitbang inverted logic?
Date: Thu, 15 Mar 2012 15:31:50 -0600	[thread overview]
Message-ID: <20120315213150.C36853E04E5@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.1203151201040.2988-0199iw4Nj15frtckUFj5Ag@public.gmane.org>

On Thu, 15 Mar 2012 12:09:42 +0100 (CET), Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org> wrote:
> Hi all
> 
> I stumbled across this code in spi-bitbang.c:
> 
> 		list_for_each_entry (t, &m->transfers, transfer_list) {
> 			...
> 			cs_change = t->cs_change;
> 			...
> 			if (!cs_change)
> 				continue;
> 			...
> 			/* 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);
> 		}
> 		...
> 
> 		/* normally deactivate chipselect ... unless no error and
> 		 * cs_change has hinted that the next message will probably
> 		 * be for this chip too.
> 		 */
> 		if (!(status == 0 && cs_change)) {
> 			ndelay(nsecs);
> 			bitbang->chipselect(spi, BITBANG_CS_INACTIVE);
> 			ndelay(nsecs);
> 		}
> 
> So, IIUC, on the first occurrance cs_change is interpreted as "true == 
> have to disable CD," whereas the second one does the opposite. Shouldn't 
> the latter one be inverted?

Actually, I suspect that cs_change is being abused here to allow multiple
messages to operate over a single cs_change assertion.  It does look dodgy,
but I think you'll need to audit the users of cs_change to ensure that every
'normal' message has cs_change asserted for the last transfer in a message.

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-15 21:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 11:09 spi-bitbang inverted logic? Guennadi Liakhovetski
     [not found] ` <Pine.LNX.4.64.1203151201040.2988-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-15 21:31   ` Grant Likely [this message]
2012-03-16  6:09   ` Jassi Brar
     [not found]     ` <CABb+yY0KqpSYnGqcf95JU0PkjMen_ECwPMmNTFdnMRwrguGPnA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-16  8:34       ` Guennadi Liakhovetski
     [not found]         ` <Pine.LNX.4.64.1203160915380.13465-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-16 10:00           ` Jassi Brar

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=20120315213150.C36853E04E5@localhost \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=g.liakhovetski-Mmb7MZpHnFY@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).