Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 26760
b: refs/heads/master
c: 1e316d7
h: refs/heads/master
v: v3
  • Loading branch information
David Brownell authored and Greg Kroah-Hartman committed May 16, 2006
1 parent 692cffb commit 237ee87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9708c121c38fe864eb6f5a119f7525729686e095
refs/heads/master: 1e316d7566b63767aa18902235c719e9e95465d0
24 changes: 14 additions & 10 deletions trunk/drivers/spi/spi_bitbang.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ int spi_bitbang_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
/* 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;
}
Expand All @@ -184,9 +186,6 @@ int spi_bitbang_setup(struct spi_device *spi)
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
Expand Down Expand Up @@ -216,7 +215,7 @@ int spi_bitbang_setup(struct spi_device *spi)
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);

Expand Down Expand Up @@ -405,6 +404,7 @@ int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m)
{
struct spi_bitbang *bitbang;
unsigned long flags;
int status = 0;

m->actual_length = 0;
m->status = -EINPROGRESS;
Expand All @@ -414,11 +414,15 @@ int spi_bitbang_transfer(struct spi_device *spi, struct spi_message *m)
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);

Expand Down

0 comments on commit 237ee87

Please sign in to comment.