- Do a clean shutdown / exit(0) after printing usage help, instead of continuing execution. This avoids the "ERROR: Allwinner USB FEL device not found!" when doing a plain ./sunxi-fel without any arguments. - Convert C++ style comments for a uniform coding style. - Some small formatting adjustments.
Signed-off-by: Bernhard Nortmann <bernhard.nortm...@web.de> --- fel.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/fel.c b/fel.c index dedde55..616cd05 100644 --- a/fel.c +++ b/fel.c @@ -80,7 +80,7 @@ static void pr_info(const char *fmt, ...) } } -static const int AW_USB_MAX_BULK_SEND = 4 * 1024 * 1024; // 4 MiB per bulk request +static const int AW_USB_MAX_BULK_SEND = 4 * 1024 * 1024; /* 4 MiB per bulk request */ void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, size_t length, bool progress) @@ -105,7 +105,7 @@ void usb_bulk_send(libusb_device_handle *usb, int ep, const void *data, data += sent; if (progress) - progress_update(sent); // notification after each chunk + progress_update(sent); /* notification after each chunk */ } } @@ -317,21 +317,19 @@ void hexdump(void *data, uint32_t offset, size_t size) size_t i; printf("%08lx: ",(long int)offset + j); for (i = 0; i < 16; i++) { - if ((j+i) < size) { + if ((j+i) < size) printf("%02x ", buf[j+i]); - } else { + else printf("__ "); - } } printf(" "); for (i = 0; i < 16; i++) { - if (j+i >= size) { + if (j+i >= size) printf("."); - } else if (isprint(buf[j+i])) { + else if (isprint(buf[j+i])) printf("%c", buf[j+i]); - } else { + else printf("."); - } } printf("\n"); } @@ -380,7 +378,7 @@ void *load_file(const char *name, size_t *size) exit(1); } - while(1) { + while (1) { ssize_t len = bufsize - offset; ssize_t n = fread(buf+offset, 1, len, in); offset += n; @@ -1075,7 +1073,7 @@ void aw_fel_write_and_execute_spl(libusb_device_handle *usb, } /* re-enable the MMU if it was enabled by BROM */ - if(tt != NULL) + if (tt != NULL) aw_restore_and_enable_mmu(usb, sram_info, tt); } @@ -1237,7 +1235,7 @@ static int aw_fel_get_endpoint(libusb_device_handle *usb) const struct libusb_endpoint_descriptor *ep = setting->endpoint + ep_idx; - // Test for bulk transfer endpoint + /* Test for bulk transfer endpoint */ if ((ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) != LIBUSB_TRANSFER_TYPE_BULK) continue; @@ -1272,7 +1270,7 @@ static unsigned int file_upload(libusb_device_handle *handle, size_t count, for (i = 0; i < count; i++) size += file_size(argv[i * 2 + 1]); - progress_start(progress, size); // set total size and progress callback + progress_start(progress, size); /* set total size and progress callback */ /* now transfer each file in turn */ for (i = 0; i < count; i++) { @@ -1281,14 +1279,14 @@ static unsigned int file_upload(libusb_device_handle *handle, size_t count, uint32_t offset = strtoul(argv[i * 2], NULL, 0); aw_write_buffer(handle, buf, offset, size, true); - // If we transferred a script, try to inform U-Boot about its address. + /* If we transferred a script, try to inform U-Boot about its address. */ if (get_image_type(buf, size) == IH_TYPE_SCRIPT) pass_fel_information(handle, offset); } free(buf); } - return i; // return number of files that were processed + return i; /* return number of files that were processed */ } /* open libusb handle to desired FEL device */ @@ -1369,8 +1367,6 @@ int main(int argc, char **argv) libusb_device_handle *handle; int busnum = -1, devnum = -1; int iface_detached = -1; - int rc = libusb_init(NULL); - assert(rc == 0); if (argc <= 1) { printf("Usage: %s [options] command arguments... [command...]\n" @@ -1407,6 +1403,7 @@ int main(int argc, char **argv) " fill address length value Fill memory\n" , argv[0] ); + exit(0); } /* process all "prefix"-type arguments first */ @@ -1434,6 +1431,8 @@ int main(int argc, char **argv) argv += 1; } + int rc = libusb_init(NULL); + assert(rc == 0); handle = open_fel_device(busnum, devnum, AW_USB_VENDOR_ID, AW_USB_PRODUCT_ID); assert(handle != NULL); rc = libusb_claim_interface(handle, 0); @@ -1527,7 +1526,7 @@ int main(int argc, char **argv) argv+=skip; } - // auto-start U-Boot if requested (by the "uboot" command) + /* auto-start U-Boot if requested (by the "uboot" command) */ if (uboot_autostart) { pr_info("Starting U-Boot (0x%08X).\n", uboot_entry); aw_fel_execute(handle, uboot_entry); -- 2.4.10 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.