From: "Steven A. Falco" <sfalco@harris.com>
To: "linuxppc-dev@ozlabs.org" <linuxppc-dev@ozlabs.org>
Cc: David Brownell <david-b@pacbell.net>, Stefan Roese <sr@denx.de>
Subject: [PATCH v1] Make spi_ppc4xx.c tolerate 0 bits-per-word and 0 speed_hz
Date: Wed, 24 Jun 2009 10:34:34 -0400 [thread overview]
Message-ID: <4A42397A.8030105@harris.com> (raw)
If a SPI transfer is set up, but does not explicitly set bits-per-word
and speed_hz, then the transaction fails, because spi_ppc4xx_setupxfer
rejects it.
This patch modifies the logic to chose the struct spi_transfer parameters
only if they are non-zero. Otherwise, the struct spi_device parameters
are used.
Additionally, since there is no OF binding for bits-per-word, we have to
tolerate the case where both t->bits_per_word and spi->bits_per_word are
zero.
---
This was brought to light by a pending patch to spi_bitbang, which results
in more calls to spi_ppc4xx_setupxfer.
drivers/spi/spi_ppc4xx.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c
index e46292b..9775bf2 100644
--- a/drivers/spi/spi_ppc4xx.c
+++ b/drivers/spi/spi_ppc4xx.c
@@ -151,16 +151,24 @@ static int spi_ppc4xx_setupxfer(struct spi_device *spi, struct spi_transfer *t)
/* Write new configration */
out_8(&hw->regs->mode, cs->mode);
+ /* Start with the generic configuration for this device. */
+ bpw = spi->bits_per_word;
+ cs->speed_hz = spi->max_speed_hz;
+
/*
- * Allow platform reduce the interrupt load on the CPU during SPI
- * transfers. We do not target maximum performance, but rather allow
- * platform to limit SPI bus frequency and interrupt rate.
+ * Allow the platform to reduce the interrupt load on the CPU during
+ * SPI transfers. We do not target maximum performance, but rather
+ * allow the platform to limit SPI bus frequency and interrupt rate.
*/
- bpw = t ? t->bits_per_word : spi->bits_per_word;
- cs->speed_hz = t ? min(t->speed_hz, spi->max_speed_hz) :
- spi->max_speed_hz;
+ if(t) {
+ if(t->bits_per_word)
+ bpw = t->bits_per_word;
+
+ if(t->speed_hz)
+ cs->speed_hz = min(t->speed_hz, spi->max_speed_hz);
+ }
- if (bpw != 8) {
+ if (bpw && bpw != 8) {
dev_err(&spi->dev, "invalid bits-per-word (%d)\n", bpw);
return -EINVAL;
}
--
1.6.0.2
reply other threads:[~2009-06-24 14:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4A42397A.8030105@harris.com \
--to=sfalco@harris.com \
--cc=david-b@pacbell.net \
--cc=linuxppc-dev@ozlabs.org \
--cc=sr@denx.de \
/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).