summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-11-24 09:52:46 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-11-24 09:52:46 +0100
commit7b1c1e40811fec5699f45cdcb2a18c0e8ac67755 (patch)
treef2af21f91b7b55cf2da24c75ec83c8631e3dc344
parent69507caa4015d0e1ec4b39e59782eb9283dcaa13 (diff)
parent582d32b7d1acec818e4c225fa0ecd528125d8193 (diff)
downloadbarebox-next.tar.gz
Merge branch 'for-next/misc' into nextnext
-rw-r--r--Documentation/user/driver-model.rst9
-rw-r--r--Documentation/user/state.rst6
-rw-r--r--arch/arm/configs/vexpress_defconfig2
-rw-r--r--commands/boot.c13
-rw-r--r--commands/readlink.c2
-rw-r--r--commands/setenv.c10
-rw-r--r--common/Kconfig19
-rw-r--r--common/Makefile2
-rw-r--r--common/blspec.c3
-rw-r--r--common/boot.c12
-rw-r--r--common/bootm.c2
-rw-r--r--common/env.c12
-rw-r--r--common/globalvar.c12
-rw-r--r--common/machine_id.c4
-rw-r--r--drivers/mtd/nand/nand_imx.c2
-rw-r--r--drivers/usb/gadget/f_fastboot.c48
-rw-r--r--drivers/video/fb.c21
-rw-r--r--fs/fs.c2
-rw-r--r--include/environment.h5
-rw-r--r--net/ifup.c2
20 files changed, 114 insertions, 74 deletions
diff --git a/Documentation/user/driver-model.rst b/Documentation/user/driver-model.rst
index a0fd3e9..c543d6d 100644
--- a/Documentation/user/driver-model.rst
+++ b/Documentation/user/driver-model.rst
@@ -88,7 +88,14 @@ The parameters can be used as shell variables:
.. code-block:: sh
eth0.ipaddr=192.168.23.15
- echo "my current ip is: $eth0.ipaddr"
+ echo "my current ip is: ${eth0.ipaddr}"
+
+.. note::
+
+ Hush shell syntax for defining and setting variables is the same, so
+ some characters such as hyphens are not allowed on the left hand side
+ of a shell variable assignment. :ref:`command_setenv`, if enabled,
+ can still be used to write such a variable though.
device variables may have a type, so assigning wrong values may fail:
diff --git a/Documentation/user/state.rst b/Documentation/user/state.rst
index 78ce24f..54aa396 100644
--- a/Documentation/user/state.rst
+++ b/Documentation/user/state.rst
@@ -684,9 +684,9 @@ Frontend
--------
As frontend a *state* instance is a regular barebox device which has
-device parameters for the *state* variables. With this the variables can
+:ref:`device_parameters` for the *state* variables. With this the variables can
be accessed like normal shell variables. The ``state`` command is used
to save/restore a *state* variable set to the backend device.
-After initializing the variable can be accessed with ``$state.foo``.
-``state -s`` stores the *state* to the backend device.
+After initializing the variable can be accessed with ``${state.foo}`` or
+:ref:`command_setenv`. ``state -s`` stores the *state* to the backend device.
diff --git a/arch/arm/configs/vexpress_defconfig b/arch/arm/configs/vexpress_defconfig
index caa9f51..f17af2b 100644
--- a/arch/arm/configs/vexpress_defconfig
+++ b/arch/arm/configs/vexpress_defconfig
@@ -1,4 +1,6 @@
CONFIG_ARCH_VEXPRESS=y
+CONFIG_MACH_VIRT=y
+CONFIG_MACH_VEXPRESS=y
CONFIG_AEABI=y
CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
CONFIG_MALLOC_SIZE=0x0
diff --git a/commands/boot.c b/commands/boot.c
index d7795bd..18f4e36 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -97,19 +97,16 @@ static int do_boot(int argc, char *argv[])
if (list_empty(&entries->entries)) {
printf("Nothing bootable found\n");
- return COMMAND_ERROR;
- }
-
- if (do_list) {
- bootsources_list(entries);
+ ret = COMMAND_ERROR;
goto out;
}
- if (do_menu) {
+ if (do_list)
+ bootsources_list(entries);
+ else if (do_menu)
bootsources_menu(entries, timeout);
- goto out;
- }
+ ret = 0;
out:
bootentries_free(entries);
free(freep);
diff --git a/commands/readlink.c b/commands/readlink.c
index fdcf175..81ad25c 100644
--- a/commands/readlink.c
+++ b/commands/readlink.c
@@ -50,7 +50,7 @@ static int do_readlink(int argc, char *argv[])
return 0;
err:
- setenv(argv[optind + 1], "");
+ unsetenv(argv[optind + 1]);
return 1;
}
diff --git a/commands/setenv.c b/commands/setenv.c
index ad26770..9aeb8f0 100644
--- a/commands/setenv.c
+++ b/commands/setenv.c
@@ -10,6 +10,7 @@
static int do_setenv(int argc, char *argv[])
{
char *equal;
+ int ret;
if (argc < 2)
return COMMAND_ERROR_USAGE;
@@ -17,12 +18,15 @@ static int do_setenv(int argc, char *argv[])
equal = strrchr(argv[1], '=');
if (equal) {
equal[0] = '\0';
- if (equal[1])
- argv[2] = &equal[1];
+ argv[2] = &equal[1];
}
+ if (argv[2])
+ ret = setenv(argv[1], argv[2]);
+ else
+ ret = unsetenv(argv[1]);
- return setenv(argv[1], argv[2]) ? COMMAND_ERROR : COMMAND_SUCCESS;
+ return ret ? COMMAND_ERROR : COMMAND_SUCCESS;
}
BAREBOX_CMD_HELP_START(setenv)
diff --git a/common/Kconfig b/common/Kconfig
index 9b73aa8..ffdce2f 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -989,19 +989,20 @@ config RESET_SOURCE
useful for any kind of system recovery or repair.
config MACHINE_ID
- bool "pass machine-id to kernel"
+ bool "compute unique machine-id"
depends on FLEXIBLE_BOOTARGS
depends on SHA1
help
- Sets the linux.bootargs.machine_id global variable with a value of
- systemd.machine_id=UID. The UID is a persistent device-specific
- id. It is a hash over device-specific information provided by various
- sources.
+ Compute a persistent machine-specific id and store it to $global.machine_id.
+ The id is a hash of device-specific information added via
+ machine_id_set_hashable(). If multiple sources are available, the
+ information provided by the last call prior to the late initcall
+ set_machine_id() is used to generate the machine id from. Thus when
+ updating barebox the machine id might change.
- Note: if multiple sources provide hashable device-specific information
- (via machine_id_set_hashable()) the information provided by the last call
- prior to the late initcall set_machine_id() is used to generate the
- machine id from. Thus when updating barebox the machine id might change.
+ global.bootm.provide_machine_id may be used to automatically set
+ the linux.bootargs.machine_id global variable with a value of
+ systemd.machine_id=${global.machine_id}
Note: if no hashable information is available no machine id will be passed
to the kernel.
diff --git a/common/Makefile b/common/Makefile
index c3ae3ca..0e0ba38 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -100,7 +100,7 @@ endif # CONFIG_PASSWORD
# dependencies on generated files need to be listed explicitly
$(obj)/version.o: include/generated/compile.h
$(obj)/imd-barebox.o: include/generated/compile.h
-$(obj)/pbl-imd-barebox.o: include/generated/compile.h
+$(obj)/imd-barebox.pbl.o: include/generated/compile.h
# compile.h changes depending on hostname, generation number, etc,
# so we regenerate it always.
diff --git a/common/blspec.c b/common/blspec.c
index a07343f..4e4ad29 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -649,7 +649,8 @@ int blspec_scan_directory(struct bootentries *bootentries, const char *root)
hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
}
- entry->entry.title = xstrdup(blspec_entry_var_get(entry, "title"));
+ entry->entry.title = xasprintf("%s (%s)", blspec_entry_var_get(entry, "title"),
+ configname);
entry->entry.description = basprintf("blspec entry, device: %s hwdevice: %s",
devname ? devname : "none",
hwdevname ? hwdevname : "none");
diff --git a/common/boot.c b/common/boot.c
index 90d504e..c6ec228 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -9,22 +9,19 @@
* General Public License for more details.
*/
-#include <environment.h>
-#include <bootchooser.h>
+#include <boot.h>
#include <globalvar.h>
#include <magicvar.h>
#include <watchdog.h>
#include <command.h>
#include <readkey.h>
#include <common.h>
-#include <blspec.h>
#include <libgen.h>
-#include <malloc.h>
#include <bootm.h>
#include <glob.h>
#include <init.h>
#include <menu.h>
-#include <fs.h>
+#include <unistd.h>
#include <linux/stat.h>
@@ -354,11 +351,10 @@ void bootsources_list(struct bootentries *bootentries)
{
struct bootentry *entry;
- printf("%-20s\n", "title");
- printf("%-20s\n", "------");
+ printf("title\n------\n");
bootentries_for_each_entry(bootentries, entry)
- printf("%-20s %s\n", entry->title, entry->description);
+ printf("%s\n\t%s\n", entry->title, entry->description);
}
BAREBOX_MAGICVAR(global.boot.default, "default boot order");
diff --git a/common/bootm.c b/common/bootm.c
index f70ef10..59efc61 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -856,4 +856,4 @@ BAREBOX_MAGICVAR(global.bootm.verify, "bootm default verify level");
BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)");
BAREBOX_MAGICVAR(global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from (default, device can be overridden via global.bootm.root_dev)");
BAREBOX_MAGICVAR(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
-BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value of global.machine_id to Kernel");
+BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
diff --git a/common/env.c b/common/env.c
index fbaaac4..2830551 100644
--- a/common/env.c
+++ b/common/env.c
@@ -251,15 +251,21 @@ static int dev_setenv(const char *name, const char *val)
return -ENODEV;
}
+/**
+ * setenv - set environment variables
+ * @_name - Variable name
+ * @value - the value to set, empty string not handled specially
+ *
+ * Returns 0 for success and a negative error code otherwise
+ * Use unsetenv() to unset.
+ */
+
int setenv(const char *_name, const char *value)
{
char *name = strdup(_name);
int ret = 0;
struct list_head *list;
- if (value && !*value)
- value = NULL;
-
if (strchr(name, '.')) {
ret = dev_setenv(name, value);
if (ret)
diff --git a/common/globalvar.c b/common/globalvar.c
index 60793d7..a55b38b 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -179,16 +179,12 @@ static int nv_set(struct device_d *dev, struct param_d *p, const char *name, con
{
int ret;
- if (!val) {
- if (p)
- free(p->value);
- return 0;
+ if (val) {
+ ret = dev_set_param(&global_device, name, val);
+ if (ret)
+ return ret;
}
- ret = dev_set_param(&global_device, name, val);
- if (ret)
- return ret;
-
if (p) {
free(p->value);
p->value = xstrdup(val);
diff --git a/common/machine_id.c b/common/machine_id.c
index c1309cc..6480806 100644
--- a/common/machine_id.c
+++ b/common/machine_id.c
@@ -24,7 +24,7 @@ void machine_id_set_hashable(const void *hashable, size_t len)
__machine_id_hashable_length = len;
}
-static int machine_id_set_bootarg(void)
+static int machine_id_set_globalvar(void)
{
struct digest *digest = NULL;
unsigned char machine_id[SHA1_DIGEST_SIZE];
@@ -64,6 +64,6 @@ out:
return ret;
}
-late_initcall(machine_id_set_bootarg);
+late_initcall(machine_id_set_globalvar);
BAREBOX_MAGICVAR(global.machine_id, "Persistent device-specific, hexadecimal, 32-character id");
diff --git a/drivers/mtd/nand/nand_imx.c b/drivers/mtd/nand/nand_imx.c
index 3d4082f..0f20e9d 100644
--- a/drivers/mtd/nand/nand_imx.c
+++ b/drivers/mtd/nand/nand_imx.c
@@ -1022,7 +1022,7 @@ static void imx_nand_command(struct nand_chip *chip, unsigned command,
*/
if (command == NAND_CMD_READOOB) {
host->send_page(host, NFC_OUTPUT);
- copy_spare(mtd, 1, host->data_buf + mtd->writesize);
+ copy_spare(chip, 1, host->data_buf + mtd->writesize);
}
break;
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index da3e0c7..96924c4 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -207,34 +207,43 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
ret = fastboot_generic_init(&f_fb->fastboot, opts->common.export_bbu);
if (ret)
- return ret;
+ goto err_wq_unregister;
/* DYNAMIC interface numbers assignments */
id = usb_interface_id(c, f);
- if (id < 0)
- return id;
+ if (id < 0) {
+ ret = id;
+ goto fb_generic_free;
+ }
+
interface_desc.bInterfaceNumber = id;
id = usb_string_id(c->cdev);
- if (id < 0)
- return id;
+ if (id < 0) {
+ ret = id;
+ goto fb_generic_free;
+ }
fastboot_string_defs[0].id = id;
interface_desc.iInterface = id;
us = usb_gstrings_attach(cdev, fastboot_strings, 1);
if (IS_ERR(us)) {
ret = PTR_ERR(us);
- return ret;
+ goto fb_generic_free;
}
f_fb->in_ep = usb_ep_autoconfig(gadget, &fs_ep_in);
- if (!f_fb->in_ep)
- return -ENODEV;
+ if (!f_fb->in_ep) {
+ ret = -ENODEV;
+ goto fb_generic_free;
+ }
f_fb->in_ep->driver_data = c->cdev;
f_fb->out_ep = usb_ep_autoconfig(gadget, &fs_ep_out);
- if (!f_fb->out_ep)
- return -ENODEV;
+ if (!f_fb->out_ep) {
+ ret = -ENODEV;
+ goto fb_generic_free;
+ }
f_fb->out_ep->driver_data = c->cdev;
hs_ep_out.bEndpointAddress = fs_ep_out.bEndpointAddress;
@@ -244,7 +253,7 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
if (!f_fb->out_req) {
puts("failed to alloc out req\n");
ret = -EINVAL;
- return ret;
+ goto fb_generic_free;
}
f_fb->out_req->complete = rx_handler_command;
@@ -254,15 +263,28 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
if (!f_fb->in_req) {
puts("failed alloc req in\n");
ret = -EINVAL;
- return ret;
+ goto err_free_out_req;
}
f_fb->in_req->complete = fastboot_complete;
ret = usb_assign_descriptors(f, fb_fs_descs, fb_hs_descs, NULL);
if (ret)
- return ret;
+ goto err_free_in_req;
return 0;
+
+err_free_in_req:
+ free(f_fb->in_req->buf);
+ usb_ep_free_request(f_fb->in_ep, f_fb->in_req);
+err_free_out_req:
+ free(f_fb->out_req->buf);
+ usb_ep_free_request(f_fb->out_ep, f_fb->out_req);
+fb_generic_free:
+ fastboot_generic_free(&f_fb->fastboot);
+err_wq_unregister:
+ wq_unregister(&f_fb->wq);
+
+ return ret;
}
static void fastboot_unbind(struct usb_configuration *c, struct usb_function *f)
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 2d82bc0..113c141 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -119,22 +119,25 @@ int fb_disable(struct fb_info *info)
return 0;
}
+static int fb_enable_get(struct param_d *param, void *priv)
+{
+ struct fb_info *info = priv;
+
+ info->p_enable = info->enabled;
+ return 0;
+}
+
static int fb_enable_set(struct param_d *param, void *priv)
{
struct fb_info *info = priv;
- int enable;
if (!info->mode)
return -EINVAL;
- enable = info->p_enable;
-
- if (enable)
- fb_enable(info);
+ if (info->p_enable)
+ return fb_enable(info);
else
- fb_disable(info);
-
- return 0;
+ return fb_disable(info);
}
static struct fb_videomode *fb_num_to_mode(struct fb_info *info, int num)
@@ -314,7 +317,7 @@ int register_framebuffer(struct fb_info *info)
if (ret)
goto err_free;
- dev_add_param_bool(dev, "enable", fb_enable_set, NULL,
+ dev_add_param_bool(dev, "enable", fb_enable_set, fb_enable_get,
&info->p_enable, info);
if (IS_ENABLED(CONFIG_DRIVER_VIDEO_EDID))
diff --git a/fs/fs.c b/fs/fs.c
index f41e4b9..00b8645 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3066,7 +3066,7 @@ static int automount_mount(struct dentry *dentry)
setenv("automount_path", am->path);
export("automount_path");
ret = run_command(am->cmd);
- setenv("automount_path", NULL);
+ unsetenv("automount_path");
if (ret) {
printf("running automount command '%s' failed\n",
diff --git a/include/environment.h b/include/environment.h
index 9488e4e..19e522c 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -87,6 +87,11 @@ int env_push_context(void);
int export(const char *);
+static inline int unsetenv(const char *var)
+{
+ return setenv(var, NULL);
+}
+
#endif /* _ENVIRONMENT_H_ */
/**
diff --git a/net/ifup.c b/net/ifup.c
index a740379..1870f74 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -86,7 +86,7 @@ static int source_env_network(struct eth_device *edev)
env_push_context();
for (i = 0; i < ARRAY_SIZE(vars); i++)
- setenv(vars[i], "");
+ unsetenv(vars[i]);
cmd = basprintf("source /env/network/%s", edev->devname);
ret = run_command(cmd);