mirror of https://gitee.com/openkylin/linux.git
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:
parent
874b315856
commit
91b3085867
|
@ -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
|
||||
* 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 =
|
||||
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;
|
||||
struct spi_bitbang *bitbang;
|
||||
unsigned nsecs;
|
||||
struct spi_transfer *t = NULL;
|
||||
unsigned tmp;
|
||||
|
@ -273,8 +266,7 @@ static void bitbang_work(struct work_struct *work)
|
|||
int status;
|
||||
int do_setup = -1;
|
||||
|
||||
list_del(&m->queue);
|
||||
spin_unlock_irqrestore(&bitbang->lock, flags);
|
||||
bitbang = spi_master_get_devdata(spi->master);
|
||||
|
||||
/* FIXME this is made-up ... the correct value is known to
|
||||
* word-at-a-time bitbang code, and presumably chipselect()
|
||||
|
@ -282,7 +274,6 @@ static void bitbang_work(struct work_struct *work)
|
|||
*/
|
||||
nsecs = 100;
|
||||
|
||||
spi = m->spi;
|
||||
tmp = 0;
|
||||
cs_change = 1;
|
||||
status = 0;
|
||||
|
@ -367,6 +358,24 @@ static void bitbang_work(struct work_struct *work)
|
|||
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);
|
||||
}
|
||||
bitbang->busy = 0;
|
||||
|
|
Loading…
Reference in New Issue