From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: David Brownell <david-b@pacbell.net>,
David Brownell <dbrownell@users.sourceforge.net>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 10/10] SPI: spi_bitbang: clocking fixes
Date: Tue, 16 May 2006 14:38:38 -0700 [thread overview]
Message-ID: <11478155192773-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <1147815518968-git-send-email-greg@kroah.com>
From: David Brownell <david-b@pacbell.net>
This fixes two problems triggered by the MMC stack updating clocks:
- SPI masters driver should accept a max clock speed of zero; that's one
convention for marking idle devices. (Presumably that helps controllers
that don't autogate clocks to "off" when not in use.)
- There are more than 1000 nanoseconds per millisecond; setting the clock
down to 125 KHz now works properly.
Showing once again that Zero (http://en.wikipedia.org/wiki/Zero) is still
an inexhaustible number of bugs.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/spi/spi_bitbang.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
1e316d7566b63767aa18902235c719e9e95465d0
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 0f7f5c6..dd2f950 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -167,9 +167,11 @@ int spi_bitbang_setup_transfer(struct sp
/* nsecs = (clock period)/2 */
if (!hz)
hz = spi->max_speed_hz;
- cs->nsecs = (1000000000/2) / hz;
- if (cs->nsecs > MAX_UDELAY_MS * 1000)
- return -EINVAL;
+ if (hz) {
+ cs->nsecs = (1000000000/2) / hz;
+ if (cs->nsecs > (MAX_UDELAY_MS * 1000 * 1000))
+ return -EINVAL;
+ }
return 0;
}
@@ -184,9 +186,6 @@ int spi_bitbang_setup(struct spi_device
struct spi_bitbang *bitbang;
int retval;
- if (!spi->max_speed_hz)
- return -EINVAL;
-
bitbang = spi_master_get_devdata(spi->master);
/* REVISIT: some systems will want to support devices using lsb-first
@@ -216,7 +215,7 @@ int spi_bitbang_setup(struct spi_device
if (retval < 0)
return retval;
- dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec\n",
+ dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n",
__FUNCTION__, spi->mode & (SPI_CPOL | SPI_CPHA),
spi->bits_per_word, 2 * cs->nsecs);
@@ -405,6 +404,7 @@ int spi_bitbang_transfer(struct spi_devi
{
struct spi_bitbang *bitbang;
unsigned long flags;
+ int status = 0;
m->actual_length = 0;
m->status = -EINPROGRESS;
@@ -414,11 +414,15 @@ int spi_bitbang_transfer(struct spi_devi
return -ESHUTDOWN;
spin_lock_irqsave(&bitbang->lock, flags);
- list_add_tail(&m->queue, &bitbang->queue);
- queue_work(bitbang->workqueue, &bitbang->work);
+ if (!spi->max_speed_hz)
+ status = -ENETDOWN;
+ else {
+ list_add_tail(&m->queue, &bitbang->queue);
+ queue_work(bitbang->workqueue, &bitbang->work);
+ }
spin_unlock_irqrestore(&bitbang->lock, flags);
- return 0;
+ return status;
}
EXPORT_SYMBOL_GPL(spi_bitbang_transfer);
--
1.3.2
prev parent reply other threads:[~2006-05-16 21:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-16 21:37 [GIT PATCH] SPI patches for 2.6.17-rc4 Greg KH
2006-05-16 21:38 ` [PATCH 01/10] SPI: per-transfer overrides for wordsize and clocking Greg KH
2006-05-16 21:38 ` [PATCH 02/10] SPI: add PXA2xx SSP SPI Driver Greg KH
2006-05-16 21:38 ` [PATCH 03/10] SPI: spi whitespace fixes Greg KH
2006-05-16 21:38 ` [PATCH 04/10] SPI: spi bounce buffer has a minimum length Greg KH
2006-05-16 21:38 ` [PATCH 05/10] SPI: Add David as the SPI subsystem maintainer Greg KH
2006-05-16 21:38 ` [PATCH 06/10] SPI: Renamed bitbang_transfer_setup to spi_bitbang_setup_transfer and export it Greg KH
2006-05-16 21:38 ` [PATCH 07/10] SPI: devices can require LSB-first encodings Greg KH
2006-05-16 21:38 ` [PATCH 08/10] SPI: busnum == 0 needs to work Greg KH
2006-05-16 21:38 ` [PATCH 09/10] spi: Update to PXA2xx SPI Driver Greg KH
2005-01-01 0:10 ` Roland Dreier
2006-05-17 1:40 ` Greg KH
2006-05-16 21:38 ` Greg KH [this message]
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=11478155192773-git-send-email-greg@kroah.com \
--to=greg@kroah.com \
--cc=david-b@pacbell.net \
--cc=dbrownell@users.sourceforge.net \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.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