Commit b8f2e7bb authored by Brian Niebuhr's avatar Brian Niebuhr Committed by Grant Likely

spi/bitbang: reinitialize transfer parameters for every message

This patch fixes the setup_transfer logic to account for the case where
multiple messages to different SPI devices are in the queue simultaneously.
With the current logic, the second message in the queue will end up
using the transfer parameters for the previous message in the queue.

The fix is to reinitialize the transfer parameters for each message
rather than only once on the first message.
Signed-off-by: default avatarBrian Niebuhr <bniebuhr@efjohnson.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 3c8e1a84
...@@ -259,7 +259,6 @@ static void bitbang_work(struct work_struct *work) ...@@ -259,7 +259,6 @@ static void bitbang_work(struct work_struct *work)
struct spi_bitbang *bitbang = struct spi_bitbang *bitbang =
container_of(work, struct spi_bitbang, work); container_of(work, struct spi_bitbang, work);
unsigned long flags; unsigned long flags;
int do_setup = -1;
int (*setup_transfer)(struct spi_device *, int (*setup_transfer)(struct spi_device *,
struct spi_transfer *); struct spi_transfer *);
...@@ -275,6 +274,7 @@ static void bitbang_work(struct work_struct *work) ...@@ -275,6 +274,7 @@ static void bitbang_work(struct work_struct *work)
unsigned tmp; unsigned tmp;
unsigned cs_change; unsigned cs_change;
int status; int status;
int do_setup = -1;
m = container_of(bitbang->queue.next, struct spi_message, m = container_of(bitbang->queue.next, struct spi_message,
queue); queue);
...@@ -307,6 +307,8 @@ static void bitbang_work(struct work_struct *work) ...@@ -307,6 +307,8 @@ static void bitbang_work(struct work_struct *work)
status = setup_transfer(spi, t); status = setup_transfer(spi, t);
if (status < 0) if (status < 0)
break; break;
if (do_setup == -1)
do_setup = 0;
} }
/* set up default clock polarity, and activate chip; /* set up default clock polarity, and activate chip;
...@@ -367,11 +369,6 @@ static void bitbang_work(struct work_struct *work) ...@@ -367,11 +369,6 @@ static void bitbang_work(struct work_struct *work)
m->status = status; m->status = status;
m->complete(m->context); m->complete(m->context);
/* restore speed and wordsize if it was overridden */
if (do_setup == 1)
setup_transfer(spi, NULL);
do_setup = 0;
/* normally deactivate chipselect ... unless no error and /* normally deactivate chipselect ... unless no error and
* cs_change has hinted that the next message will probably * cs_change has hinted that the next message will probably
* be for this chip too. * be for this chip too.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment