From: Torsten Fleischer <to-fleischer@t-online.de>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: avorontsov@ru.mvista.com
Subject: Re: spi_mpc8xxx.c: chip select polarity problem
Date: Wed, 9 Dec 2009 20:13:30 +0100 [thread overview]
Message-ID: <200912092013.30831.to-fleischer@t-online.de> (raw)
In-Reply-To: <fa686aa40912090946m12fe293cg2efb043cb7a7f573@mail.gmail.com>
On Wed, Dec 9, 2009 at 18:46:51 Grant Likely wrote:
[...]
> > + ret = of_get_spi_cs_active_state(np, i, &astate);
> > + if (ret) {
> > + dev_err(dev, "can't get cs active state of device
> > " + "#%d: %d\n", i, ret);
> > + goto err_loop;
> > + }
>
> This is a bit heavy handed in that it expects the device tree to be
> fully populated with all SPI devices which isn't always a given. For
> example a board that has some unpopulated SPI devices could have some
> gaps in the GPIO CS layout. If a node can't be found, then just
> ignore it silently and move on to the next. I'd do something like
> this:
>
> + astate = of_get_spi_cs_active_state(np, i);
What should be returned if the node can't be found, 'true' or 'false?
Maybe its better to do the following:
+ ret = of_get_spi_cs_active_state(np, i, &astate);
+ if (ret) {
+ /* Device node not found */
+ continue;
+ }
> ret = gpio_direction_output(pinfo->gpios[i],
> - pinfo->alow_flags[i]);
> + pinfo->alow_flags[i] ^ !astate);
>
> BTW, why the xor? The usage is non-obvious enough that I'd like to
> see a comment describing the use case.
If I understand it right, the alow_flags describe the wiring. If set to 0 the
wiring is non-inverted, if set to 1 its inverted respectively. To take this
into account the active state has to be xor'd with the appropriate alow_flag.
next prev parent reply other threads:[~2009-12-09 19:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 16:42 spi_mpc8xxx.c: chip select polarity problem Torsten Fleischer
2009-11-16 17:10 ` Anton Vorontsov
2009-11-16 18:00 ` Anton Vorontsov
2009-11-17 20:09 ` Torsten Fleischer
2009-11-17 20:22 ` Anton Vorontsov
2009-11-17 23:28 ` Anton Vorontsov
2009-11-18 16:20 ` Torsten Fleischer
2009-11-18 23:29 ` Anton Vorontsov
2009-11-21 8:45 ` Grant Likely
2009-11-21 16:08 ` Torsten Fleischer
2009-11-25 0:33 ` Grant Likely
2009-11-25 20:41 ` Torsten Fleischer
2009-11-25 22:11 ` Grant Likely
2009-11-26 12:12 ` Anton Vorontsov
2009-11-26 17:27 ` Torsten Fleischer
2009-11-26 18:18 ` Grant Likely
2009-11-26 18:16 ` Grant Likely
2009-11-26 18:41 ` Anton Vorontsov
2009-11-26 18:50 ` Grant Likely
2009-11-26 19:01 ` Anton Vorontsov
2009-11-26 19:17 ` Grant Likely
2009-12-09 15:49 ` Torsten Fleischer
2009-12-09 17:46 ` Grant Likely
2009-12-09 19:13 ` Torsten Fleischer [this message]
2009-12-14 16:54 ` Torsten Fleischer
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=200912092013.30831.to-fleischer@t-online.de \
--to=to-fleischer@t-online.de \
--cc=avorontsov@ru.mvista.com \
--cc=grant.likely@secretlab.ca \
/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).