diff mbox

spi: reinitialize transfer parameters for every message

Message ID 1275682387-10681-1-git-send-email-bniebuhr@efjohnson.com (mailing list archive)
State Superseded
Headers show

Commit Message

Brian Niebuhr June 4, 2010, 8:13 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 5265330..8c0c0b8 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -259,7 +259,6 @@  static void bitbang_work(struct work_struct *work)
 	struct spi_bitbang	*bitbang =
 		container_of(work, struct spi_bitbang, work);
 	unsigned long		flags;
-	int			do_setup = -1;
 	int			(*setup_transfer)(struct spi_device *,
 					struct spi_transfer *);
 
@@ -275,6 +274,8 @@  static void bitbang_work(struct work_struct *work)
 		unsigned		tmp;
 		unsigned		cs_change;
 		int			status;
+		int			do_setup = 1;
+		int			restore_param = 0;
 
 		m = container_of(bitbang->queue.next, struct spi_message,
 				queue);
@@ -295,10 +296,11 @@  static void bitbang_work(struct work_struct *work)
 		list_for_each_entry (t, &m->transfers, transfer_list) {
 
 			/* override speed or wordsize? */
-			if (t->speed_hz || t->bits_per_word)
+			if (t->speed_hz || t->bits_per_word) {
 				do_setup = 1;
+				restore_param = 1;
+			}
 
-			/* init (-1) or override (1) transfer params */
 			if (do_setup != 0) {
 				if (!setup_transfer) {
 					status = -ENOPROTOOPT;
@@ -307,6 +309,7 @@  static void bitbang_work(struct work_struct *work)
 				status = setup_transfer(spi, t);
 				if (status < 0)
 					break;
+				do_setup = 0;
 			}
 
 			/* set up default clock polarity, and activate chip;
@@ -368,9 +371,8 @@  static void bitbang_work(struct work_struct *work)
 		m->complete(m->context);
 
 		/* restore speed and wordsize if it was overridden */
-		if (do_setup == 1)
+		if (restore_param == 1)
 			setup_transfer(spi, NULL);
-		do_setup = 0;
 
 		/* normally deactivate chipselect ... unless no error and
 		 * cs_change has hinted that the next message will probably