9
0
Fork 0

Merge branch 'for-next/misc'

This commit is contained in:
Sascha Hauer 2015-11-06 16:10:42 +01:00
commit 1d9295b344
21 changed files with 173 additions and 68 deletions

View File

@ -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/

View File

@ -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

View File

@ -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)

View File

@ -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};

View File

@ -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)

View File

@ -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");

View File

@ -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)

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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; \
)

View File

@ -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);
}