summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/boards/efi.rst6
-rw-r--r--Documentation/boards/imx/zii-imx7d-dev/openocd.cfg6
-rw-r--r--Documentation/conf.py4
-rw-r--r--arch/arm/boards/zii-vf610-dev/defaultenv-zii-vf610-dev/nv/autoboot_abort_key1
-rw-r--r--arch/arm/dts/vf610-zii-cfu1.dts8
-rw-r--r--arch/arm/mach-imx/imx-bbu-internal.c10
-rw-r--r--arch/mips/lib/bootm.c2
-rw-r--r--commands/edit.c10
-rw-r--r--commands/mmc_extcsd.c11
-rw-r--r--common/complete.c2
-rw-r--r--common/console.c22
-rw-r--r--common/elf.c45
-rw-r--r--common/ratp/mw.c2
-rw-r--r--common/ratp/ratp.c12
-rw-r--r--common/startup.c6
-rw-r--r--drivers/i2c/muxes/i2c-mux-pca954x.c13
-rw-r--r--drivers/input/Kconfig6
-rw-r--r--drivers/input/Makefile1
-rw-r--r--drivers/input/specialkeys.c36
-rw-r--r--drivers/mfd/rave-sp.c18
-rw-r--r--drivers/net/phy/mv88e6xxx/chip.c1
-rw-r--r--drivers/net/smc911x.c2
-rw-r--r--drivers/nvme/host/core.c4
-rw-r--r--drivers/serial/efi-stdio.c5
-rw-r--r--drivers/serial/serial_efi.c5
-rw-r--r--drivers/usb/gadget/fsl_udc.c9
-rw-r--r--drivers/video/stm.c4
-rw-r--r--fs/fat/ff.c2
-rw-r--r--fs/omap4_usbbootfs.c41
-rw-r--r--fs/pstore/platform.c29
-rw-r--r--include/ata_drive.h4
-rw-r--r--include/console.h2
-rw-r--r--include/elf.h29
-rw-r--r--include/gpio.h18
-rw-r--r--include/linux/mfd/rave-sp.h1
-rw-r--r--include/mci.h1
-rw-r--r--include/param.h2
-rw-r--r--lib/gui/png_lode.c13
-rw-r--r--lib/libfile.c9
39 files changed, 257 insertions, 145 deletions
diff --git a/Documentation/boards/efi.rst b/Documentation/boards/efi.rst
index 3da2daac99..2178c9ab42 100644
--- a/Documentation/boards/efi.rst
+++ b/Documentation/boards/efi.rst
@@ -43,7 +43,7 @@ name it ``BOOTx64.EFI`` on 64bit architectures and ``BOOTIA32.EFI`` on 32bit
architectures. Switching to USB boot in the BIOS should then be enough to
start barebox via USB. Some BIOSes allow to specify a path to a binary to
be executed, others have a "start UEFI shell" entry which executes
-EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary aswell.
+EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary as well.
To use the :ref:`state_framework`, the describing devicetree file ``state.dtb``
has to be put into the ``EFI/barebox/`` directory.
Supported backends for EFI are raw partitions that can be discovered via a
@@ -200,7 +200,7 @@ EFI device paths
In EFI each device can be pointed to using a device path. Device paths have multiple
components. The toplevel component on X86 systems will be the PCI root complex, on
-other systems this can be the physical memory space. Each component will now descrive
+other systems this can be the physical memory space. Each component will now describe
how to find the child component on the parent bus. Additional device path nodes can
describe network addresses or filenames on partitions. Device paths have a binary
representation and a clearly defined string representation. These characteristics make
@@ -274,7 +274,7 @@ Network Protocol GUID:
EFI_GUID( 0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D )
Matching between EFI devices and drivers is done based on the Protocol GUIDs, so
-whenever a driver GUID matches one of the GUIDs a device imeplements the drivers
+whenever a driver GUID matches one of the GUIDs a device implements the drivers
probe function is called.
.. _efi_building_edk2:
diff --git a/Documentation/boards/imx/zii-imx7d-dev/openocd.cfg b/Documentation/boards/imx/zii-imx7d-dev/openocd.cfg
index f971c3fb21..6056b89578 100644
--- a/Documentation/boards/imx/zii-imx7d-dev/openocd.cfg
+++ b/Documentation/boards/imx/zii-imx7d-dev/openocd.cfg
@@ -138,6 +138,12 @@ proc start_barebox { } {
resume $MX7_DDR_BASE_ADDR
}
+# disable internal reset-assert handling to
+# allow reset-init to work
+$_TARGETNAME.0 configure -event reset-assert ""
+$_TARGETNAME.1 configure -event reset-assert ""
+$_TARGETNAME_2 configure -event reset-assert ""
+
# hook the init function into the reset-init event
${_TARGETNAME}.0 configure -event reset-init { board_init }
diff --git a/Documentation/conf.py b/Documentation/conf.py
index ec6ec0470b..bcd8633c91 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -53,9 +53,9 @@ copyright = u'2014, The barebox project'
# The short X.Y version.
import os
-version = os.environ["KERNELVERSION"]
+version = os.environ.get("KERNELVERSION", 'unknown version')
# The full version, including alpha/beta/rc tags.
-release = os.environ["KERNELRELEASE"]
+release = os.environ.get("KERNELRELEASE", 'unknown release')
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/arch/arm/boards/zii-vf610-dev/defaultenv-zii-vf610-dev/nv/autoboot_abort_key b/arch/arm/boards/zii-vf610-dev/defaultenv-zii-vf610-dev/nv/autoboot_abort_key
new file mode 100644
index 0000000000..55920c9a58
--- /dev/null
+++ b/arch/arm/boards/zii-vf610-dev/defaultenv-zii-vf610-dev/nv/autoboot_abort_key
@@ -0,0 +1 @@
+ctrl-c \ No newline at end of file
diff --git a/arch/arm/dts/vf610-zii-cfu1.dts b/arch/arm/dts/vf610-zii-cfu1.dts
index 0f1ee140e1..70cd9d1ba9 100644
--- a/arch/arm/dts/vf610-zii-cfu1.dts
+++ b/arch/arm/dts/vf610-zii-cfu1.dts
@@ -11,10 +11,10 @@
/ {
aliases {
/*
- * NVMEM device corresponding to EEPROM attached to
- * the switch shared DT node with it, so we use that
- * fact to create a desirable naming
- */
+ * NVMEM device corresponding to EEPROM attached to
+ * the switch shared DT node with it, so we use that
+ * fact to create a desirable naming
+ */
switch-eeprom = &switch0;
fiber-eeprom0 = &fiber_eeprom0;
};
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index a563b3bc29..946a3e9a77 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -87,6 +87,7 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
const void *buf, int image_len)
{
int fd, ret, offset = 0;
+ struct stat st;
fd = open(devicefile, O_RDWR | O_CREAT);
if (fd < 0)
@@ -101,6 +102,15 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler,
if (imx_handler->handler.flags & IMX_BBU_FLAG_KEEP_HEAD)
offset += imx_handler->flash_header_offset;
+ ret = fstat(fd, &st);
+ if (ret)
+ goto err_close;
+
+ if (image_len > st.st_size) {
+ ret = -ENOSPC;
+ goto err_close;
+ }
+
ret = imx_bbu_protect(fd, imx_handler, devicefile, offset,
image_len, 0);
if (ret)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index f14540a4c4..5bb09cc2de 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -72,7 +72,7 @@ static int do_bootm_elf(struct image_data *data)
shutdown_barebox();
- entry = (void *)elf->entry;
+ entry = (void *) (unsigned long) elf->entry;
entry(-2, phys_to_virt((unsigned long)fdt));
diff --git a/commands/edit.c b/commands/edit.c
index 290222ce15..ba6a8c7cdd 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -524,12 +524,12 @@ static int do_edit(int argc, char *argv[])
} else
delete_char(textx);
break;
- case 13:
- case 10:
+ case '\r':
+ case '\n':
split_line();
break;
case 127:
- case 8:
+ case '\b':
if (textx > 0) {
textx--;
delete_char(textx);
@@ -542,10 +542,10 @@ static int do_edit(int argc, char *argv[])
merge_line(curline);
}
break;
- case 4:
+ case CTL_CH('d'):
ret = save_file(argv[1]);
goto out;
- case 3:
+ case CTL_CH('c'):
goto out;
default:
if ((signed char)c != -1)
diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c
index c27bb722ea..ad8e9ad19f 100644
--- a/commands/mmc_extcsd.c
+++ b/commands/mmc_extcsd.c
@@ -222,8 +222,8 @@ static struct extcsd_reg extcsd[] = {
.access = ACC_R,
.width = 2,
},
- [EXT_CSD_EXCEPTION_EVENTS_STATUS] = {
- .name = "EXT_CSD_EXCEPTION_EVENTS_STATUS",
+ [EXT_CSD_EXCEPTION_DYNCAP_NEEDED] = {
+ .name = "EXT_CSD_EXCEPTION_DYNCAP_NEEDED",
.access = ACC_R,
.width = 1,
},
@@ -1833,6 +1833,13 @@ static int print_field(u8 *reg, int index)
printf("\t[4] EXTENDED_SECURITY_FAILURE: %i\n", val);
return 1;
+ case EXT_CSD_EXCEPTION_DYNCAP_NEEDED:
+ if (get_field_val(EXT_CSD_EXCEPTION_EVENTS_STATUS, 2, 0x1)) {
+ val = get_field_val(EXT_CSD_EXCEPTION_DYNCAP_NEEDED, 0, 0x1);
+ printf("\t[0] DYNCAP_NEEDED: %i\n", val);
+ }
+ return 1;
+
case EXT_CSD_EXCEPTION_EVENTS_CTRL:
val = get_field_val(EXT_CSD_EXCEPTION_EVENTS_CTRL, 1, 0x1);
printf("\t[1] DYNCAP_EVENT_EN: %i\n", val);
diff --git a/common/complete.c b/common/complete.c
index 2dab7d1dde..919e5abc6a 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -277,7 +277,6 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
struct device_d *dev;
struct variable_d *var;
struct env_context *c;
- char *instr_param;
int len;
char end = '=', *pos, *dot;
char *begin = "";
@@ -317,7 +316,6 @@ static int env_param_complete(struct string_list *sl, char *instr, int eval)
devname = xstrndup(instr, dot - instr);
- instr_param++;
dev = get_device_by_name(devname);
free(devname);
diff --git a/common/console.c b/common/console.c
index ee17a508ba..d04aae58f9 100644
--- a/common/console.c
+++ b/common/console.c
@@ -253,20 +253,19 @@ static void console_set_stdoutpath(struct console_device *cdev)
free(str);
}
-static int __console_puts(struct console_device *cdev, const char *s)
+static int __console_puts(struct console_device *cdev, const char *s,
+ size_t nbytes)
{
- int n = 0;
+ size_t i;
- while (*s) {
- if (*s == '\n') {
+ for (i = 0; i < nbytes; i++) {
+ if (*s == '\n')
cdev->putc(cdev, '\r');
- n++;
- }
+
cdev->putc(cdev, *s);
- n++;
s++;
}
- return n;
+ return i;
}
static int fops_open(struct cdev *cdev, unsigned long flags)
@@ -298,7 +297,7 @@ static ssize_t fops_write(struct cdev* dev, const void* buf, size_t count,
{
struct console_device *priv = dev->priv;
- priv->puts(priv, buf);
+ priv->puts(priv, buf, count);
return count;
}
@@ -324,6 +323,9 @@ int console_register(struct console_device *newcdev)
dev->parent = newcdev->dev;
platform_device_register(dev);
+ if (!newcdev->devname)
+ newcdev->devname = xstrdup(dev_name(dev));
+
newcdev->open_count = 0;
/*
@@ -545,7 +547,7 @@ int console_puts(unsigned int ch, const char *str)
if (initialized == CONSOLE_INIT_FULL) {
for_each_console(cdev) {
if (cdev->f_active & ch) {
- n = cdev->puts(cdev, str);
+ n = cdev->puts(cdev, str, strlen(str));
}
}
return n;
diff --git a/common/elf.c b/common/elf.c
index 8edf388564..4733accb05 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -45,29 +45,31 @@ static void elf_release_regions(struct elf_image *elf)
static int load_elf_phdr_segment(struct elf_image *elf, void *src,
- Elf32_Phdr *phdr)
+ void *phdr)
{
- void *dst = (void *)phdr->p_paddr;
+ void *dst = (void *) elf_phdr_p_paddr(elf, phdr);
int ret;
+ u64 p_filesz = elf_phdr_p_filesz(elf, phdr);
+ u64 p_memsz = elf_phdr_p_memsz(elf, phdr);
/* we care only about PT_LOAD segments */
- if (phdr->p_type != PT_LOAD)
+ if (elf_phdr_p_type(elf, phdr) != PT_LOAD)
return 0;
- if (!phdr->p_filesz)
+ if (!p_filesz)
return 0;
- pr_debug("Loading phdr to 0x%p (%i bytes)\n", dst, phdr->p_filesz);
+ pr_debug("Loading phdr to 0x%p (%llu bytes)\n", dst, p_filesz);
- ret = elf_request_region(elf, (resource_size_t)dst, phdr->p_filesz);
+ ret = elf_request_region(elf, (resource_size_t)dst, p_filesz);
if (ret)
return ret;
- memcpy(dst, src, phdr->p_filesz);
+ memcpy(dst, src, p_filesz);
- if (phdr->p_filesz < phdr->p_memsz)
- memset(dst + phdr->p_filesz, 0x00,
- phdr->p_memsz - phdr->p_filesz);
+ if (p_filesz < p_memsz)
+ memset(dst + p_filesz, 0x00,
+ p_memsz - p_filesz);
return 0;
}
@@ -75,14 +77,13 @@ static int load_elf_phdr_segment(struct elf_image *elf, void *src,
static int load_elf_image_phdr(struct elf_image *elf)
{
void *buf = elf->buf;
- Elf32_Ehdr *ehdr = buf;
- Elf32_Phdr *phdr = (Elf32_Phdr *)(buf + ehdr->e_phoff);
+ void *phdr = (void *) (buf + elf_hdr_e_phoff(elf, buf));
int i, ret;
- elf->entry = ehdr->e_entry;
+ elf->entry = elf_hdr_e_entry(elf, buf);
- for (i = 0; i < ehdr->e_phnum; ++i) {
- void *src = buf + phdr->p_offset;
+ for (i = 0; i < elf_hdr_e_phnum(elf, buf) ; ++i) {
+ void *src = buf + elf_phdr_p_offset(elf, phdr);
ret = load_elf_phdr_segment(elf, src, phdr);
/* in case of error elf_load_image() caller should clean up and
@@ -90,22 +91,22 @@ static int load_elf_image_phdr(struct elf_image *elf)
if (ret)
return ret;
- ++phdr;
+ phdr += elf_size_of_phdr(elf);
}
return 0;
}
-static int elf_check_image(void *buf)
+static int elf_check_image(struct elf_image *elf)
{
- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)buf;
-
- if (strncmp(buf, ELFMAG, SELFMAG)) {
+ if (strncmp(elf->buf, ELFMAG, SELFMAG)) {
pr_err("ELF magic not found.\n");
return -EINVAL;
}
- if (ehdr->e_type != ET_EXEC) {
+ elf->class = ((char *) elf->buf)[EI_CLASS];
+
+ if (elf_hdr_e_type(elf, elf->buf) != ET_EXEC) {
pr_err("Non EXEC ELF image.\n");
return -ENOEXEC;
}
@@ -124,7 +125,7 @@ struct elf_image *elf_load_image(void *buf)
elf->buf = buf;
- ret = elf_check_image(buf);
+ ret = elf_check_image(elf);
if (ret)
return ERR_PTR(ret);
diff --git a/common/ratp/mw.c b/common/ratp/mw.c
index 55e79bbaf0..772910b39d 100644
--- a/common/ratp/mw.c
+++ b/common/ratp/mw.c
@@ -125,7 +125,7 @@ static int ratp_cmd_mw(const struct ratp_bb *req, int req_len,
/* Validate buffer size */
if (buffer_size < (path_size + data_size)) {
- pr_err("ignored: size mismatch (%d < %hu): path or data not be fully given\n",
+ pr_err("ignored: size mismatch (%d < %u): path or data not be fully given\n",
req_len, path_size + data_size);
ret = -EINVAL;
goto out;
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index 9aea1786d6..e84ad22167 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -259,19 +259,17 @@ static int ratp_console_tstc(struct console_device *cdev)
return kfifo_len(ctx->console_recv_fifo) ? 1 : 0;
}
-static int ratp_console_puts(struct console_device *cdev, const char *s)
+static int ratp_console_puts(struct console_device *cdev, const char *s,
+ size_t nbytes)
{
struct ratp_ctx *ctx = container_of(cdev, struct ratp_ctx, ratp_console);
- int len = 0;
-
- len = strlen(s);
if (ratp_busy(&ctx->ratp))
- return len;
+ return nbytes;
- kfifo_put(ctx->console_transmit_fifo, s, len);
+ kfifo_put(ctx->console_transmit_fifo, s, nbytes);
- return len;
+ return nbytes;
}
static void ratp_console_putc(struct console_device *cdev, char c)
diff --git a/common/startup.c b/common/startup.c
index 88eeee5e3d..c6e119966a 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -202,7 +202,7 @@ void set_autoboot_state(enum autoboot_state autoboot)
* do_autoboot_countdown - print autoboot countdown to console
*
* This prints the autoboot countdown to the console and waits for input. This
- * evaluates the global.autoboot_about_key to determine which keys are allowed
+ * evaluates the global.autoboot_abort_key to determine which keys are allowed
* to interrupt booting and also global.autoboot_timeout to determine the timeout
* for the counter. This function can be called multiple times, it is executed
* only the first time.
@@ -314,11 +314,11 @@ static int run_init(void)
autoboot = do_autoboot_countdown();
+ console_ctrlc_allow();
+
if (autoboot == AUTOBOOT_BOOT)
run_command("boot");
- console_ctrlc_allow();
-
if (autoboot == AUTOBOOT_MENU)
run_command(MENUFILE);
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index d397e803b1..42bde5ed1c 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -177,7 +177,7 @@ static int pca954x_probe(struct device_d *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
- int num, force;
+ int num;
struct pca954x *data;
uintptr_t tmp;
int ret = -ENODEV;
@@ -195,10 +195,11 @@ static int pca954x_probe(struct device_d *dev)
if (gpio_is_valid(gpio))
gpio_direction_output(gpio, 1);
- /* Read the mux register at addr to verify
- * that the mux is in fact present.
+ /* Write the mux register at addr to verify
+ * that the mux is in fact present. This also
+ * initializes the mux to disconnected state.
*/
- if (i2c_smbus_read_byte(client) < 0) {
+ if (i2c_smbus_write_byte(client, 0) < 0) {
dev_warn(&client->dev, "probe failed\n");
goto exit_free;
}
@@ -220,8 +221,8 @@ static int pca954x_probe(struct device_d *dev)
if (data->virt_adaps[num] == NULL) {
ret = -ENODEV;
dev_err(&client->dev,
- "failed to register multiplexed adapter"
- " %d as bus %d\n", num, force);
+ "failed to register multiplexed adapter%d\n",
+ num);
goto virt_reg_failed;
}
}
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 1f89ae3892..be061683fb 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -64,4 +64,10 @@ config KEYBOARD_USB
help
This driver implements support for usb keyboard.
+config INPUT_SPECIALKEYS
+ bool "Special keys handler"
+ select INPUT
+ help
+ Say Y here to handle key events like KEY_RESTART and KEY_POWER.
+
endmenu
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index e694a98d10..36a4204d53 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o
obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
+obj-$(CONFIG_INPUT_SPECIALKEYS) += specialkeys.o
diff --git a/drivers/input/specialkeys.c b/drivers/input/specialkeys.c
new file mode 100644
index 0000000000..ff29b8455d
--- /dev/null
+++ b/drivers/input/specialkeys.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Ahmad Fatoum, Pengutronix
+
+#include <common.h>
+#include <restart.h>
+#include <poweroff.h>
+#include <init.h>
+#include <input/input.h>
+#include <dt-bindings/input/linux-event-codes.h>
+
+static void input_specialkeys_notify(struct input_notifier *in,
+ struct input_event *ev)
+{
+ switch (ev->code) {
+ case KEY_RESTART:
+ pr_info("Triggering reset due to special key.\n", ev->code);
+ restart_machine();
+ break;
+
+ case KEY_POWER:
+ pr_info("Triggering poweroff due to special key.\n", ev->code);
+ poweroff_machine();
+ break;
+ }
+
+ pr_debug("ignoring code: %d\n", ev->code);
+}
+
+static struct input_notifier notifier;
+
+static int input_specialkeys_init(void)
+{
+ notifier.notify = input_specialkeys_notify;
+ return input_register_notfier(&notifier);
+}
+late_initcall(input_specialkeys_init);
diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c
index 1448c4143f..67f7d4c654 100644
--- a/drivers/mfd/rave-sp.c
+++ b/drivers/mfd/rave-sp.c
@@ -640,6 +640,7 @@ static int rave_sp_emulated_get_status(struct rave_sp *sp,
[0] = RAVE_SP_CMD_GET_FIRMWARE_VERSION,
[1] = 0,
};
+ u8 firmware_mode;
int ret;
ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status->firmware_version,
@@ -648,8 +649,21 @@ static int rave_sp_emulated_get_status(struct rave_sp *sp,
return ret;
cmd[0] = RAVE_SP_CMD_GET_BOOTLOADER_VERSION;
- return rave_sp_exec(sp, cmd, sizeof(cmd), &status->bootloader_version,
- sizeof(status->bootloader_version));
+ ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status->bootloader_version,
+ sizeof(status->bootloader_version));
+ if (ret)
+ return ret;
+
+ cmd[0] = RAVE_SP_CMD_GET_OPERATIONAL_MODE;
+ ret = rave_sp_exec(sp, cmd, sizeof(cmd), &firmware_mode,
+ sizeof(firmware_mode));
+ if (ret)
+ return ret;
+
+ status->general_status =
+ firmware_mode ? RAVE_SP_STATUS_GS_FIRMWARE_MODE : 0;
+
+ return 0;
}
static int rave_sp_get_status(struct rave_sp *sp)
diff --git a/drivers/net/phy/mv88e6xxx/chip.c b/drivers/net/phy/mv88e6xxx/chip.c
index ac08b5ef54..9688dbd1be 100644
--- a/drivers/net/phy/mv88e6xxx/chip.c
+++ b/drivers/net/phy/mv88e6xxx/chip.c
@@ -572,7 +572,6 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
.name = "Marvell 88E6352",
.num_ports = 7,
.port_base_addr = 0x10,
- .ops = &mv88e6352_ops,
.global2_addr = 0x1c,
.ops = &mv88e6352_ops,
},
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 0d5dcb31ee..ea7cea5f1b 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -540,7 +540,7 @@ static int smc911x_probe(struct device_d *dev)
* poll the READY bit in PMT_CTRL. Any other access to the device is
* forbidden while this bit isn't set. Try for 100ms
*/
- ret = wait_on_timeout(100 * MSECOND, !smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY);
+ ret = wait_on_timeout(100 * MSECOND, smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY);
if (!ret) {
dev_err(dev, "Device not READY in 100ms aborting\n");
return -ENODEV;
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e0984708b4..d2c2b6f306 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -94,7 +94,7 @@ EXPORT_SYMBOL_GPL(nvme_set_queue_count);
static int nvme_wait_ready(struct nvme_ctrl *ctrl, u64 cap, bool enabled)
{
uint64_t start = get_time_ns();
- unsigned long timeout =
+ uint64_t timeout =
((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2);
u32 csts, bit = enabled ? NVME_CSTS_RDY : 0;
int ret;
@@ -496,7 +496,7 @@ EXPORT_SYMBOL_GPL(nvme_enable_ctrl);
int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl)
{
uint64_t start = get_time_ns();
- unsigned long timeout = SHUTDOWN_TIMEOUT;
+ uint64_t timeout = SHUTDOWN_TIMEOUT;
u32 csts;
int ret;
diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index 0703f727e7..2ca89fa4f8 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -243,12 +243,13 @@ static int efi_process_key(struct efi_console_priv *priv, const char *inp)
return 1;
}
-static int efi_console_puts(struct console_device *cdev, const char *s)
+static int efi_console_puts(struct console_device *cdev, const char *s,
+ size_t nbytes)
{
struct efi_console_priv *priv = to_efi(cdev);
int n = 0;
- while (*s) {
+ while (nbytes--) {
if (*s == 27) {
priv->efi_console_buffer[n] = 0;
priv->out->output_string(priv->out,
diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
index f0a2b22c2b..667d51f622 100644
--- a/drivers/serial/serial_efi.c
+++ b/drivers/serial/serial_efi.c
@@ -130,13 +130,14 @@ static void efi_serial_putc(struct console_device *cdev, char c)
serial->write(serial, &buffersize, &c);
}
-static int efi_serial_puts(struct console_device *cdev, const char *s)
+static int efi_serial_puts(struct console_device *cdev, const char *s,
+ size_t nbytes)
{
struct efi_serial_port *uart = to_efi_serial_port(cdev);
struct efi_serial_io_protocol *serial = uart->serial;
uint32_t control;
efi_status_t efiret;
- unsigned long buffersize = strlen(s) * sizeof(char);
+ unsigned long buffersize = nbytes;
do {
efiret = serial->getcontrol(serial, &control);
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index a47ba20f46..a44c7abc01 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1422,8 +1422,7 @@ static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe)
{
struct fsl_ep *ep = get_ep_by_pipe(udc, pipe);
- if (ep->name)
- nuke(ep, -ESHUTDOWN);
+ nuke(ep, -ESHUTDOWN);
}
/* Clear up all ep queues */
@@ -1914,12 +1913,6 @@ static void dtd_complete_irq(struct fsl_udc *udc)
curr_ep = get_ep_by_pipe(udc, i);
- /* If the ep is configured */
- if (curr_ep->name == NULL) {
- WARNING("Invalid EP?");
- continue;
- }
-
/* process the req queue until an uncomplete request */
list_for_each_entry_safe(curr_req, temp_req, &curr_ep->queue,
queue) {
diff --git a/drivers/video/stm.c b/drivers/video/stm.c
index 0c190d36ae..d4a618fe50 100644
--- a/drivers/video/stm.c
+++ b/drivers/video/stm.c
@@ -551,9 +551,9 @@ static int stmfb_probe(struct device_d *hw_dev)
}
modes = of_get_display_timings(display);
- if (IS_ERR(modes)) {
+ if (!modes) {
dev_err(hw_dev, "unable to parse display timings\n");
- return PTR_ERR(modes);
+ return -EINVAL;
}
fbi.info.modes.modes = modes->modes;
diff --git a/fs/fat/ff.c b/fs/fat/ff.c
index ba4adfc133..4d30433e5f 100644
--- a/fs/fat/ff.c
+++ b/fs/fat/ff.c
@@ -1538,7 +1538,7 @@ static enum filetype check_fs ( /* 0:The FAT BR, 1:Valid BR but not an FAT, 2:No
DWORD *bootsec
)
{
- enum filetype ret;
+ DRESULT ret;
/* Load boot record */
ret = disk_read(fs, fs->win, sect, 1);
diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
index 169cde7ddb..4f159210d1 100644
--- a/fs/omap4_usbbootfs.c
+++ b/fs/omap4_usbbootfs.c
@@ -29,39 +29,6 @@ struct file_priv {
s32 id;
u32 size;
};
-/*
-static int omap4_usbbootfs_create(
- struct device_d *dev, const char *pathname, mode_t mode)
-{
- return -ENOSYS;
-}
-
-static int omap4_usbbootfs_unlink(struct device_d *dev, const char *pathname)
-{
- return -ENOSYS;
-}
-
-static int omap4_usbbootfs_mkdir(struct device_d *dev, const char *pathname)
-{
- return -ENOSYS;
-}
-
-static int omap4_usbbootfs_rmdir(struct device_d *dev, const char *pathname)
-{
- return -ENOSYS;
-}
-
-static int omap4_usbbootfs_write(
- struct device_d *_dev, FILE *f, const void *inbuf, size_t size)
-{
- return -ENOSYS;
-}
-
-static int omap4_usbbootfs_truncate(struct device_d *dev, FILE *f, loff_t size)
-{
- return -ENOSYS;
-}
-*/
static struct file_priv *omap4_usbbootfs_do_open(
struct device_d *dev, int accmode, const char *filename)
@@ -187,14 +154,6 @@ static struct fs_driver_d omap4_usbbootfs_driver = {
.read = omap4_usbbootfs_read,
.opendir = omap4_usbbootfs_opendir,
.stat = omap4_usbbootfs_stat,
-/*
- .create = omap4_usbbootfs_create,
- .unlink = omap4_usbbootfs_unlink,
- .mkdir = omap4_usbbootfs_mkdir,
- .rmdir = omap4_usbbootfs_rmdir,
- .write = omap4_usbbootfs_write,
- .truncate= omap4_usbbootfs_truncate,
-*/
.flags = 0,
.drv = {
.probe = omap4_usbbootfs_probe,
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 0a6fa38edc..15c0174b1f 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -46,6 +46,35 @@ void pstore_set_kmsg_bytes(int bytes)
static int pstore_ready;
+static void pstore_console_write(const char *s, unsigned c)
+{
+ const char *e = s + c;
+
+ while (s < e) {
+ struct pstore_record record = {
+ .type = PSTORE_TYPE_CONSOLE,
+ .psi = psinfo,
+ };
+
+ if (c > psinfo->bufsize)
+ c = psinfo->bufsize;
+
+ record.buf = (char *)s;
+ record.size = c;
+ psinfo->write_buf(PSTORE_TYPE_CONSOLE, 0, &record.id, 0,
+ record.buf, 0, record.size, psinfo);
+ s += c;
+ c = e - s;
+ }
+}
+
+static int pstore_console_puts(struct console_device *cdev, const char *s,
+ size_t nbytes)
+{
+ pstore_console_write(s, nbytes);
+ return nbytes;
+}
+
void pstore_log(const char *str)
{
uint64_t id;
diff --git a/include/ata_drive.h b/include/ata_drive.h
index 11685eef12..d61c6f11d4 100644
--- a/include/ata_drive.h
+++ b/include/ata_drive.h
@@ -14,7 +14,7 @@
*/
#ifndef ATA_DISK_H
-# define ATA_DISK
+#define ATA_DISK_H
#include <block.h>
@@ -197,4 +197,4 @@ struct device_d;
* 0x400 data data 16 bit area with 1 kiB in size
*/
-#endif /* ATA_DISK */
+#endif /* ATA_DISK_H */
diff --git a/include/console.h b/include/console.h
index 4062e5abf6..7afe59e93a 100644
--- a/include/console.h
+++ b/include/console.h
@@ -42,7 +42,7 @@ struct console_device {
int (*tstc)(struct console_device *cdev);
void (*putc)(struct console_device *cdev, char c);
- int (*puts)(struct console_device *cdev, const char *s);
+ int (*puts)(struct console_device *cdev, const char *s, size_t nbytes);
int (*getc)(struct console_device *cdev);
int (*setbrg)(struct console_device *cdev, int baudrate);
void (*flush)(struct console_device *cdev);
diff --git a/include/elf.h b/include/elf.h
index 92c8d9c127..633f4992dd 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -400,11 +400,38 @@ static inline void arch_write_notes(struct file *file) { }
struct elf_image {
struct list_head list;
- unsigned long entry;
+ u8 class;
+ u64 entry;
void *buf;
};
struct elf_image *elf_load_image(void *buf);
void elf_release_image(struct elf_image *elf);
+#define ELF_GET_FIELD(__s, __field, __type) \
+static inline __type elf_##__s##_##__field(struct elf_image *elf, void *arg) { \
+ if (elf->class == ELFCLASS32) \
+ return (__type) ((struct elf32_##__s *) arg)->__field; \
+ else \
+ return (__type) ((struct elf64_##__s *) arg)->__field; \
+}
+
+ELF_GET_FIELD(hdr, e_entry, u64)
+ELF_GET_FIELD(hdr, e_phnum, u16)
+ELF_GET_FIELD(hdr, e_phoff, u64)
+ELF_GET_FIELD(hdr, e_type, u16)
+ELF_GET_FIELD(phdr, p_paddr, u64)
+ELF_GET_FIELD(phdr, p_filesz, u64)
+ELF_GET_FIELD(phdr, p_memsz, u64)
+ELF_GET_FIELD(phdr, p_type, u32)
+ELF_GET_FIELD(phdr, p_offset, u64)
+
+static inline unsigned long elf_size_of_phdr(struct elf_image *elf)
+{
+ if (elf->class == ELFCLASS32)
+ return sizeof(Elf32_Phdr);
+ else
+ return sizeof(Elf64_Phdr);
+}
+
#endif /* _LINUX_ELF_H */
diff --git a/include/gpio.h b/include/gpio.h
index 1926edeca7..4d5f2c25c7 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -3,6 +3,7 @@
#include <linux/types.h>
#include <linux/list.h>
+#include <linux/iopoll.h>
#ifdef CONFIG_GENERIC_GPIO
void gpio_set_value(unsigned gpio, int value);
@@ -31,6 +32,21 @@ static inline int gpio_direction_input(unsigned gpio)
void gpio_set_active(unsigned gpio, bool state);
int gpio_is_active(unsigned gpio);
int gpio_direction_active(unsigned gpio, bool state);
+
+/**
+ * gpio_poll_timeout_us - Poll till GPIO reaches requested active state
+ * @gpio: gpio to poll
+ * @active: wait till GPIO is active if true, wait till it's inactive if false
+ * @timeout_us: timeout in microseconds
+ *
+ * During the wait barebox pollers are called, if any.
+ */
+#define gpio_poll_timeout_us(gpio, active, timeout_us) \
+ ({ \
+ int __state; \
+ readx_poll_timeout(gpio_is_active, gpio, __state, \
+ __state == (active), timeout_us); \
+ })
#else
static inline void gpio_set_active(unsigned gpio, int value)
{
@@ -43,6 +59,8 @@ static inline int gpio_direction_active(unsigned gpio, int value)
{
return -EINVAL;
}
+
+#define gpio_poll_timeout_us(gpio, val, timeout_us) (-ENOSYS)
#endif
#if defined(CONFIG_ARCH_NR_GPIO) && CONFIG_ARCH_NR_GPIO > 0
diff --git a/include/linux/mfd/rave-sp.h b/include/linux/mfd/rave-sp.h
index 7b3187cb74..92315c6e12 100644
--- a/include/linux/mfd/rave-sp.h
+++ b/include/linux/mfd/rave-sp.h
@@ -14,6 +14,7 @@
enum rave_sp_command {
RAVE_SP_CMD_GET_FIRMWARE_VERSION = 0x20,
RAVE_SP_CMD_GET_BOOTLOADER_VERSION = 0x21,
+ RAVE_SP_CMD_GET_OPERATIONAL_MODE = 0x25,
RAVE_SP_CMD_BOOT_SOURCE = 0x26,
RAVE_SP_CMD_GET_BOARD_COPPER_REV = 0x2B,
RAVE_SP_CMD_GET_GPIO_STATE = 0x2F,
diff --git a/include/mci.h b/include/mci.h
index 072008ef9d..77625ea8e9 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -164,6 +164,7 @@
#define EXT_CSD_EXT_PARTITIONS_ATTRIBUTE 52 /* R/W, 2 bytes */
#define EXT_CSD_EXCEPTION_EVENTS_STATUS 54 /* RO, 2 bytes */
#define EXT_CSD_EXCEPTION_EVENTS_CTRL 56 /* R/W, 2 bytes */
+#define EXT_CSD_EXCEPTION_DYNCAP_NEEDED 58 /* RO, 1 byte */
#define EXT_CSD_CLASS_6_CTRL 59 /* R/W */
#define EXT_CSD_INI_TIMEOUT_EMU 60 /* RO */
#define EXT_CSD_DATA_SECTOR_SIZE 61 /* RO */
diff --git a/include/param.h b/include/param.h
index b618a2305d..dea6990497 100644
--- a/include/param.h
+++ b/include/param.h
@@ -272,7 +272,7 @@ static inline struct param_d *dev_add_param_string_ro(struct device_d *dev, cons
}
static inline struct param_d *dev_add_param_string_fixed(struct device_d *dev, const char *name,
- char *value)
+ const char *value)
{
return dev_add_param_fixed(dev, name, value);
}
diff --git a/lib/gui/png_lode.c b/lib/gui/png_lode.c
index 477704d976..e30db0f853 100644
--- a/lib/gui/png_lode.c
+++ b/lib/gui/png_lode.c
@@ -46,15 +46,16 @@ struct image *png_open(char *inbuf, int insize)
LodePNGState state;
int ret;
unsigned error;
- struct image *img = calloc(1, sizeof(struct image));
- unsigned char *png;
-
- if (!img)
- return ERR_PTR(-ENOMEM);
+ struct image *img;
+ unsigned char *png = NULL;
ret = png_uncompress_init();
if (ret)
- goto err;
+ return ERR_PTR(ret);
+
+ img = calloc(1, sizeof(struct image));
+ if (!img)
+ return ERR_PTR(-ENOMEM);
lodepng_state_init(&state);
diff --git a/lib/libfile.c b/lib/libfile.c
index b42753c2b5..3f3ec21fdb 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -38,7 +38,7 @@ int pwrite_full(int fd, const void *buf, size_t size, loff_t offset)
now = pwrite(fd, buf, size, offset);
if (now == 0) {
errno = ENOSPC;
- return -1;
+ return -errno;
}
if (now < 0)
return now;
@@ -66,7 +66,7 @@ int write_full(int fd, const void *buf, size_t size)
now = write(fd, buf, size);
if (now == 0) {
errno = ENOSPC;
- return -1;
+ return -errno;
}
if (now < 0)
return now;
@@ -194,6 +194,7 @@ again:
buf = calloc(read_size + 1, 1);
if (!buf) {
ret = -ENOMEM;
+ errno = ENOMEM;
goto err_out;
}
@@ -241,9 +242,9 @@ EXPORT_SYMBOL(read_file_2);
*
* This function reads a file to an allocated buffer.
* Some TFTP servers do not transfer the size of a file. In this case
- * a the file is first read to a temporary file.
+ * the file is first read to a temporary file.
*
- * Return: The buffer conataining the file or NULL on failure
+ * Return: The buffer containing the file or NULL on failure
*/
void *read_file(const char *filename, size_t *size)
{