[PATCH dfu-util v2] main: Move DFU state transition blocks together

Tormod Volden lists.tormod at gmail.com
Sat Sep 24 15:08:00 CEST 2011


From: Tormod Volden <debian.tormod at gmail.com>

There is an extra DFU state check after the transfer size has been
determined. The order should not matter so move it around.

Signed-off-by: Tormod Volden <debian.tormod at gmail.com>
---

If you are already testing, please test this as well. Maybe this block
is not needed at all. I wonder if anyone is ever seeing the message
"WARNING: DFU Status:".

This is just to make the code cleaner and better structured.
It has been like this since the start of the git history,
but I do not think there is any reason for having this check
/after/ requesting the functional descriptor. If someone can
test it on sam7DFU device that would be nice. I think the
early code was made for this device.

v2: Refreshed.
  
Tormod

 src/main.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/main.c b/src/main.c
index 3eed7e6..b9e11c0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -986,6 +986,21 @@ status_again:
 		break;
 	}
 
+	if (DFU_STATUS_OK != status.bStatus ) {
+		printf("WARNING: DFU Status: '%s'\n",
+			dfu_status_to_string(status.bStatus));
+		/* Clear our status & try again. */
+		dfu_clear_status(dif->dev_handle, dif->interface);
+		dfu_get_status(dif->dev_handle, dif->interface, &status);
+
+		if (DFU_STATUS_OK != status.bStatus) {
+			fprintf(stderr, "Error: %d\n", status.bStatus);
+			exit(1);
+		}
+		if (!(quirks & QUIRK_POLLTIMEOUT))
+			usleep(status.bwPollTimeout * 1000);
+	}
+
 	/* Get the DFU mode DFU functional descriptor
 	 * If it is not found cached, we will request it from the device */
 	ret = get_cached_extra_descriptor(dif->dev, dif->configuration,
@@ -1038,21 +1053,6 @@ status_again:
 		printf("Adjusted transfer size to %i\n", transfer_size);
 	}
 
-	if (DFU_STATUS_OK != status.bStatus ) {
-		printf("WARNING: DFU Status: '%s'\n",
-			dfu_status_to_string(status.bStatus));
-		/* Clear our status & try again. */
-		dfu_clear_status(dif->dev_handle, dif->interface);
-		dfu_get_status(dif->dev_handle, dif->interface, &status);
-
-		if (DFU_STATUS_OK != status.bStatus) {
-			fprintf(stderr, "Error: %d\n", status.bStatus);
-			exit(1);
-		}
-		if (!(quirks & QUIRK_POLLTIMEOUT))
-			usleep(status.bwPollTimeout * 1000);
-	}
-
 	switch (mode) {
 	case MODE_UPLOAD:
 		file.fd = open(file.name, O_WRONLY|O_CREAT|O_EXCL, 0644);
-- 
1.7.5.4




More information about the devel mailing list