spi/bitbang: Factor out message transfer from message pump loop
In order to make it easier to convert to transfer_one_message() lift the code that does the actual message transfer out of the work function that implements the message pump. This should have no functional impact, it's just a simple code motion patch. Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
@@ -255,17 +255,10 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
|
|||||||
* Drivers can provide word-at-a-time i/o primitives, or provide
|
* Drivers can provide word-at-a-time i/o primitives, or provide
|
||||||
* transfer-at-a-time ones to leverage dma or fifo hardware.
|
* transfer-at-a-time ones to leverage dma or fifo hardware.
|
||||||
*/
|
*/
|
||||||
static void bitbang_work(struct work_struct *work)
|
static int spi_bitbang_transfer_one(struct spi_device *spi,
|
||||||
|
struct spi_message *m)
|
||||||
{
|
{
|
||||||
struct spi_bitbang *bitbang =
|
struct spi_bitbang *bitbang;
|
||||||
container_of(work, struct spi_bitbang, work);
|
|
||||||
unsigned long flags;
|
|
||||||
struct spi_message *m, *_m;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&bitbang->lock, flags);
|
|
||||||
bitbang->busy = 1;
|
|
||||||
list_for_each_entry_safe(m, _m, &bitbang->queue, queue) {
|
|
||||||
struct spi_device *spi;
|
|
||||||
unsigned nsecs;
|
unsigned nsecs;
|
||||||
struct spi_transfer *t = NULL;
|
struct spi_transfer *t = NULL;
|
||||||
unsigned tmp;
|
unsigned tmp;
|
||||||
@@ -273,8 +266,7 @@ static void bitbang_work(struct work_struct *work)
|
|||||||
int status;
|
int status;
|
||||||
int do_setup = -1;
|
int do_setup = -1;
|
||||||
|
|
||||||
list_del(&m->queue);
|
bitbang = spi_master_get_devdata(spi->master);
|
||||||
spin_unlock_irqrestore(&bitbang->lock, flags);
|
|
||||||
|
|
||||||
/* FIXME this is made-up ... the correct value is known to
|
/* FIXME this is made-up ... the correct value is known to
|
||||||
* word-at-a-time bitbang code, and presumably chipselect()
|
* word-at-a-time bitbang code, and presumably chipselect()
|
||||||
@@ -282,7 +274,6 @@ static void bitbang_work(struct work_struct *work)
|
|||||||
*/
|
*/
|
||||||
nsecs = 100;
|
nsecs = 100;
|
||||||
|
|
||||||
spi = m->spi;
|
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
cs_change = 1;
|
cs_change = 1;
|
||||||
status = 0;
|
status = 0;
|
||||||
@@ -367,6 +358,24 @@ static void bitbang_work(struct work_struct *work)
|
|||||||
ndelay(nsecs);
|
ndelay(nsecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bitbang_work(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct spi_bitbang *bitbang =
|
||||||
|
container_of(work, struct spi_bitbang, work);
|
||||||
|
unsigned long flags;
|
||||||
|
struct spi_message *m, *_m;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&bitbang->lock, flags);
|
||||||
|
bitbang->busy = 1;
|
||||||
|
list_for_each_entry_safe(m, _m, &bitbang->queue, queue) {
|
||||||
|
list_del(&m->queue);
|
||||||
|
spin_unlock_irqrestore(&bitbang->lock, flags);
|
||||||
|
|
||||||
|
spi_bitbang_transfer_one(m->spi, m);
|
||||||
|
|
||||||
spin_lock_irqsave(&bitbang->lock, flags);
|
spin_lock_irqsave(&bitbang->lock, flags);
|
||||||
}
|
}
|
||||||
bitbang->busy = 0;
|
bitbang->busy = 0;
|
||||||
|
Reference in New Issue
Block a user