[PATCH 3/4 dfu-util] main: Use libusb_le16_to_cpu instead of homebrew equivalent

Tormod Volden lists.tormod at gmail.com
Thu Sep 15 22:08:02 CEST 2011


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

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

Now that we have switched to libusb-1.0...

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

diff --git a/src/main.c b/src/main.c
index 0312603..819e26c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,14 +58,6 @@ int verbose = 0;
  * but 253 would even accomodate any UTF-8 encoding */
 #define MAX_DESC_STR_LEN 253
 
-/* define a portable function for reading a 16bit little-endian word */
-unsigned short get_int16_le(const void *p)
-{
-    const unsigned char *cp = p;
-
-    return ( cp[0] ) | ( ((unsigned short)cp[1]) << 8 );
-}
-
 /* Find DFU interfaces in a given device.
  * Iterate through all DFU interfaces and their alternate settings
  * and call the passed handler function on each setting until handler
@@ -904,7 +896,7 @@ status_again:
 			fprintf(stderr, "Error obtaining DFU functional "
 				"descriptor\n");
 		} else {
-			transfer_size = get_int16_le(&func_dfu.wTransferSize);
+			transfer_size = libusb_le16_to_cpu(func_dfu.wTransferSize);
 			printf("Device returned transfer size %i\n",
 				transfer_size);
 		}
-- 
1.7.5.4




More information about the devel mailing list