summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-07-18 07:13:14 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-07-18 07:13:14 +0200
commit889612fab092ec20463c886513b5cfde14cc8cb0 (patch)
tree069cb22123290fd999f4d03aa19a73be344c9ffb
parent8a5144d02a0146c4f0ec577232c0a102d12c8ee7 (diff)
parent8751ea38a38e2dd81c6a80848be760cc4d0aca2b (diff)
downloadbarebox-889612fab092ec20463c886513b5cfde14cc8cb0.tar.gz
barebox-889612fab092ec20463c886513b5cfde14cc8cb0.tar.xz
Merge branch 'for-next/misc'
-rw-r--r--arch/riscv/lib/bootm.c3
-rw-r--r--commands/md.c2
-rw-r--r--common/bbu.c27
-rw-r--r--drivers/nvmem/core.c2
-rw-r--r--drivers/regulator/fixed.c12
-rw-r--r--drivers/reset/reset-stm32.c4
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/usb/misc/usb251xb.c2
-rw-r--r--drivers/w1/masters/w1-gpio.c15
-rw-r--r--drivers/w1/slaves/w1_ds2431.c10
-rw-r--r--drivers/w1/slaves/w1_ds2433.c12
-rw-r--r--lib/Kconfig2
-rw-r--r--lib/image-sparse.c4
-rw-r--r--test/kconfig/base.cfg1
-rw-r--r--test/kconfig/full.cfg1
-rw-r--r--test/self/Kconfig4
-rw-r--r--test/self/Makefile1
-rw-r--r--test/self/progress-notifier.c79
18 files changed, 138 insertions, 45 deletions
diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index 8504ee63a9..1b96edcd1b 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -14,6 +14,9 @@ static int do_bootm_linux(struct image_data *data)
if (IS_ERR(fn))
return PTR_ERR(fn);
+ if (data->dryrun)
+ return 0;
+
ret = of_overlay_load_firmware();
if (ret)
return ret;
diff --git a/commands/md.c b/commands/md.c
index ef6a1e1bc0..d80c7cca0c 100644
--- a/commands/md.c
+++ b/commands/md.c
@@ -59,7 +59,7 @@ static int do_mem_md(int argc, char *argv[])
goto out;
}
- buf = xmalloc(RW_BUF_SIZE);
+ buf = xzalloc(RW_BUF_SIZE + 7);
do {
now = min(size, (loff_t)RW_BUF_SIZE);
diff --git a/common/bbu.c b/common/bbu.c
index 1a1edda96b..cd7bdc40b7 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -4,6 +4,9 @@
*
* Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*/
+
+#define pr_fmt(fmt) "bbu: " fmt
+
#include <common.h>
#include <bbu.h>
#include <linux/list.h>
@@ -32,12 +35,32 @@ static void append_bbu_entry(struct bbu_handler *handler, struct file_list *file
free(name);
}
+static bool bbu_handler_is_available(struct bbu_handler *handler)
+{
+ struct stat s;
+ int ret;
+
+ device_detect_by_name(devpath_to_name(handler->devicefile));
+
+ ret = stat(handler->devicefile, &s);
+ if (ret)
+ return false;
+
+ return true;
+}
+
void bbu_append_handlers_to_file_list(struct file_list *files)
{
struct bbu_handler *handler;
- list_for_each_entry(handler, &bbu_image_handlers, list)
- append_bbu_entry(handler, files);
+ list_for_each_entry(handler, &bbu_image_handlers, list) {
+ if (bbu_handler_is_available(handler)) {
+ append_bbu_entry(handler, files);
+ } else {
+ pr_info("Skipping unavailable handler bbu-%s\n",
+ handler->name);
+ }
+ }
}
int bbu_force(struct bbu_data *data, const char *fmt, ...)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index cfeecf70cd..8f4b4646a9 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -215,7 +215,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
dev_set_name(&nvmem->dev, config->name);
nvmem->dev.id = DEVICE_ID_DYNAMIC;
- dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
+ dev_dbg(nvmem->dev.parent, "Registering nvmem device %s\n", config->name);
rval = register_device(&nvmem->dev);
if (rval) {
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 160a55163f..e35b294fb2 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -20,10 +20,10 @@
#include <of.h>
#include <of_gpio.h>
#include <gpio.h>
+#include <gpiod.h>
struct regulator_fixed {
int gpio;
- int active_low;
int always_on;
struct regulator_dev rdev;
struct regulator_desc rdesc;
@@ -36,7 +36,7 @@ static int regulator_fixed_enable(struct regulator_dev *rdev)
if (!gpio_is_valid(fix->gpio))
return 0;
- return gpio_direction_output(fix->gpio, !fix->active_low);
+ return gpio_direction_active(fix->gpio, true);
}
static int regulator_fixed_disable(struct regulator_dev *rdev)
@@ -49,7 +49,7 @@ static int regulator_fixed_disable(struct regulator_dev *rdev)
if (!gpio_is_valid(fix->gpio))
return 0;
- return gpio_direction_output(fix->gpio, fix->active_low);
+ return gpio_direction_active(fix->gpio, false);
}
const static struct regulator_ops fixed_ops = {
@@ -60,7 +60,6 @@ const static struct regulator_ops fixed_ops = {
static int regulator_fixed_probe(struct device_d *dev)
{
struct regulator_fixed *fix;
- enum of_gpio_flags gpioflags;
int ret;
if (!dev->device_node)
@@ -70,14 +69,11 @@ static int regulator_fixed_probe(struct device_d *dev)
fix->gpio = -EINVAL;
if (of_get_property(dev->device_node, "gpio", NULL)) {
- fix->gpio = of_get_named_gpio_flags(dev->device_node, "gpio", 0, &gpioflags);
+ fix->gpio = gpiod_get(dev, NULL, GPIOD_ASIS);
if (fix->gpio < 0) {
ret = fix->gpio;
goto err;
}
-
- if (gpioflags & OF_GPIO_ACTIVE_LOW)
- fix->active_low = 1;
}
fix->rdesc.ops = &fixed_ops;
diff --git a/drivers/reset/reset-stm32.c b/drivers/reset/reset-stm32.c
index a4498f573b..2ef00859c4 100644
--- a/drivers/reset/reset-stm32.c
+++ b/drivers/reset/reset-stm32.c
@@ -81,8 +81,8 @@ static u32 stm32_reset_status(struct stm32_reset *priv, unsigned long bank)
static void stm32_reset(struct stm32_reset *priv, unsigned long id, bool assert)
{
- int bank = (id / BITS_PER_LONG) * 4;
- int offset = id % BITS_PER_LONG;
+ int bank = (id / 32) * 4;
+ int offset = id % 32;
priv->ops->reset(priv->base + bank, offset, assert);
}
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 323d93efeb..91083ee709 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -71,7 +71,7 @@ config DRIVER_SPI_IMX_0_7
config DRIVER_SPI_IMX_2_3
bool
- depends on ARCH_IMX50 || ARCH_IMX51 || ARCH_IMX53 || ARCH_IMX6 || ARCH_IMX7 || ARCH_IMX8MQ
+ depends on ARCH_IMX50 || ARCH_IMX51 || ARCH_IMX53 || ARCH_IMX6 || ARCH_IMX7 || ARCH_IMX8M
default y
config DRIVER_SPI_MXS
diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 10d5aa310b..e282988fb4 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -560,7 +560,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
*/
hub->port_swap = USB251XB_DEF_PORT_SWAP;
of_property_for_each_u32(np, "swap-dx-lanes", prop, p, port) {
- if ((port >= 0) && (port <= data->port_cnt))
+ if (port <= data->port_cnt)
hub->port_swap |= BIT(port);
}
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index 916027ea87..8f2f772c6e 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -1,13 +1,8 @@
-/*
- * w1-gpio - GPIO w1 bus master driver
- *
- * Copyright (C) 2007 Ville Syrjala <syrjala@sci.fi>
- * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2007 Ville Syrjala <syrjala@sci.fi>
+// SPDX-FileCopyrightText: 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+
+/* w1-gpio - GPIO w1 bus master driver */
#include <common.h>
#include <init.h>
diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c
index ab2ceffa42..9a5f6b5dae 100644
--- a/drivers/w1/slaves/w1_ds2431.c
+++ b/drivers/w1/slaves/w1_ds2431.c
@@ -1,13 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2008 Bernhard Weirich <bernhard.weirich@riedel.net>
+// SPDX-FileCopyrightText: 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+
/*
* w1_ds2431.c - w1 family 2d (DS2431) driver
*
- * Copyright (c) 2008 Bernhard Weirich <bernhard.weirich@riedel.net>
- * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
- *
* Heavily inspired by w1_DS2433 driver from Ben Gardner <bgardner@wabtec.com>
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
*/
#include <init.h>
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index b24fb5b3b5..0e626530db 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -1,11 +1,7 @@
-/*
- * w1_ds2433.c - w1 family 23 (DS2433) driver
- *
- * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: 2005 Ben Gardner <bgardner@wabtec.com>
+
+/* w1_ds2433.c - w1 family 23 (DS2433) driver */
#include <init.h>
#include "../w1.h"
diff --git a/lib/Kconfig b/lib/Kconfig
index 922710e106..ea6de76a22 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -155,7 +155,7 @@ source "lib/logo/Kconfig"
source "lib/bootstrap/Kconfig"
config PROGRESS_NOTIFIER
- bool
+ bool "Progress Notifier" if COMPILE_TEST
help
This is selected by boards that register a notifier to visualize
progress, like blinking a LED during an update.
diff --git a/lib/image-sparse.c b/lib/image-sparse.c
index c375c78d63..eb5242e25a 100644
--- a/lib/image-sparse.c
+++ b/lib/image-sparse.c
@@ -46,10 +46,6 @@
#include <linux/math64.h>
-#ifndef CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE
-#define CONFIG_FASTBOOT_FLASH_FILLBUF_SIZE (1024 * 512)
-#endif
-
struct sparse_image_ctx {
int fd;
struct sparse_header sparse;
diff --git a/test/kconfig/base.cfg b/test/kconfig/base.cfg
index 6a9f683498..80b9c68f02 100644
--- a/test/kconfig/base.cfg
+++ b/test/kconfig/base.cfg
@@ -1,3 +1,4 @@
+CONFIG_COMPILE_TEST=y
CONFIG_TEST=y
CONFIG_SELFTEST=y
CONFIG_CMD_SELFTEST=y
diff --git a/test/kconfig/full.cfg b/test/kconfig/full.cfg
index 39275768ea..547100bacc 100644
--- a/test/kconfig/full.cfg
+++ b/test/kconfig/full.cfg
@@ -1,2 +1,3 @@
CONFIG_BTHREAD=y
CONFIG_CMD_BTHREAD=y
+CONFIG_PROGRESS_NOTIFIER=y
diff --git a/test/self/Kconfig b/test/self/Kconfig
index 73dc6c7b4f..dfaa32dda0 100644
--- a/test/self/Kconfig
+++ b/test/self/Kconfig
@@ -28,6 +28,7 @@ config SELFTEST_AUTORUN
config SELFTEST_ENABLE_ALL
bool "Enable all self-tests"
select SELFTEST_PRINTF
+ select SELFTEST_PROGRESS_NOTIFIER
help
Selects all self-tests compatible with current configuration
@@ -36,4 +37,7 @@ config SELFTEST_PRINTF
help
Tests barebox vsnprintf() functionality
+config SELFTEST_PROGRESS_NOTIFIER
+ bool "progress notifier selftest"
+
endif
diff --git a/test/self/Makefile b/test/self/Makefile
index b4aa49d6f8..e78ccc3cfb 100644
--- a/test/self/Makefile
+++ b/test/self/Makefile
@@ -2,3 +2,4 @@
obj-$(CONFIG_SELFTEST) += core.o
obj-$(CONFIG_SELFTEST_PRINTF) += printf.o
+obj-$(CONFIG_SELFTEST_PROGRESS_NOTIFIER) += progress-notifier.o
diff --git a/test/self/progress-notifier.c b/test/self/progress-notifier.c
new file mode 100644
index 0000000000..af65b0900e
--- /dev/null
+++ b/test/self/progress-notifier.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <common.h>
+#include <bselftest.h>
+#include <progress.h>
+
+BSELFTEST_GLOBALS();
+
+static void __ok(bool cond, const char *func, int line)
+{
+ total_tests++;
+ if (!cond) {
+ failed_tests++;
+ printf("%s:%d: assertion failure\n", func, line);
+ }
+}
+
+#define ok(cond) \
+ __ok(cond, __func__, __LINE__)
+
+static unsigned long stage;
+static const void *prefix;
+static int counter;
+
+static int dummy_notifier(struct notifier_block *r, unsigned long _stage, void *_prefix)
+{
+ prefix = _prefix;
+ stage = _stage;
+ counter++;
+ return 0;
+}
+
+static struct notifier_block dummy_nb = {
+ .notifier_call = dummy_notifier
+};
+
+static void test_dummy_notifier(void)
+{
+ const char *arg = "ARGUMENT";
+ int local_counter = 0;
+
+ stage = 0;
+ prefix = NULL;
+ counter = 0;
+
+ progress_register_client(&dummy_nb);
+ ok(stage == 0);
+ ok(prefix == NULL);
+ ok(counter == local_counter);
+ progress_notifier_call_chain(1, arg);
+
+ if (IS_ENABLED(CONFIG_PROGRESS_NOTIFIER)) {
+ ok(stage == 1);
+ ok(prefix == arg);
+ ok(counter == ++local_counter);
+ progress_notifier_call_chain(0, NULL);
+ local_counter++;
+ } else {
+ total_tests += 2;
+ skipped_tests += 2;
+ }
+
+ ok(stage == 0);
+ ok(prefix == NULL || *(const char *)prefix == '\0');
+ ok(counter == local_counter);
+ progress_unregister_client(&dummy_nb);
+
+ ok(stage == 0);
+ ok(prefix == NULL || *(const char *)prefix == '\0');
+ ok(counter == local_counter);
+}
+
+static void test_notifier(void)
+{
+ test_dummy_notifier();
+}
+bselftest(core, test_notifier);