Skip to content

Commit f60f2bd

Browse files
quic-bjorandeandersson
authored andcommitted
qdl: Refactor main()
Rather than mixing subcommands and the default "flash" operation, split the flashing mechanism out into its own subcommand function to clean up the main function. Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
1 parent 156d967 commit f60f2bd

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

qdl.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static int qdl_ramdump(int argc, char **argv)
541541
return ret;
542542
}
543543

544-
int main(int argc, char **argv)
544+
static int qdl_flash(int argc, char **argv)
545545
{
546546
enum qdl_storage_type storage_type = QDL_STORAGE_UFS;
547547
struct sahara_image sahara_images[MAPPING_SZ] = {};
@@ -578,11 +578,6 @@ int main(int argc, char **argv)
578578
{0, 0, 0, 0}
579579
};
580580

581-
if (argc == 2 && !strcmp(argv[1], "list"))
582-
return qdl_list(stdout);
583-
if (argc >= 2 && !strcmp(argv[1], "ramdump"))
584-
return qdl_ramdump(argc - 1, argv + 1);
585-
586581
while ((opt = getopt_long(argc, argv, "dvi:lu:S:D:s:fcnt:T:h", options, NULL)) != -1) {
587582
switch (opt) {
588583
case 'd':
@@ -762,3 +757,13 @@ int main(int argc, char **argv)
762757

763758
return !!ret;
764759
}
760+
761+
int main(int argc, char **argv)
762+
{
763+
if (argc == 2 && !strcmp(argv[1], "list"))
764+
return qdl_list(stdout);
765+
if (argc >= 2 && !strcmp(argv[1], "ramdump"))
766+
return qdl_ramdump(argc - 1, argv + 1);
767+
768+
return qdl_flash(argc, argv);
769+
}

0 commit comments

Comments
 (0)