- 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 uniform coding style.

Signed-off-by: Bernhard Nortmann <bernhard.nortm...@web.de>
---
 fel.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/fel.c b/fel.c
index e7b81a2..8300043 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 
*/
        }
 }
 
@@ -1255,7 +1255,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;
@@ -1290,7 +1290,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++) {
@@ -1299,14 +1299,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 */
@@ -1387,8 +1387,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"
@@ -1427,6 +1425,7 @@ int main(int argc, char **argv)
                        "       fill address length value       Fill memory\n"
                        , argv[0]
                );
+               exit(0);
        }
 
        /* process all "prefix"-type arguments first */
@@ -1454,6 +1453,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);
@@ -1557,7 +1558,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.

Reply via email to