diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-05-05 11:31:34 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-05-05 11:31:34 +0200 |
commit | e63f9a85226b1520a5881da7e7fef82446deb879 (patch) | |
tree | cdc1d521e9338d24af1c0a98c6177587a771b33e | |
parent | 337bf5f7eb243fb909f045950e8b6f402e5a0f8e (diff) | |
parent | b876c2b7394f9d5258e6b73f684741c88fa41f23 (diff) | |
download | barebox-e63f9a85226b1520a5881da7e7fef82446deb879.tar.gz barebox-e63f9a85226b1520a5881da7e7fef82446deb879.tar.xz |
Merge branch 'for-next/misc'
-rw-r--r-- | commands/spd_decode.c | 1 | ||||
-rw-r--r-- | common/dlmalloc.c | 3 | ||||
-rw-r--r-- | common/dummy_malloc.c | 4 | ||||
-rw-r--r-- | common/globalvar.c | 2 | ||||
-rw-r--r-- | common/state/backend_bucket_circular.c | 1 | ||||
-rw-r--r-- | drivers/eeprom/at24.c | 4 | ||||
-rw-r--r-- | drivers/eeprom/at25.c | 2 | ||||
-rw-r--r-- | drivers/mci/mci-core.c | 11 | ||||
-rw-r--r-- | drivers/net/dm9k.c | 2 | ||||
-rw-r--r-- | drivers/net/rtl8139.c | 4 | ||||
-rw-r--r-- | drivers/of/base.c | 14 | ||||
-rw-r--r-- | drivers/of/of_net.c | 20 | ||||
-rw-r--r-- | drivers/spi/spi.c | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 3 | ||||
-rw-r--r-- | drivers/video/of_display_timing.c | 19 | ||||
-rw-r--r-- | lib/readline_simple.c | 13 | ||||
-rw-r--r-- | lib/strtox.c | 54 | ||||
-rw-r--r-- | lib/xfuncs.c | 32 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/mkmakefile | 36 |
19 files changed, 117 insertions, 116 deletions
diff --git a/commands/spd_decode.c b/commands/spd_decode.c index 2bedcf05c5..08b9589622 100644 --- a/commands/spd_decode.c +++ b/commands/spd_decode.c @@ -59,5 +59,6 @@ BAREBOX_CMD_START(spd_decode) .cmd = do_spd_decode, BAREBOX_CMD_DESC("Decode SPD EEPROM") BAREBOX_CMD_OPTS("FILE") + BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) BAREBOX_CMD_HELP(cmd_spd_decode_help) BAREBOX_CMD_END diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 499ec93c28..9c33cc2c95 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1753,7 +1753,6 @@ void *calloc(size_t n, size_t elem_size) /* Utility to update current_mallinfo for malloc_stats and mallinfo() */ -#ifdef CONFIG_CMD_MEMINFO static void malloc_update_mallinfo(void) { int i; @@ -1821,8 +1820,6 @@ void malloc_stats(void) #endif } -#endif /* CONFIG_CMD_MEMINFO */ - /* History: diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c index dd36a5b156..641baa125a 100644 --- a/common/dummy_malloc.c +++ b/common/dummy_malloc.c @@ -24,6 +24,10 @@ #include <common.h> #include <malloc.h> +void malloc_stats(void) +{ +} + void *memalign(size_t alignment, size_t bytes) { unsigned long mem = (unsigned long)sbrk(bytes + alignment); diff --git a/common/globalvar.c b/common/globalvar.c index 1ecf5134af..ff52c9d47f 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -19,7 +19,7 @@ struct device_d global_device = { .id = DEVICE_ID_SINGLE, }; -struct device_d nv_device = { +static struct device_d nv_device = { .name = "nv", .id = DEVICE_ID_SINGLE, }; diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 832f44e599..7c81cdfaff 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -72,7 +72,6 @@ struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta { }; static const uint32_t circular_magic = 0x14fa2d02; -static const uint8_t free_pattern = 0xff; static inline struct state_backend_storage_bucket_circular *get_bucket_circular(struct state_backend_storage_bucket *bucket) diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index 1227286fbe..050a35aed8 100644 --- a/drivers/eeprom/at24.c +++ b/drivers/eeprom/at24.c @@ -454,6 +454,10 @@ static int at24_probe(struct device_d *dev) at24->cdev.size = chip.byte_len; writable = !(chip.flags & AT24_FLAG_READONLY); + + if (of_get_property(dev->device_node, "read-only", NULL)) + writable = 0; + if (writable) { unsigned write_max = chip.page_size; diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c index 1caaebd371..9f16f964a8 100644 --- a/drivers/eeprom/at25.c +++ b/drivers/eeprom/at25.c @@ -290,7 +290,7 @@ static int at25_np_to_chip(struct device_d *dev, val); return -ENODEV; } - if (of_find_property(np, "read-only", NULL)) + if (of_property_read_bool(np, "read-only")) chip->flags |= EE_READONLY; } return 0; diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index b173a173b1..3da1c261a9 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -984,7 +984,7 @@ static int mci_startup_sd(struct mci *mci) mci_setup_cmd(&cmd, SD_CMD_APP_SET_BUS_WIDTH, 2, MMC_RSP_R1); err = mci_send_cmd(mci, &cmd, NULL); if (err) { - dev_dbg(&mci->dev, "Changing SD bus width failed: %d\n", err); + dev_warn(&mci->dev, "Changing SD bus width failed: %d\n", err); /* TODO continue with 1 bit? */ return err; } @@ -1041,8 +1041,11 @@ static int mci_startup_mmc(struct mci *mci) err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, ext_csd_bits[idx]); - if (err) + if (err) { + if (idx == 0) + dev_warn(&mci->dev, "Changing MMC bus width failed: %d\n", err); continue; + } mci_set_bus_width(mci, bus_widths[idx]); @@ -1051,7 +1054,7 @@ static int mci_startup_mmc(struct mci *mci) break; } - return 0; + return err; } /** @@ -1693,7 +1696,7 @@ static int mci_card_probe(struct mci *mci) rc = mci_startup(mci); if (rc) { - dev_dbg(&mci->dev, "Card's startup fails with %d\n", rc); + dev_warn(&mci->dev, "Card's startup fails with %d\n", rc); goto on_error; } diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c index 25f08602f6..c99d188ded 100644 --- a/drivers/net/dm9k.c +++ b/drivers/net/dm9k.c @@ -737,7 +737,7 @@ static int dm9000_parse_dt(struct device_d *dev, struct dm9k *priv) if (!IS_ENABLED(CONFIG_OFDEVICE) || !np) return -ENODEV; - if (of_find_property(np, "davicom,no-eeprom", NULL)) { + if (of_property_read_bool(np, "davicom,no-eeprom")) { priv->srom = 0; } else { priv->srom = 1; diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index a9eb865358..cfa34a2f2a 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -492,10 +492,6 @@ static int rtl8139_eth_send(struct eth_device *edev, void *packet, return 0; } -static const u16 rtl8139_intr_mask = - PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver | - TxErr | TxOK | RxErr | RxOK; - static int rtl8139_eth_rx(struct eth_device *edev) { struct rtl8139_priv *priv = edev->priv; diff --git a/drivers/of/base.c b/drivers/of/base.c index 6632f4d9dd..c9bdd91810 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1090,19 +1090,14 @@ int of_property_write_u8_array(struct device_node *np, size_t sz) { struct property *prop = of_find_property(np, propname, NULL); - u8 *val; if (prop) of_delete_property(prop); - prop = of_new_property(np, propname, NULL, sizeof(*val) * sz); + prop = of_new_property(np, propname, values, sizeof(*values) * sz); if (!prop) return -ENOMEM; - val = prop->value; - while (sz--) - *val++ = *values++; - return 0; } @@ -1807,12 +1802,7 @@ struct property *of_new_property(struct device_node *node, const char *name, struct property *prop; prop = xzalloc(sizeof(*prop)); - prop->name = strdup(name); - if (!prop->name) { - free(prop); - return NULL; - } - + prop->name = xstrdup(name); prop->length = len; prop->value = xzalloc(len); diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 086573fc1a..9b54e44674 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -77,19 +77,15 @@ EXPORT_SYMBOL_GPL(of_get_phy_mode); */ const void *of_get_mac_address(struct device_node *np) { - struct property *pp; + const void *p; + int len, i; + const char *str[] = { "mac-address", "local-mac-address", "address" }; - pp = of_find_property(np, "mac-address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; - - pp = of_find_property(np, "local-mac-address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; - - pp = of_find_property(np, "address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; + for (i = 0; i < ARRAY_SIZE(str); i++) { + p = of_get_property(np, str[i], &len); + if (p && (len == 6) && is_valid_ether_addr(p)) + return p; + } return NULL; } diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 99412b07e2..5650098a0a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -118,13 +118,13 @@ static void spi_of_register_slaves(struct spi_master *master) chip.name = xstrdup(n->name); chip.bus_num = master->bus_num; /* Mode (clock phase/polarity/etc.) */ - if (of_find_property(n, "spi-cpha", NULL)) + if (of_property_read_bool(n, "spi-cpha")) chip.mode |= SPI_CPHA; - if (of_find_property(n, "spi-cpol", NULL)) + if (of_property_read_bool(n, "spi-cpol")) chip.mode |= SPI_CPOL; - if (of_find_property(n, "spi-cs-high", NULL)) + if (of_property_read_bool(n, "spi-cs-high")) chip.mode |= SPI_CS_HIGH; - if (of_find_property(n, "spi-3wire", NULL)) + if (of_property_read_bool(n, "spi-3wire")) chip.mode |= SPI_3WIRE; of_property_read_u32(n, "spi-max-frequency", &chip.max_speed_hz); diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index ef5f7ec6e0..598637619d 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -758,6 +758,9 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd copy: ret = copy_file(FASTBOOT_TMPFILE, filename, 1); + + unlink(FASTBOOT_TMPFILE); + if (ret) { fastboot_tx_print(f_fb, "FAILwrite partition: %s", strerror(-ret)); return; diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c index 6a5bf62a36..20f9354a18 100644 --- a/drivers/video/of_display_timing.c +++ b/drivers/video/of_display_timing.c @@ -188,22 +188,3 @@ entryfail: return NULL; } EXPORT_SYMBOL_GPL(of_get_display_timings); - -/** - * of_display_timings_exist - check if a display-timings node is provided - * @np: device_node with the timing - **/ -int of_display_timings_exist(struct device_node *np) -{ - struct device_node *timings_np; - - if (!np) - return -EINVAL; - - timings_np = of_parse_phandle(np, "display-timings", 0); - if (!timings_np) - return -EINVAL; - - return 1; -} -EXPORT_SYMBOL_GPL(of_display_timings_exist); diff --git a/lib/readline_simple.c b/lib/readline_simple.c index c2960665fb..c4d3d240e5 100644 --- a/lib/readline_simple.c +++ b/lib/readline_simple.c @@ -57,19 +57,6 @@ int readline (const char *prompt, char *line, int len) col = plen; for (;;) { -#ifdef CONFIG_BOOT_RETRY_TIME - while (!tstc()) { /* while no incoming data */ - if (retry_time >= 0 && get_ticks() > endtime) - return (-2); /* timed out */ - } -#endif - -#ifdef CONFIG_SHOW_ACTIVITY - while (!tstc()) { - extern void show_activity(int arg); - show_activity(0); - } -#endif c = getchar(); /* diff --git a/lib/strtox.c b/lib/strtox.c index cfe61240cc..3bb6b0ef89 100644 --- a/lib/strtox.c +++ b/lib/strtox.c @@ -1,67 +1,75 @@ #include <common.h> #include <linux/ctype.h> -unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) +unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) { - unsigned long result = 0,value; + unsigned long result = 0, value; if (*cp == '0') { cp++; + if ((*cp == 'x') && isxdigit(cp[1])) { base = 16; cp++; } - if (!base) { + + if (!base) base = 8; - } } - if (!base) { + + if (!base) base = 10; - } - while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp) - ? toupper(*cp) : *cp)-'A'+10) < base) { - result = result*base + value; + + while (isxdigit(*cp) && (value = isdigit(*cp) ? + *cp - '0' : toupper(*cp) - 'A' + 10) < base) { + result = result * base + value; cp++; } + if (endp) *endp = (char *)cp; + return result; } EXPORT_SYMBOL(simple_strtoul); -long simple_strtol(const char *cp,char **endp,unsigned int base) +long simple_strtol(const char *cp, char **endp, unsigned int base) { - if(*cp=='-') - return -simple_strtoul(cp+1,endp,base); - return simple_strtoul(cp,endp,base); + if (*cp == '-') + return -simple_strtoul(cp + 1, endp, base); + + return simple_strtoul(cp, endp, base); } EXPORT_SYMBOL(simple_strtol); -unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int base) +unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) { unsigned long long result = 0, value; if (*cp == '0') { cp++; - if ((*cp == 'x') && isxdigit (cp[1])) { + + if ((*cp == 'x') && isxdigit(cp[1])) { base = 16; cp++; } - if (!base) { + + if (!base) base = 8; - } } - if (!base) { + + if (!base) base = 10; - } - while (isxdigit (*cp) && (value = isdigit (*cp) - ? *cp - '0' - : (islower (*cp) ? toupper (*cp) : *cp) - 'A' + 10) < base) { + + while (isxdigit(*cp) && (value = isdigit(*cp) ? + *cp - '0' : toupper(*cp) - 'A' + 10) < base) { result = result * base + value; cp++; } + if (endp) - *endp = (char *) cp; + *endp = (char *)cp; + return result; } EXPORT_SYMBOL(simple_strtoull); diff --git a/lib/xfuncs.c b/lib/xfuncs.c index 1dc2ea92d8..1bcaa5e10e 100644 --- a/lib/xfuncs.c +++ b/lib/xfuncs.c @@ -18,18 +18,30 @@ * GNU General Public License for more details. * */ +#define pr_fmt(fmt) "xfuncs: " fmt #include <common.h> #include <malloc.h> #include <module.h> #include <wchar.h> +static void __noreturn enomem_panic(size_t size) +{ + pr_emerg("out of memory\n"); + if (size) + pr_emerg("Unable to allocate %d bytes\n", size); + + malloc_stats(); + + panic("out of memory"); +} + void *xmalloc(size_t size) { void *p = NULL; if (!(p = malloc(size))) - panic("ERROR: out of memory\n"); + enomem_panic(size); return p; } @@ -40,7 +52,7 @@ void *xrealloc(void *ptr, size_t size) void *p = NULL; if (!(p = realloc(ptr, size))) - panic("ERROR: out of memory\n"); + enomem_panic(size); return p; } @@ -63,7 +75,7 @@ char *xstrdup(const char *s) p = strdup(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic(strlen(s) + 1); return p; } @@ -95,7 +107,8 @@ void* xmemalign(size_t alignment, size_t bytes) { void *p = memalign(alignment, bytes); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic(bytes); + return p; } EXPORT_SYMBOL(xmemalign); @@ -116,7 +129,7 @@ char *xvasprintf(const char *fmt, va_list ap) p = bvasprintf(fmt, ap); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic(0); return p; } EXPORT_SYMBOL(xvasprintf); @@ -139,7 +152,8 @@ wchar_t *xstrdup_wchar(const wchar_t *s) wchar_t *p = strdup_wchar(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic((wcslen(s) + 1) * sizeof(wchar_t)); + return p; } EXPORT_SYMBOL(xstrdup_wchar); @@ -149,7 +163,8 @@ wchar_t *xstrdup_char_to_wchar(const char *s) wchar_t *p = strdup_char_to_wchar(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic((strlen(s) + 1) * sizeof(wchar_t)); + return p; } EXPORT_SYMBOL(xstrdup_char_to_wchar); @@ -159,7 +174,8 @@ char *xstrdup_wchar_to_char(const wchar_t *s) char *p = strdup_wchar_to_char(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic((wcslen(s) + 1) * sizeof(wchar_t)); + return p; } EXPORT_SYMBOL(xstrdup_wchar_to_char); diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 7f9d544f9b..84af27bf0f 100644..100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -11,7 +11,15 @@ test ! -r $2/Makefile -o -O $2/Makefile || exit 0 -echo " GEN $2/Makefile" +# Only overwrite automatically generated Makefiles +# (so we do not overwrite kernel Makefile) +if test -e $2/Makefile && ! grep -q Automatically $2/Makefile +then + exit 0 +fi +if [ "${quiet}" != "silent_" ]; then + echo " GEN $2/Makefile" +fi cat << EOF > $2/Makefile # Automatically generated by $0: don't edit @@ -19,18 +27,26 @@ cat << EOF > $2/Makefile VERSION = $3 PATCHLEVEL = $4 -KERNELSRC := $1 -KERNELOUTPUT := $2 +lastword = \$(word \$(words \$(1)),\$(1)) +makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) -MAKEFLAGS += --no-print-directory +ifeq ("\$(origin V)", "command line") +VERBOSE := \$(V) +endif +ifneq (\$(VERBOSE),1) +Q := @ +endif + +MAKEARGS := -C $1 +MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) -.PHONY: all \$(MAKECMDGOALS) +MAKEFLAGS += --no-print-directory -all: - \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) +.PHONY: __sub-make \$(MAKECMDGOALS) -Makefile:; +__sub-make: + \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS) -\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/: - \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@ +\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make + @: EOF |