summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-11-06 16:10:42 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-06 16:10:42 +0100
commit1d9295b344a885e5a79de38df28740a1db6f6103 (patch)
treeca427bbf13a04f3480fb398630473bede4ef6463
parent736a74ba7a1c3983105b92a709c263e206fe3913 (diff)
parent6face0e8ab8d97dcc7284a8a5d7ae1f4d134798f (diff)
downloadbarebox-1d9295b344a885e5a79de38df28740a1db6f6103.tar.gz
barebox-1d9295b344a885e5a79de38df28740a1db6f6103.tar.xz
Merge branch 'for-next/misc'
-rw-r--r--Makefile5
-rw-r--r--arch/arm/Makefile7
-rw-r--r--commands/clk.c59
-rw-r--r--commands/edit.c20
-rw-r--r--commands/loadb.c4
-rw-r--r--commands/memtest.c5
-rw-r--r--commands/of_dump.c21
-rw-r--r--common/command.c2
-rw-r--r--common/filetype.c4
-rw-r--r--common/parser.c18
-rw-r--r--drivers/ata/disk_ata_drive.c17
-rw-r--r--drivers/mci/mci-core.c9
-rw-r--r--drivers/video/fb.c15
-rw-r--r--drivers/video/fbconsole.c3
-rw-r--r--fs/devfs-core.c6
-rw-r--r--fs/devfs.c7
-rw-r--r--fs/fs.c9
-rw-r--r--images/Makefile18
-rw-r--r--include/clock.h3
-rw-r--r--lib/logo/Makefile1
-rwxr-xr-xscripts/checkpatch.pl8
21 files changed, 173 insertions, 68 deletions
diff --git a/Makefile b/Makefile
index 5770f2d3a3..1029dc157d 100644
--- a/Makefile
+++ b/Makefile
@@ -484,6 +484,9 @@ export KBUILD_BINARY ?= barebox.bin
barebox-flash-image: $(KBUILD_IMAGE) FORCE
$(call if_changed,ln)
+barebox-flash-images: $(KBUILD_IMAGE)
+ @echo $^ > $@
+
images: barebox.bin FORCE
$(Q)$(MAKE) $(build)=images $@
images/%.s: barebox.bin FORCE
@@ -492,7 +495,7 @@ images/%.s: barebox.bin FORCE
ifdef CONFIG_PBL_MULTI_IMAGES
all: barebox.bin images
else
-all: barebox-flash-image
+all: barebox-flash-image barebox-flash-images
endif
common-$(CONFIG_PBL_IMAGE) += pbl/
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 721aa9bd9d..cae05ff52b 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -13,6 +13,13 @@ AS += -EL
LD += -EL
endif
+# Unaligned access is not supported when MMU is disabled, so given how
+# at least some of the code would be executed with MMU off, lets be
+# conservative and instruct the compiler not to generate any unaligned
+# accesses
+CFLAGS += -mno-unaligned-access
+
+
# This selects which instruction set is used.
# Note that GCC does not numerically define an architecture version
# macro, but instead defines a whole series of macros which makes
diff --git a/commands/clk.c b/commands/clk.c
index 4e7ca60a29..e9459a3fd3 100644
--- a/commands/clk.c
+++ b/commands/clk.c
@@ -3,6 +3,8 @@
#include <getopt.h>
#include <linux/clk.h>
#include <linux/err.h>
+#include <environment.h>
+#include <malloc.h>
static int do_clk_enable(int argc, char *argv[])
{
@@ -38,7 +40,7 @@ static int do_clk_disable(int argc, char *argv[])
clk_disable(clk);
- return 0;
+ return COMMAND_SUCCESS;
}
BAREBOX_CMD_START(clk_disable)
@@ -77,6 +79,59 @@ BAREBOX_CMD_START(clk_set_rate)
BAREBOX_CMD_HELP(cmd_clk_set_rate_help)
BAREBOX_CMD_END
+static int do_clk_get_rate(int argc, char *argv[])
+{
+ int opt;
+ struct clk *clk;
+ unsigned long rate;
+ const char *variable_name = NULL;
+
+ while ((opt = getopt(argc, argv, "s:")) > 0) {
+ switch (opt) {
+ case 's':
+ variable_name = optarg;
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
+
+ if (optind == argc) {
+ fprintf(stderr, "No clock name given\n");
+ return COMMAND_ERROR_USAGE;
+ }
+
+ clk = clk_lookup(argv[optind]);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ rate = clk_get_rate(clk);
+
+ if (variable_name) {
+ char *t;
+
+ t = asprintf("%lu", rate);
+ setenv(variable_name, t);
+ free(t);
+ } else
+ printf("%lu\n", rate);
+
+ return COMMAND_SUCCESS;
+}
+
+BAREBOX_CMD_HELP_START(clk_get_rate)
+BAREBOX_CMD_HELP_TEXT("Show clock CLK rate")
+BAREBOX_CMD_HELP_OPT("-s VARNAME", "set variable VARNAME instead of showing information")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(clk_get_rate)
+ .cmd = do_clk_get_rate,
+ BAREBOX_CMD_DESC("get a clocks rate")
+ BAREBOX_CMD_OPTS("[-s VARNAME] CLK")
+ BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP)
+ BAREBOX_CMD_HELP(cmd_clk_get_rate_help)
+BAREBOX_CMD_END
+
static int do_clk_dump(int argc, char *argv[])
{
int opt, verbose = 0;
@@ -94,7 +149,7 @@ static int do_clk_dump(int argc, char *argv[])
clk_dump(verbose);
- return 0;
+ return COMMAND_SUCCESS;
}
BAREBOX_CMD_HELP_START(clk_dump)
diff --git a/commands/edit.c b/commands/edit.c
index b28e2b92a1..c014892fc4 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -258,6 +258,7 @@ static int save_file(const char *path)
{
struct line *line, *tmp;
int fd;
+ int ret = 0;
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT);
if (fd < 0) {
@@ -269,12 +270,20 @@ static int save_file(const char *path)
while(line) {
tmp = line->next;
- write(fd, line->data, strlen(line->data));
- write(fd, "\n", 1);
+ ret = write_full(fd, line->data, strlen(line->data));
+ if (ret < 0)
+ goto out;
+ ret = write_full(fd, "\n", 1);
+ if (ret < 0)
+ goto out;
line = tmp;
}
+
+ ret = 0;
+
+out:
close(fd);
- return 0;
+ return ret;
}
static void insert_char(char c)
@@ -375,6 +384,7 @@ static int do_edit(int argc, char *argv[])
int i;
int linepos;
int c;
+ int ret = COMMAND_SUCCESS;
if (argc != 2)
return COMMAND_ERROR_USAGE;
@@ -533,7 +543,7 @@ static int do_edit(int argc, char *argv[])
}
break;
case 4:
- save_file(argv[1]);
+ ret = save_file(argv[1]);
goto out;
case 3:
goto out;
@@ -546,7 +556,7 @@ out:
free_buffer();
printf("%c[2J%c[r", 27, 27);
printf("\n");
- return 0;
+ return ret;
}
static const char *edit_aliases[] = { "sedit", NULL};
diff --git a/commands/loadb.c b/commands/loadb.c
index be5830da32..aabb00ab20 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -681,9 +681,9 @@ static int do_load_serial_bin(int argc, char *argv[])
BAREBOX_CMD_HELP_START(loadb)
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT("-f FILE", "download to FILE (default image.bin")
+BAREBOX_CMD_HELP_OPT("-f FILE", "download to FILE (default image.bin)")
BAREBOX_CMD_HELP_OPT("-o OFFS", "destination file OFFSet (default 0)")
-BAREBOX_CMD_HELP_OPT("-b BAUD", "baudrate for download (default: console baudrate")
+BAREBOX_CMD_HELP_OPT("-b BAUD", "baudrate for download (default: console baudrate)")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(loadb)
diff --git a/commands/memtest.c b/commands/memtest.c
index 691b388907..d784a5c0e2 100644
--- a/commands/memtest.c
+++ b/commands/memtest.c
@@ -129,8 +129,11 @@ static int do_memtest(int argc, char *argv[])
goto out;
for (i = 1; (i <= max_i) || !max_i; i++) {
+ printf("Start iteration %u", i);
if (max_i)
- printf("Start iteration %u of %u.\n", i, max_i);
+ printf(" of %u.\n", max_i);
+ else
+ putchar('\n');
if (cached) {
printf("Do memtest with caching enabled.\n");
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 513a4b88a0..b15f54ae04 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -31,6 +31,16 @@
#include <getopt.h>
#include <linux/err.h>
+static void of_print_nodenames(struct device_node *node)
+{
+ struct device_node *n;
+
+ printf("%s\n", node->full_name);
+
+ list_for_each_entry(n, &node->children, parent_list)
+ of_print_nodenames(n);
+}
+
static int do_of_dump(int argc, char *argv[])
{
int opt;
@@ -40,8 +50,9 @@ static int do_of_dump(int argc, char *argv[])
char *dtbfile = NULL;
size_t size;
const char *nodename;
+ int names_only = 0;
- while ((opt = getopt(argc, argv, "Ff:")) > 0) {
+ while ((opt = getopt(argc, argv, "Ff:n")) > 0) {
switch (opt) {
case 'f':
dtbfile = optarg;
@@ -49,6 +60,9 @@ static int do_of_dump(int argc, char *argv[])
case 'F':
fix = 1;
break;
+ case 'n':
+ names_only = 1;
+ break;
default:
return COMMAND_ERROR_USAGE;
}
@@ -111,7 +125,10 @@ static int do_of_dump(int argc, char *argv[])
goto out;
}
- of_print_nodes(node, 0);
+ if (names_only)
+ of_print_nodenames(node);
+ else
+ of_print_nodes(node, 0);
out:
if (of_free)
diff --git a/common/command.c b/common/command.c
index dc2cb88eaf..03c70834d1 100644
--- a/common/command.c
+++ b/common/command.c
@@ -83,7 +83,7 @@ int execute_command(int argc, char **argv)
#else
printf ("Unknown command '%s'\n", argv[0]);
#endif
- ret = 1; /* give up after bad command */
+ ret = COMMAND_ERROR; /* give up after bad command */
}
getopt_context_restore(&gc);
diff --git a/common/filetype.c b/common/filetype.c
index dc2ff3f5f0..9ec8ebf7c2 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -369,9 +369,10 @@ enum filetype cdev_detect_type(const char *name)
struct cdev *cdev;
void *buf;
- cdev = cdev_by_name(name);
+ cdev = cdev_open(name, O_RDONLY);
if (!cdev)
return type;
+
buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE);
ret = cdev_read(cdev, buf, FILE_TYPE_SAFE_BUFSIZE, 0, 0);
if (ret < 0)
@@ -396,5 +397,6 @@ enum filetype cdev_detect_type(const char *name)
err_out:
free(buf);
+ cdev_close(cdev);
return type;
}
diff --git a/common/parser.c b/common/parser.c
index ed414d04ea..6136dbf36f 100644
--- a/common/parser.c
+++ b/common/parser.c
@@ -253,7 +253,8 @@ int run_command(const char *cmd)
continue;
}
- rc = execute_command(argc, argv);
+ if (execute_command(argc, argv) != COMMAND_SUCCESS)
+ rc = -1;
}
return rc;
@@ -265,7 +266,6 @@ int run_shell(void)
{
static char lastcommand[CONFIG_CBSIZE] = { 0, };
int len;
- int rc = 1;
login();
@@ -275,14 +275,14 @@ int run_shell(void)
if (len > 0)
strcpy (lastcommand, console_buffer);
- if (len == -1)
+ if (len == -1) {
puts ("<INTERRUPT>\n");
- else
- rc = run_command(lastcommand);
-
- if (rc <= 0) {
- /* invalid command or not repeatable, forget it */
- lastcommand[0] = 0;
+ } else {
+ const int rc = run_command(lastcommand);
+ if (rc < 0) {
+ /* invalid command or not repeatable, forget it */
+ lastcommand[0] = 0;
+ }
}
}
return 0;
diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index ee1709e2ff..d30d0ad997 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -26,16 +26,6 @@
#include <disks.h>
#include <dma.h>
-static int ata_id_is_valid(const uint16_t *id)
-{
- if ((id[ATA_ID_FIELD_VALID] & 1) == 0) {
- pr_debug("Drive's ID seems invalid\n");
- return -EINVAL;
- }
-
- return 0;
-}
-
static uint64_t ata_id_n_sectors(uint16_t *id)
{
if (ata_id_has_lba(id)) {
@@ -244,13 +234,6 @@ static int ata_port_init(struct ata_port *port)
ata_fix_endianess(port->id, SECTOR_SIZE / sizeof(uint16_t));
- rc = ata_id_is_valid(port->id);
- if (rc) {
- dev_err(dev, "ata id invalid\n");
- free(port->id);
- return rc;
- }
-
#ifdef DEBUG
ata_dump_id(port->id);
#endif
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 90001153d7..29c0d5474e 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -947,14 +947,13 @@ out:
static char *mci_version_string(struct mci *mci)
{
static char version[sizeof("x.xx")];
- unsigned major, minor, micro;
+ unsigned major, minor;
major = (mci->version >> 8) & 0xf;
- minor = (mci->version >> 4) & 0xf;
- micro = mci->version & 0xf;
+ minor = mci->version & 0xff;
- sprintf(version, "%u.%u", major,
- micro ? (minor << 4) | micro : minor);
+ /* Shift off last digit of minor if it's 0 */
+ sprintf(version, "%u.%x", major, minor & 0xf ? minor : minor >> 4);
return version;
}
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 3672c44202..d159d607f5 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -31,6 +31,12 @@ static int fb_ioctl(struct cdev* cdev, int req, void *data)
return 0;
}
+static void fb_release_shadowfb(struct fb_info *info)
+{
+ free(info->screen_base_shadow);
+ info->screen_base_shadow = NULL;
+}
+
static int fb_alloc_shadowfb(struct fb_info *info)
{
if (info->screen_base_shadow && info->shadowfb)
@@ -47,8 +53,7 @@ static int fb_alloc_shadowfb(struct fb_info *info)
memcpy(info->screen_base_shadow, info->screen_base,
info->line_length * info->yres);
} else {
- free(info->screen_base_shadow);
- info->screen_base_shadow = NULL;
+ fb_release_shadowfb(info);
}
return 0;
@@ -79,6 +84,8 @@ int fb_disable(struct fb_info *info)
info->fbops->fb_disable(info);
+ fb_release_shadowfb(info);
+
info->enabled = false;
return 0;
@@ -92,9 +99,9 @@ static int fb_enable_set(struct param_d *param, void *priv)
enable = info->p_enable;
if (enable)
- info->fbops->fb_enable(info);
+ fb_enable(info);
else
- info->fbops->fb_disable(info);
+ fb_disable(info);
return 0;
}
diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
index b10503eb84..c38d13c304 100644
--- a/drivers/video/fbconsole.c
+++ b/drivers/video/fbconsole.c
@@ -192,8 +192,9 @@ static void printchar(struct fbc_priv *priv, int c)
buf = gui_screen_render_buffer(priv->sc);
- memcpy(buf, buf + line_height, line_height * (priv->rows + 1));
+ memcpy(buf, buf + line_height, line_height * priv->rows);
memset(buf + line_height * priv->rows, 0, line_height);
+
gu_screen_blit(priv->sc);
priv->y = priv->rows;
}
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 62571fb8a3..2541ea36e6 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -121,9 +121,13 @@ int cdev_do_open(struct cdev *cdev, unsigned long flags)
struct cdev *cdev_open(const char *name, unsigned long flags)
{
- struct cdev *cdev = cdev_by_name(name);
+ struct cdev *cdev;
int ret;
+ if (!strncmp(name, "/dev/", 5))
+ name += 5;
+
+ cdev = cdev_by_name(name);
if (!cdev)
return NULL;
diff --git a/fs/devfs.c b/fs/devfs.c
index c6db25cb14..5c96682f96 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -228,6 +228,13 @@ static int devfs_stat(struct device_d *_dev, const char *filename, struct stat *
static int devfs_probe(struct device_d *dev)
{
+ struct fs_device_d *fsdev = dev_to_fs_device(dev);
+
+ if (strcmp(fsdev->path, "/dev")) {
+ dev_err(dev, "devfs can only be mounted on /dev/\n");
+ return -EINVAL;
+ }
+
return 0;
}
diff --git a/fs/fs.c b/fs/fs.c
index c2a20e17d7..4983fc7ec1 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1205,8 +1205,6 @@ static const char *detect_fs(const char *filename)
struct driver_d *drv;
struct fs_driver_d *fdrv;
- if (!strncmp(filename, "/dev/", 5))
- filename += 5;
type = cdev_detect_type(filename);
if (type == filetype_unknown)
@@ -1224,12 +1222,7 @@ static const char *detect_fs(const char *filename)
int fsdev_open_cdev(struct fs_device_d *fsdev)
{
- const char *backingstore = fsdev->backingstore;
-
- if (!strncmp(backingstore , "/dev/", 5))
- backingstore += 5;
-
- fsdev->cdev = cdev_open(backingstore, O_RDWR);
+ fsdev->cdev = cdev_open(fsdev->backingstore, O_RDWR);
if (!fsdev->cdev)
return -EINVAL;
diff --git a/images/Makefile b/images/Makefile
index a5f589b303..6a44511215 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -121,10 +121,26 @@ targets += $(foreach m, $(image-y), $(FILE_$(m)))
SECONDARY: $(addprefix $(obj)/,$(targets))
-images: $(addprefix $(obj)/, $(image-y)) FORCE
+# Images with full paths
+image-y-path := $(addprefix $(obj)/,$(image-y))
+# File will have a list of images generated
+flash-list := $(obj)/../barebox-flash-images
+# Symlink, which will point to non-existent 'multi-image-build' if there are
+# multiple images
+flash-link := $(obj)/../barebox-flash-image
+link-dest := $(if $(filter 1,$(words $(image-y))),$(image-y-path),multi-image-build)
+multi-image-build:
+
+images: $(image-y-path) $(flash-link) $(flash-list) FORCE
@echo "images built:"
@for i in $(image-y); do echo $$i; done
+$(flash-link): $(link-dest) FORCE
+ $(call if_changed,ln)
+
+$(flash-list): $(image-y-path)
+ @for i in $^; do echo $$i; done > $@
+
clean-files := *.pbl *.pblb *.pblx *.map start_*.imximg *.img barebox.z start_*.kwbimg \
start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg *.t30img \
*.t30img.cfg *.t124img *.t124img.cfg *.mlospi *.mlo *.mxsbs *.mxssd
diff --git a/include/clock.h b/include/clock.h
index 7f0f1eccc4..d65e404e86 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -1,8 +1,7 @@
-#include <types.h>
-
#ifndef CLOCK_H
#define CLOCK_H
+#include <types.h>
#include <linux/time.h>
#define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
diff --git a/lib/logo/Makefile b/lib/logo/Makefile
index f5f229f8fd..eb7aee080e 100644
--- a/lib/logo/Makefile
+++ b/lib/logo/Makefile
@@ -41,7 +41,6 @@ cmd_logo_S = \
quiet_cmd_logo = LOGO.S $@
cmd_logo = \
( \
- echo OPTS: $(OPTS_$(@F)); \
inkscape -z $(OPTS_$(@F)) -e $@ $< > /dev/null; \
)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8d96434650..f3fd3395f1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2013,8 +2013,8 @@ sub process {
# function brace can't be on same line, except for #defines of do while,
# or if closed on same line
- if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
- !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
+ if (($line=~/$Type\s*$Ident\(.*\).*\s\{/) and
+ !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) {
ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
}
@@ -2264,8 +2264,8 @@ sub process {
## }
#need space before brace following if, while, etc
- if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
- $line =~ /do{/) {
+ if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\){/) ||
+ $line =~ /do\{/) {
ERROR("space required before the open brace '{'\n" . $herecurr);
}