diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/crc.c | 4 | ||||
-rw-r--r-- | commands/firmwareload.c | 4 | ||||
-rw-r--r-- | commands/loadb.c | 13 | ||||
-rw-r--r-- | commands/loadxy.c | 13 | ||||
-rw-r--r-- | commands/memcpy.c | 20 | ||||
-rw-r--r-- | commands/of_display_timings.c | 8 | ||||
-rw-r--r-- | commands/of_dump.c | 6 | ||||
-rw-r--r-- | commands/of_fixup_status.c | 2 | ||||
-rw-r--r-- | commands/oftree.c | 4 |
9 files changed, 23 insertions, 51 deletions
diff --git a/commands/crc.c b/commands/crc.c index edb1fb125c..580521d677 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -138,8 +138,8 @@ BAREBOX_CMD_HELP_OPT ("-F FILE", "Use file to compare.") #endif BAREBOX_CMD_HELP_OPT ("-v CRC", "Verify") BAREBOX_CMD_HELP_OPT ("-V FILE", "Verify with CRC read from FILE") -BAREBOX_CMD_HELP_OPT ("-r <var>", "Set <var> to the checksum result\n") -BAREBOX_CMD_HELP_OPT ("-s <var>", "Set <var> to the data size\n") +BAREBOX_CMD_HELP_OPT ("-r <var>", "Set <var> to the checksum result") +BAREBOX_CMD_HELP_OPT ("-s <var>", "Set <var> to the data size") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(crc32) diff --git a/commands/firmwareload.c b/commands/firmwareload.c index 071f25be99..dbd43e046d 100644 --- a/commands/firmwareload.c +++ b/commands/firmwareload.c @@ -55,8 +55,8 @@ static int do_firmwareload(int argc, char *argv[]) BAREBOX_CMD_HELP_START(firmwareload) BAREBOX_CMD_HELP_TEXT("Options:") -BAREBOX_CMD_HELP_OPT("-t <target>", "define the firmware handler by name\n") -BAREBOX_CMD_HELP_OPT("-l\t", "list devices capable of firmware loading\n") +BAREBOX_CMD_HELP_OPT("-t <target>", "define the firmware handler by name") +BAREBOX_CMD_HELP_OPT("-l\t", "list devices capable of firmware loading") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(firmwareload) diff --git a/commands/loadb.c b/commands/loadb.c index 8c3906ca42..37c272f6c7 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -33,6 +33,7 @@ #include <command.h> #include <console.h> #include <errno.h> +#include <libfile.h> #include <environment.h> #include <cache.h> #include <getopt.h> @@ -661,21 +662,11 @@ static int do_load_serial_bin(int argc, char *argv[]) output_file = DEF_FILE; /* File should exist */ - ofd = open(output_file, O_WRONLY | O_CREAT); + ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset); if (ofd < 0) { perror(argv[0]); return 3; } - /* Seek to the right offset */ - if (offset) { - int seek = lseek(ofd, offset, SEEK_SET); - if (seek != offset) { - close(ofd); - ofd = 0; - perror(argv[0]); - return 4; - } - } printf("## Ready for binary (kermit) download " "to 0x%08lX offset on %s device at %d bps...\n", offset, diff --git a/commands/loadxy.c b/commands/loadxy.c index 2bfe482fc5..85efad67c7 100644 --- a/commands/loadxy.c +++ b/commands/loadxy.c @@ -37,6 +37,7 @@ #include <fcntl.h> #include <fs.h> #include <malloc.h> +#include <libfile.h> #define DEF_FILE "image.bin" @@ -176,21 +177,11 @@ static int do_loadx(int argc, char *argv[]) output_file = DEF_FILE; /* File should exist */ - ofd = open(output_file, O_WRONLY | O_CREAT); + ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset); if (ofd < 0) { perror(argv[0]); return 3; } - /* Seek to the right offset */ - if (offset) { - int seek = lseek(ofd, offset, SEEK_SET); - if (seek != offset) { - close(ofd); - ofd = 0; - perror(argv[0]); - return 4; - } - } current_baudrate = console_get_baudrate(cdev); diff --git a/commands/memcpy.c b/commands/memcpy.c index ddaf767eac..ef25fb7b23 100644 --- a/commands/memcpy.c +++ b/commands/memcpy.c @@ -84,9 +84,9 @@ static int do_memcpy(int argc, char *argv[]) buf = xmalloc(RW_BUF_SIZE); while (count > 0) { - int now, r, w, tmp; + int now, r; - now = min((loff_t)RW_BUF_SIZE, count); + now = min_t(loff_t, RW_BUF_SIZE, count); r = read(sourcefd, buf, now); if (r < 0) { @@ -97,19 +97,9 @@ static int do_memcpy(int argc, char *argv[]) if (!r) break; - tmp = 0; - now = r; - while (now) { - w = write(destfd, buf + tmp, now); - if (w < 0) { - perror("write"); - goto out; - } - if (!w) - break; - - now -= w; - tmp += w; + if (write_full(destfd, buf, r) < 0) { + perror("write"); + goto out; } count -= r; diff --git a/commands/of_display_timings.c b/commands/of_display_timings.c index ccf2db0da5..365ff80c36 100644 --- a/commands/of_display_timings.c +++ b/commands/of_display_timings.c @@ -148,10 +148,10 @@ static int do_of_display_timings(int argc, char *argv[]) BAREBOX_CMD_HELP_START(of_display_timings) BAREBOX_CMD_HELP_TEXT("Options:") -BAREBOX_CMD_HELP_OPT("-l", "list path of all available display-timings\n") -BAREBOX_CMD_HELP_OPT("-s", "list path of all selected display-timings\n") -BAREBOX_CMD_HELP_OPT("-S path", "select display-timings and register oftree fixup\n") -BAREBOX_CMD_HELP_OPT("-f dtb", "work on dtb. Has no effect on -s option\n") +BAREBOX_CMD_HELP_OPT("-l", "list path of all available display-timings") +BAREBOX_CMD_HELP_OPT("-s", "list path of all selected display-timings") +BAREBOX_CMD_HELP_OPT("-S path", "select display-timings and register oftree fixup") +BAREBOX_CMD_HELP_OPT("-f dtb", "work on dtb. Has no effect on -s option") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_display_timings) diff --git a/commands/of_dump.c b/commands/of_dump.c index 7bec0b925e..06b8e9fcda 100644 --- a/commands/of_dump.c +++ b/commands/of_dump.c @@ -139,9 +139,9 @@ out: BAREBOX_CMD_HELP_START(of_dump) BAREBOX_CMD_HELP_TEXT("Options:") -BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree\n") -BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree\n") -BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties\n") +BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree") +BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree") +BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_dump) diff --git a/commands/of_fixup_status.c b/commands/of_fixup_status.c index 9a4a619195..e0da429ac3 100644 --- a/commands/of_fixup_status.c +++ b/commands/of_fixup_status.c @@ -59,7 +59,7 @@ static int do_of_fixup_status(int argc, char *argv[]) BAREBOX_CMD_HELP_START(of_fixup_status) BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT("-d", "disable node") -BAREBOX_CMD_HELP_OPT("path", "Node path\n") +BAREBOX_CMD_HELP_OPT("path", "Node path") BAREBOX_CMD_HELP_TEXT("Register a fixup to enable or disable a device tree node.") BAREBOX_CMD_HELP_TEXT("Nodes are enabled on default. Disabled with -d.") BAREBOX_CMD_HELP_END diff --git a/commands/oftree.c b/commands/oftree.c index 26a47bb581..299c2edfcd 100644 --- a/commands/oftree.c +++ b/commands/oftree.c @@ -123,8 +123,8 @@ out: BAREBOX_CMD_HELP_START(oftree) BAREBOX_CMD_HELP_TEXT("Options:") -BAREBOX_CMD_HELP_OPT ("-l <DTB>", "Load <DTB> to internal devicetree\n") -BAREBOX_CMD_HELP_OPT ("-s <DTB>", "save internal devicetree to <DTB>\n") +BAREBOX_CMD_HELP_OPT ("-l <DTB>", "Load <DTB> to internal devicetree") +BAREBOX_CMD_HELP_OPT ("-s <DTB>", "save internal devicetree to <DTB>") BAREBOX_CMD_HELP_OPT ("-p", "probe devices from stored device tree") BAREBOX_CMD_HELP_END |