From 6823b290f3a598b235b4bfcfb639399daf03055b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 16 Oct 2019 13:50:02 +0900 Subject: kbuild: remove ar-option Linux commit 13dc8c029cab ("kbuild: remove ar-option and KBUILD_ARFLAGS") removed this already. Barebox has never used this macro. Signed-off-by: Masahiro Yamada Signed-off-by: Sascha Hauer --- scripts/Kbuild.include | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index fe0de87240..919f286162 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -134,11 +134,6 @@ cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) ld-option = $(call try-run,\ $(CC) -x c /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) -# ar-option -# Usage: KBUILD_ARFLAGS := $(call ar-option,D) -# Important: no spaces around options -ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) - ###### ### -- cgit v1.2.3 From 4c8af438c80e9959a3d6f33889af6686b24bfd2b Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Wed, 16 Oct 2019 18:39:57 +0200 Subject: cp: complete command help Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- commands/cp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/cp.c b/commands/cp.c index 54934dd64f..845dae6b15 100644 --- a/commands/cp.c +++ b/commands/cp.c @@ -100,13 +100,14 @@ BAREBOX_CMD_HELP_START(cp) BAREBOX_CMD_HELP_TEXT("Copy file from SRC to DEST.") BAREBOX_CMD_HELP_TEXT("") BAREBOX_CMD_HELP_TEXT("Options:") +BAREBOX_CMD_HELP_OPT ("-r", "recursive") BAREBOX_CMD_HELP_OPT ("-v", "verbose") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(cp) .cmd = do_cp, BAREBOX_CMD_DESC("copy files") - BAREBOX_CMD_OPTS("[-v] SRC DEST") + BAREBOX_CMD_OPTS("[-rv] SRC DEST") BAREBOX_CMD_GROUP(CMD_GRP_FILE) BAREBOX_CMD_HELP(cmd_cp_help) BAREBOX_CMD_END -- cgit v1.2.3 From d4eb2645610625b3b6f5179a319935d3fc7c6829 Mon Sep 17 00:00:00 2001 From: DU HUANPENG Date: Wed, 16 Oct 2019 23:56:44 +0800 Subject: readline: make ctrl-u to work like linux console currtly, the ctrl-u discards the whole line, in most linux boxes, ctrl-u just erase characters before cursor to the begginning of the line. this patch make ctrl-u to do this. Signed-off-by: DU HUANPENG Signed-off-by: Sascha Hauer --- lib/readline.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/readline.c b/lib/readline.c index d026af1104..3d16c1838c 100644 --- a/lib/readline.c +++ b/lib/readline.c @@ -290,9 +290,17 @@ int readline(const char *prompt, char *buf, int len) insert = !insert; break; case BB_KEY_ERASE_LINE: + BEGINNING_OF_LINE(); + ERASE_TO_EOL(); + break; case CTL_CH('u'): + wlen = eol_num - num; + memmove(buf, buf+num, wlen); BEGINNING_OF_LINE(); ERASE_TO_EOL(); + eol_num = wlen; + REFRESH_TO_EOL(); + BEGINNING_OF_LINE(); break; case DEL: case BB_KEY_DEL7: -- cgit v1.2.3 From e4aa9092365213d7ff116e0431e28e4d9368cee2 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Oct 2019 22:04:07 +0200 Subject: edit: replace %c for literal with literal directly There's no need to use %c for ESC, when we can use the appropriate escape sequence directly. Do this and shave off 60~ bytes on my compressed THUMB-2 barebox. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/edit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/commands/edit.c b/commands/edit.c index ba6a8c7cdd..8668a8c065 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -55,7 +55,7 @@ static int scrcol = 0; /* the first column on screen */ static void pos(int x, int y) { - printf("%c[%d;%dH", 27, y + 2, x + 1); + printf("\x1b[%d;%dH", y + 2, x + 1); } static char *screenline(char *line, int *pos) @@ -110,7 +110,7 @@ static void refresh_line(struct line *line, int ypos) char *str = screenline(line->data, NULL) + scrcol; pos(0, ypos); str[screenwidth] = 0; - printf("%s%c[K", str, 27); + printf("%s\x1b[K", str); pos(cursx, cursy); } @@ -130,7 +130,7 @@ static void refresh(int full) if (!full) { if (smartscroll) { if (scrline->next == lastscrline) { - printf("%c[1T", 27); + printf("\x1b[1T"); refresh_line(scrline, 0); pos(0, screenheight); printf("%*s", screenwidth, ""); @@ -138,7 +138,7 @@ static void refresh(int full) } if (scrline->prev == lastscrline) { - printf("%c[1S", 27); + printf("\x1b[1S"); for (i = 0; i < screenheight - 1; i++) { l = l->next; if (!l) @@ -420,13 +420,13 @@ static int do_edit(int argc, char *argv[]) lastscrline = scrline; lastscrcol = 0; - printf("%c[2J", 27); + printf("\x1b[2J"); pos(0, -1); - printf("%c[7m %-25s : Save and quit : quit %c[0m", - 27, argv[1], 27); - printf("%c[2;%dr", 27, screenheight); + printf("\x1b[7m %-25s : Save and quit : quit \x1b[0m", + argv[1]); + printf("\x1b[2;%dr", screenheight); screenheight--; /* status line */ @@ -554,7 +554,7 @@ static int do_edit(int argc, char *argv[]) } out: free_buffer(); - printf("%c[2J%c[r", 27, 27); + printf("\x1b[2J\x1b[r"); printf("\n"); return ret; } -- cgit v1.2.3 From 040e74a8b6cd316f9553b80aa8b1a7f83672bbed Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 14 Oct 2019 22:04:08 +0200 Subject: edit: add vi alias with vi-style bindings The edit command already supports a few key bindings for code navigation. To improve user experience for vi-impaired users, add a vi alias that maps traditional vi key bindings to the barebox edit ones. This is done by adding a mode-aware read_modal_key that maps vi normal-mode keys to barebox edit. For operations that requires more than one barebox edit key, a backlog of two characters is additionally used. In interest of code size reduction, a command mode (and the associated readline overhead) are not implemented, the effect of the most common commands :q and :wq commands can be realized with vim-like ZQ and ZZ bindings instead. This increases the size of my LZO-compressed THUMB2 barebox by 843 bytes. Acked-by: Roland Hieber Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/edit.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 144 insertions(+), 8 deletions(-) diff --git a/commands/edit.c b/commands/edit.c index 8668a8c065..4e661df14f 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -378,8 +378,128 @@ static void getwinsize(void) pos(0, 0); } +static void statusbar(const char *str) +{ + pos(0, screenheight+1); + printf("%*c\r%s", screenwidth, ' ', str); + pos(cursx, cursy); +} + +static int read_modal_key(bool is_modal) +{ + static enum { MODE_INSERT, MODE_NORMAL } mode = MODE_NORMAL; + static int backlog[2] = { -1, -1 }; + int c; + + if (backlog[0] >= 0) { + /* pop a character */ + c = backlog[0]; + backlog[0] = backlog[1]; + backlog[1] = -1; + } else { + c = read_key(); + } + + if (is_modal && mode == MODE_INSERT && (c == -1 || c == CTL_CH('c'))) { + mode = MODE_NORMAL; + statusbar(""); + return -EAGAIN; + } + + if (!is_modal || mode == MODE_INSERT) + return c; + + switch (c) { + case -1: /* invalid escape, e.g. two escapes in a row */ + break; + case 'i': + statusbar("-- INSERT --"); + mode = MODE_INSERT; + break; + case 'h': + return BB_KEY_LEFT; + case 'j': + return BB_KEY_DOWN; + case 'k': + return BB_KEY_UP; + case 'a': + statusbar("-- INSERT --"); + mode = MODE_INSERT; + /* fall through */ + case 'l': + return BB_KEY_RIGHT; + case 'O': + backlog[0] = '\n'; + backlog[1] = BB_KEY_UP; + /* fall through */ + case 'I': + statusbar("-- INSERT --"); + mode = MODE_INSERT; + /* fall through */ + case '^': + case '0': + return BB_KEY_HOME; + case 'g': + c = read_key(); + if (c != 'g') + break; + backlog[0] = CTL_CH('u'); + backlog[1] = CTL_CH('u'); + /* fall through */ + case CTL_CH('u'): + return BB_KEY_PAGEUP; + case 'G': + backlog[0] = CTL_CH('d'); + backlog[1] = CTL_CH('d'); + /* fall through */ + case CTL_CH('d'): + return BB_KEY_PAGEDOWN; + case 'o': + backlog[0] = '\n'; + /* fall through */ + case 'A': + statusbar("-- INSERT --"); + mode = MODE_INSERT; + /* fall through */ + case '$': + return BB_KEY_END; + case CTL_CH('c'): + statusbar("Type ZQ to abandon all changes and exit vi." + "Type ZZ to exit while saving them."); + break; + case 'x': + return BB_KEY_DEL; + case 'X': + return '\b'; + case BB_KEY_PAGEUP: + case BB_KEY_PAGEDOWN: + case BB_KEY_HOME: + case BB_KEY_END: + case BB_KEY_UP: + case BB_KEY_DOWN: + case BB_KEY_RIGHT: + case BB_KEY_LEFT: + return c; + case ':': + statusbar("ERROR: command mode not supported"); + break; + case 'Z': + c = read_key(); + if (c == 'Z') + return CTL_CH('d'); + if (c == 'Q') + return CTL_CH('c'); + default: + statusbar("ERROR: not implemented"); + break; + } + + return -EAGAIN; +} + static int do_edit(int argc, char *argv[]) { + bool is_vi = false; int lastscrcol; int i; int linepos; @@ -401,10 +521,14 @@ static int do_edit(int argc, char *argv[]) else screenheight = 25; - /* check if we are called as "sedit" instead of "edit" */ - if (*argv[0] == 's') { + /* check if we are not called as "edit" */ + if (*argv[0] != 'e') { smartscroll = 1; getwinsize(); + + /* check if we are called as "vi" */ + if (*argv[0] == 'v') + is_vi = true; } buffer = NULL; @@ -424,14 +548,22 @@ static int do_edit(int argc, char *argv[]) pos(0, -1); - printf("\x1b[7m %-25s : Save and quit : quit \x1b[0m", - argv[1]); + if (is_vi) { + screenheight -= 2; + printf("\x1b[7m%*c\x1b[0m", screenwidth , ' '); + pos(0, screenheight-1); + printf("\x1b[7m%*c\x1b[0m", screenwidth , ' '); + printf("\r\x1b[7m%-25s\x1b[0m", argv[1]); + } else { + printf("\x1b[7m %-25s : Save and quit : quit \x1b[0m", + argv[1]); + } + printf("\x1b[2;%dr", screenheight); + pos(0, 0); screenheight--; /* status line */ - pos(0, 0); - refresh(1); while (1) { @@ -469,7 +601,11 @@ static int do_edit(int argc, char *argv[]) lastscrline = scrline; pos(cursx, cursy); - c = read_key(); +again: + c = read_modal_key(is_vi); + if (c == -EAGAIN) + goto again; + switch (c) { case BB_KEY_UP: if (!curline->prev) @@ -559,7 +695,7 @@ out: return ret; } -static const char * const edit_aliases[] = { "sedit", NULL}; +static const char * const edit_aliases[] = { "sedit", "vi", NULL}; BAREBOX_CMD_HELP_START(edit) BAREBOX_CMD_HELP_TEXT("Use cursor keys, Ctrl-C to exit and Ctrl-D to exit-with-save.") -- cgit v1.2.3 From 4d4258d24b82ac4316702d173c1e3aaf3d361c35 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 21 Oct 2019 14:20:46 +0200 Subject: hwrng: dev-random: always use /dev/urandom /dev/random can block long after boot time. It seems there's a consensus that /dev/urandom is safe to use except for very early boot, which isn't when barebox sandbox is usually run. To make the HWRNG more useful, always use /dev/urandom. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/sandbox/board/dev-random.c | 7 +------ arch/sandbox/mach-sandbox/include/mach/linux.h | 1 - drivers/hw_random/Kconfig | 6 +++--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/sandbox/board/dev-random.c b/arch/sandbox/board/dev-random.c index f65e5ef6e5..60295e9fce 100644 --- a/arch/sandbox/board/dev-random.c +++ b/arch/sandbox/board/dev-random.c @@ -4,10 +4,6 @@ devrandom_t *devrandom_init(void) { devrandom_t *fds = xzalloc(sizeof(*fds)); - fds->randomfd = linux_open("/dev/random", false); - if (fds->randomfd < 0) - return ERR_PTR(-EPERM); - fds->urandomfd = linux_open("/dev/urandom", false); if (fds->urandomfd < 0) return ERR_PTR(-EPERM); @@ -17,8 +13,7 @@ devrandom_t *devrandom_init(void) { int devrandom_read(devrandom_t *devrandom, void *buf, size_t len, int wait) { - if (wait) - return linux_read(devrandom->randomfd, buf, len); + (void)wait; /* /dev/urandom won't block */ return linux_read(devrandom->urandomfd, buf, len); } diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 1e64d41c6a..9759a376ec 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -52,7 +52,6 @@ int barebox_libftdi1_update(struct ft2232_bitbang *ftbb); void barebox_libftdi1_close(void); typedef struct { - int randomfd; int urandomfd; } devrandom_t; devrandom_t *devrandom_init(void); diff --git a/drivers/hw_random/Kconfig b/drivers/hw_random/Kconfig index c57928204d..242a7ef278 100644 --- a/drivers/hw_random/Kconfig +++ b/drivers/hw_random/Kconfig @@ -15,11 +15,11 @@ config HWRNG_MXC_RNGC Generator hardware found on some Freescale i.MX processors. config HWRNG_DEV_RANDOM - tristate "Linux /dev/random and /dev/urandom RNG" + tristate "Linux /dev/urandom RNG" depends on SANDBOX default y help - This driver allows use of the host provided /dev/random - and /dev/urandom as barebox HWRNGs. + This driver allows use of the host provided /dev/urandom + as barebox HWRNGs. endif -- cgit v1.2.3 From 24020d5b87c0809ced4164e17c9568af5d743053 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 21 Oct 2019 14:20:47 +0200 Subject: commands: passwd: suggest sandbox for offline password generation Users might want to generate the password while the target is offline. We don't provide a dedicated host tool for that, but barebox sandbox can be used. Document this possibility. While at it, remove a misplaced single quite and slash in the help text. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- commands/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/Kconfig b/commands/Kconfig index 0189b4715b..a6db52ae54 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -1389,8 +1389,10 @@ config CMD_PASSWD help Set password - 'Interactively asks for a password. The digest of this password will be - stored in /env/etc//passwd. This is then used by the 'login' command. + Interactively asks for a password. The digest of this password will be + stored in /env/etc/passwd. This is then used by the 'login' command. + + Passwords can be generated on the host machine using barebox sandbox. Entering an empty string will disable the password function. -- cgit v1.2.3 From 1162764b0c0c966b4c24ecd7597bc6ed08363623 Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Mon, 21 Oct 2019 14:59:08 +0200 Subject: sandbox: add_image: output errno string on mmap failure Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- arch/sandbox/os/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 86118822a1..1b2daa3965 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -264,7 +264,7 @@ static int add_image(char *str, char *devname_template, int *devname_number) PROT_READ | (readonly ? 0 : PROT_WRITE), MAP_SHARED, fd, 0); if ((void *)hf->base == MAP_FAILED) - printf("warning: mmapping %s failed\n", filename); + printf("warning: mmapping %s failed: %s\n", filename, strerror(errno)); ret = barebox_register_filedev(hf); if (ret) -- cgit v1.2.3 From fbc7ee7c5b1d3eba95501d25a4ad799b82e6b94e Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 21 Oct 2019 19:00:43 +0200 Subject: partition: include partuuid string in debug string When debugging partitions detected by barebox, knowing the partuuid can be useful. Include it in the dev_dbg output. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- common/partitions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/partitions.c b/common/partitions.c index 574b31fbbe..4162e86804 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -54,8 +54,8 @@ static int register_one_partition(struct block_device *blk, partition_name = basprintf("%s.%d", blk->cdev.name, no); if (!partition_name) return -ENOMEM; - dev_dbg(blk->dev, "Registering partition %s on drive %s\n", - partition_name, blk->cdev.name); + dev_dbg(blk->dev, "Registering partition %s on drive %s (partuuid=%s)\n", + partition_name, blk->cdev.name, part->partuuid); cdev = devfs_add_partition(blk->cdev.name, start, size, 0, partition_name); if (IS_ERR(cdev)) { -- cgit v1.2.3 From 4a2e799263de5acabc1881e5330cf87b1aee7451 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 21 Oct 2019 19:00:44 +0200 Subject: fs: devfs-core: do a case-insensitive compare of partuuids partuuids are represented as hexadecimal strings, where case doesn't matter. barebox formats them as lower case internally, forcing the partuuid device tree property to be lower case too. Use strcasecmp to be case-insensitive. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- fs/devfs-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 258bb2dbaa..5341e39e67 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -104,7 +104,7 @@ struct cdev *cdev_by_partuuid(const char *partuuid) return NULL; list_for_each_entry(cdev, &cdev_list, list) { - if (!strcmp(cdev->partuuid, partuuid)) + if (!strcasecmp(cdev->partuuid, partuuid)) return cdev; } return NULL; -- cgit v1.2.3 From 6ee9b4a05f2264b733760eaa84b0ec4bdb8c7cb4 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Tue, 22 Oct 2019 11:15:38 +0200 Subject: common: state: improve kconfig help text Cc: Juergen Borleis Signed-off-by: Roland Hieber Signed-off-by: Sascha Hauer --- common/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index b840242ac9..d397d8bc4d 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -959,11 +959,11 @@ config STATE_CRYPTO for more information. config STATE_BACKWARD_COMPATIBLE - bool "backward compatible 'direct storage backend'" + bool "backward compatible 'direct' storage backend" depends on STATE help - With this option enabled the 'direct' storage backend keeps backward - compatibility with older revisions of the state framework. Newer + With this option enabled, the 'direct' storage backend keeps backward + compatibility with the state framework of barebox <= v2016.08.0. Newer revisions expect an additional 'meta header' and fail otherwise. config BOOTCHOOSER -- cgit v1.2.3 From d8dee49cacb914a14c7a7b55d61c16b1fabde50c Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Tue, 22 Oct 2019 15:47:32 +0200 Subject: libfile: copy_file: fix error handling Before this, ret was falsely polluted, which caused a misleading error message if the function bailed out at a later point. Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- lib/libfile.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/libfile.c b/lib/libfile.c index 02078dd43d..5a1817e32a 100644 --- a/lib/libfile.c +++ b/lib/libfile.c @@ -332,7 +332,7 @@ int copy_file(const char *src, const char *dst, int verbose) { char *rw_buf = NULL; int srcfd = 0, dstfd = 0; - int r; + int r, s; int ret = 1, err1 = 0; int mode; int total = 0; @@ -343,22 +343,27 @@ int copy_file(const char *src, const char *dst, int verbose) srcfd = open(src, O_RDONLY); if (srcfd < 0) { printf("could not open %s: %s\n", src, errno_str()); + ret = srcfd; goto out; } mode = O_WRONLY | O_CREAT; - ret = stat(dst, &dststat); - if (ret && ret != -ENOENT) + s = stat(dst, &dststat); + if (s && s != -ENOENT) { + printf("could not stat %s: %s\n", dst, errno_str()); + ret = s; goto out; + } /* Set O_TRUNC only if file exist and is a regular file */ - if (!ret && S_ISREG(dststat.st_mode)) + if (!s && S_ISREG(dststat.st_mode)) mode |= O_TRUNC; dstfd = open(dst, mode); if (dstfd < 0) { printf("could not open %s: %s\n", dst, errno_str()); + ret = dstfd; goto out; } @@ -373,12 +378,14 @@ int copy_file(const char *src, const char *dst, int verbose) r = read(srcfd, rw_buf, RW_BUF_SIZE); if (r < 0) { perror("read"); + ret = r; goto out; } if (!r) break; - if (write_full(dstfd, rw_buf, r) < 0) { + ret = write_full(dstfd, rw_buf, r); + if (ret < 0) { perror("write"); goto out; } -- cgit v1.2.3 From ea7fa7c272320344b653e0d90a8b3d666e561493 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 28 Oct 2019 11:12:57 +0100 Subject: mfd: superio: use strerrorp helper instead of open-coding Apparently, we have a helper for strerror(-PTR_ERR(regmap)). Use it. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- drivers/mfd/superio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/superio.c b/drivers/mfd/superio.c index 0f08d56cb3..12d74b40f6 100644 --- a/drivers/mfd/superio.c +++ b/drivers/mfd/superio.c @@ -88,7 +88,7 @@ void superio_chip_add(struct superio_chip *siochip) &superio_regmap_config); if (IS_ERR(regmap)) pr_warn("creating %s regmap failed: %s\n", - chipname, strerror(-PTR_ERR(regmap))); + chipname, strerrorp(regmap)); ret = regmap_register_cdev(regmap, chipname); if (ret) -- cgit v1.2.3 From 8d6da6462b12a5e7cc84253ada8f91cd4561dc5e Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Fri, 25 Oct 2019 13:19:12 +0200 Subject: sandbox: add_image: mmap block devices This makes it possible to mount block devices from the host machine, which have been passed as arguments to --image Signed-off-by: Robert Karszniewicz Signed-off-by: Sascha Hauer --- arch/sandbox/os/common.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c index 1b2daa3965..3ad12b4a30 100644 --- a/arch/sandbox/os/common.c +++ b/arch/sandbox/os/common.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include /* * ...except the ones needed to connect with barebox */ @@ -260,6 +262,12 @@ static int add_image(char *str, char *devname_template, int *devname_number) hf->size = s.st_size; hf->devname = strdup(devname); + if (S_ISBLK(s.st_mode)) { + if (ioctl(fd, BLKGETSIZE64, &hf->size) == -1) { + perror("ioctl"); + goto err_out; + } + } hf->base = (unsigned long)mmap(NULL, hf->size, PROT_READ | (readonly ? 0 : PROT_WRITE), MAP_SHARED, fd, 0); -- cgit v1.2.3 From 660041ba309268c3f5404da4ae1b7eba201f4c4c Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 30 Oct 2019 10:48:34 +0100 Subject: OF: gpio: don't warn if ignored GPIO flag matches the behavior Port of the upstream accepted change to the Linux kernel. Some devicetrees specify the ACTIVE_LOW flag in the fixed regulator GPIO handle. While this has always been ignored, it's consistent with the behavior of the regulator binding in the absence of the "enable-active-high" DT property. It doesn't make much sense to print a user visible warning for a configuration which is consistent, so only print the warning if the GPIO flag contradicts the behavior dictated by by the enable-active-high property. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- drivers/of/of_gpio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_gpio.c b/drivers/of/of_gpio.c index 9a8331ed18..7cbeeaf69e 100644 --- a/drivers/of/of_gpio.c +++ b/drivers/of/of_gpio.c @@ -19,18 +19,20 @@ static void of_gpio_flags_quirks(struct device_node *np, (!(strcmp(propname, "enable-gpio") && strcmp(propname, "enable-gpios")) && of_device_is_compatible(np, "regulator-gpio")))) { + bool active_low = !of_property_read_bool(np, + "enable-active-high"); /* * The regulator GPIO handles are specified such that the * presence or absence of "enable-active-high" solely controls * the polarity of the GPIO line. Any phandle flags must * be actively ignored. */ - if (*flags & OF_GPIO_ACTIVE_LOW) { + if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) { pr_warn("%s GPIO handle specifies active low - ignored\n", np->full_name); *flags &= ~OF_GPIO_ACTIVE_LOW; } - if (!of_property_read_bool(np, "enable-active-high")) + if (active_low) *flags |= OF_GPIO_ACTIVE_LOW; } } -- cgit v1.2.3 From 5c06691a321c9f0d9e143c52b143366d0428391b Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 30 Oct 2019 12:11:49 +0100 Subject: fs: ubootvarfs: use correct format specifier for pointer diff The difference between two pointers is represented as a ptrdiff_t, use the correct format specifier when printing to get rid of the following warning in a 64bit build: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long int' [-Wformat=] Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- fs/ubootvarfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ubootvarfs.c b/fs/ubootvarfs.c index 81ec05d5ef..475e4b7a79 100644 --- a/fs/ubootvarfs.c +++ b/fs/ubootvarfs.c @@ -409,7 +409,7 @@ static void ubootvarfs_parse(struct ubootvarfs_data *data, char *blob, list_add_tail(&var->list, &data->var_list); } else { - pr_err("No separator in data @ 0x%08x. Skipped.", + pr_err("No separator in data @ 0x%08tx. Skipped.", blob - start); free(var); } -- cgit v1.2.3 From 3b81d1199347b2fd250d72bb4df39e15f975b6ed Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Wed, 30 Oct 2019 18:03:39 +0100 Subject: parameter: strip leading and trailing whitespaces My initial bug was the following: I set the global.boot.default="boot1 boot2 " and executed the 'boot' command. If both targets are not bootable barebox starts to execute the boot scripts found under /env/boot. This is because of the command/boot.c implementation and the leading whitespace. Without the whitespace only the two desired boot targets are tried. IMHO leading and trailing whitespaces are error-prone in many cases. If someone wants to concatenate strings he/she should add spaces on purpose. So I fixed the bug above globally by always stripping leading and trailing whitespaces. Signed-off-by: Marco Felsch Signed-off-by: Sascha Hauer --- lib/parameter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/parameter.c b/lib/parameter.c index 00e9a9ff4e..fdbb2e71d1 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -253,11 +253,14 @@ static int param_string_set(struct device_d *dev, struct param_d *p, const char struct param_string *ps = to_param_string(p); int ret; char *value_save = *ps->value; + char *value_new; if (!val) val = ""; - *ps->value = xstrdup(val); + value_new = xstrdup(val); + value_new = strim(value_new); + *ps->value = value_new; if (!ps->set) return 0; -- cgit v1.2.3 From cd6b02211852fa753b6a527af227aafd9d5088d4 Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Wed, 30 Oct 2019 18:04:55 +0100 Subject: of: of_path: fix return in case of EPROBE_DEFER As said in commit 82eb3dff10 ("of_path: handle no driver for device") this case happens if the driver isn't probed yet. So we should return -EPROBE_DEFER to signal that. Signed-off-by: Marco Felsch Signed-off-by: Sascha Hauer --- drivers/of/of_path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c index f8bbf2cba1..5c3a020345 100644 --- a/drivers/of/of_path.c +++ b/drivers/of/of_path.c @@ -83,7 +83,7 @@ static int __of_find_path(struct device_node *node, const char *part, char **out } if (dev->bus && !dev->driver) - return -ENODEV; + return -EPROBE_DEFER; device_detect(dev); -- cgit v1.2.3 From 31227a94238830a16767d207e0668015d297e9fa Mon Sep 17 00:00:00 2001 From: Robert Karszniewicz Date: Fri, 25 Oct 2019 17:56:08 +0200 Subject: usb: storage: Increase retries for usb_stor_transport() This should make writing and reading more reliable. Also: - change loop condition to make "retries" semantically correct - add a debug message in case of fatal failure Signed-off-by: Sascha Hauer --- drivers/usb/storage/usb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 63d624e91b..e0ef4f5ef3 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -87,8 +87,7 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev, struct device_d *dev = &us->pusb_dev->dev; int i, ret; - - for (i = 0; i < retries; i++) { + for (i = 0; i <= retries; i++) { dev_dbg(dev, "%s\n", usb_stor_opcode_name(cmd[0])); ret = us->transport(usb_blkdev, cmd, cmdlen, data, datalen); dev_dbg(dev, "%s returns %d\n", usb_stor_opcode_name(cmd[0]), @@ -105,6 +104,8 @@ static int usb_stor_transport(struct us_blk_dev *usb_blkdev, mdelay(request_sense_delay_ms); } + dev_dbg(dev, "Retried %s %d times, and failed.\n", usb_stor_opcode_name(cmd[0]), retries); + return -EIO; } @@ -194,7 +195,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode, put_unaligned_be16(blocks, &cmd[7]); return usb_stor_transport(usb_blkdev, cmd, sizeof(cmd), data, - blocks * SECTOR_SIZE, 2, 0); + blocks * SECTOR_SIZE, 10, 0); } /*********************************************************************** -- cgit v1.2.3 From 361ecbfff18fe2051b69dbbfa6efe6a2d054863f Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 4 Nov 2019 18:04:18 +0100 Subject: param: drop unused parameters in helpers These parameters aren't currently used anywhere, but are still useful to have nonetheless. Keep them but drop the unused parameters. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- include/param.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/param.h b/include/param.h index dea6990497..4ac502e726 100644 --- a/include/param.h +++ b/include/param.h @@ -264,8 +264,6 @@ static inline struct param_d *dev_add_param_bool_ro(struct device_d *dev, const } static inline struct param_d *dev_add_param_string_ro(struct device_d *dev, const char *name, - int (*set)(struct param_d *p, void *priv), - int (*get)(struct param_d *p, void *priv), char **value, void *priv) { return dev_add_param_string(dev, name, param_set_readonly, NULL, value, NULL); @@ -285,9 +283,7 @@ static inline struct param_d *dev_add_param_enum_ro(struct device_d *dev, const } static inline struct param_d *dev_add_param_bitmask_ro(struct device_d *dev, const char *name, - int (*set)(struct param_d *p, void *priv), - int (*get)(struct param_d *p, void *priv), - unsigned long *value, const char * const *names, int max, void *priv) + unsigned long *value, const char * const *names, int max) { return dev_add_param_bitmask(dev, name, param_set_readonly, NULL, value, names, max, NULL); -- cgit v1.2.3