diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst b/Documentation/devicetree/bindings/barebox/barebox,state.rst index d1b0627..d507657 100644 --- a/Documentation/devicetree/bindings/barebox/barebox,state.rst +++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst @@ -43,7 +43,7 @@ These are subnodes of a state node each describing a single variable. The node name may end with ``@
``, but the suffix is -sripped from the variable name. +stripped from the variable name. State variables have a type. Currenty supported types are: ``uint8``, ``uint32``, ``enum32``, ``mac`` address or ``string``. Variable length diff --git a/commands/devinfo.c b/commands/devinfo.c index c78efcb..9d5e8b8 100644 --- a/commands/devinfo.c +++ b/commands/devinfo.c @@ -77,13 +77,15 @@ if (dev->num_resources) printf("Resources:\n"); for (i = 0; i < dev->num_resources; i++) { + resource_size_t size; res = &dev->resource[i]; + size = resource_size(res); printf(" num: %d\n", i); if (res->name) printf(" name: %s\n", res->name); - printf(" start: " PRINTF_CONVERSION_RESOURCE "\n" - " size: " PRINTF_CONVERSION_RESOURCE "\n", - res->start, resource_size(res)); + printf(" start: %pa\n" + " size: %pa\n", + &res->start, &size); } if (dev->driver) diff --git a/commands/iomemport.c b/commands/iomemport.c index 5294c13..6d97c57 100644 --- a/commands/iomemport.c +++ b/commands/iomemport.c @@ -22,14 +22,14 @@ static void __print_resources(struct resource *res, int indent) { struct resource *r; + resource_size_t size = resource_size(res); int i; for (i = 0; i < indent; i++) printf(" "); - printf(PRINTF_CONVERSION_RESOURCE " - " PRINTF_CONVERSION_RESOURCE - " (size " PRINTF_CONVERSION_RESOURCE ") %s\n", - res->start, res->end, resource_size(res), res->name); + printf("%pa - %pa (size %pa) %s\n", + &res->start, &res->end, &size, res->name); list_for_each_entry(r, &res->children, sibling) __print_resources(r, indent + 1); diff --git a/common/bootm.c b/common/bootm.c index 1199cb7..79833e0 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -246,7 +246,7 @@ printf(", multifile image %s", data->initrd_part); printf("\n"); done1: - printf("initrd is at " PRINTF_CONVERSION_RESOURCE "-" PRINTF_CONVERSION_RESOURCE "\n", + printf("initrd is at %pa-%pa\n", data->initrd_res->start, data->initrd_res->end); @@ -456,9 +456,9 @@ static void bootm_print_info(struct image_data *data) { if (data->os_res) - printf("OS image is at " PRINTF_CONVERSION_RESOURCE "-" PRINTF_CONVERSION_RESOURCE "\n", - data->os_res->start, - data->os_res->end); + printf("OS image is at %pa-%pa\n", + &data->os_res->start, + &data->os_res->end); else printf("OS image not yet relocated\n"); } diff --git a/common/hush.c b/common/hush.c index 832bc7b..d3f7bf3 100644 --- a/common/hush.c +++ b/common/hush.c @@ -863,29 +863,29 @@ if ((rpipe->r_mode == RES_IN || rpipe->r_mode == RES_FOR) && (rpipe->next == NULL)) { - syntax(); - return 1; + syntax(); + return 1; } if ((rpipe->r_mode == RES_IN && - (rpipe->next->r_mode == RES_IN && - rpipe->next->progs->argv != NULL))|| - (rpipe->r_mode == RES_FOR && - rpipe->next->r_mode != RES_IN)) { - syntax(); - return 1; + (rpipe->next->r_mode == RES_IN && + rpipe->next->progs->argv != NULL))|| + (rpipe->r_mode == RES_FOR && + rpipe->next->r_mode != RES_IN)) { + syntax(); + return 1; } } for (; pi; pi = (flag_restore != 0) ? rpipe : pi->next) { if (pi->r_mode == RES_WHILE || pi->r_mode == RES_UNTIL || - pi->r_mode == RES_FOR) { - /* check Ctrl-C */ - if (ctrlc()) - return 1; - flag_restore = 0; - if (!rpipe) { - flag_rep = 0; - rpipe = pi; - } + pi->r_mode == RES_FOR) { + /* check Ctrl-C */ + if (ctrlc()) + return 1; + flag_restore = 0; + if (!rpipe) { + flag_rep = 0; + rpipe = pi; + } } rmode = pi->r_mode; debug("rmode=%d if_code=%d next_if_code=%d skip_more=%d\n", diff --git a/common/uimage.c b/common/uimage.c index a7011a7..59d7b65 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -354,10 +354,9 @@ uimage_resource = request_sdram_region("uimage", start, size); if (!uimage_resource) { - printf("unable to request SDRAM " - PRINTF_CONVERSION_RESOURCE "-" - PRINTF_CONVERSION_RESOURCE "\n", - start, start + size - 1); + resource_size_t prsize = start + size - 1; + printf("unable to request SDRAM %pa - %pa\n", + &start, &prsize); return -ENOMEM; } } diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 27f4abc..908aacb 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,18 @@ #define SPI_NOR_MAX_ID_LEN 6 +/* + * For everything but full-chip erase; probably could be much smaller, but kept + * around for safety for now + */ +#define DEFAULT_READY_WAIT (40 * SECOND) + +/* + * For full-chip erase, calibrated to a 2MB flash (M25P16); should be scaled up + * for larger flash + */ +#define CHIP_ERASE_2MB_READY_WAIT (40 * SECOND) + struct flash_info { /* * This array stores the ID bytes. @@ -228,14 +241,15 @@ * Service routine to read status register until ready, or timeout occurs. * Returns non-zero if error. */ -static int spi_nor_wait_till_ready(struct spi_nor *nor) +static int spi_nor_wait_till_ready_with_timeout(struct spi_nor *nor, + uint64_t timeout_ns) { uint64_t start = get_time_ns(); int timeout = 0; int ret; while (!timeout) { - if (is_timeout(start, 40 * SECOND)) + if (is_timeout(start, timeout_ns)) timeout = 1; ret = spi_nor_ready(nor); @@ -250,6 +264,12 @@ return -ETIMEDOUT; } +static int spi_nor_wait_till_ready(struct spi_nor *nor) +{ + return spi_nor_wait_till_ready_with_timeout(nor, + DEFAULT_READY_WAIT); +} + /* * Erase the whole flash memory * @@ -318,6 +338,8 @@ /* whole-chip erase? */ if (len == mtd->size) { + uint64_t timeout; + write_enable(nor); if (erase_chip(nor)) { @@ -325,7 +347,16 @@ goto erase_err; } - ret = spi_nor_wait_till_ready(nor); + /* + * Scale the timeout linearly with the size of the flash, with + * a minimum calibrated to an old 2MB flash. We could try to + * pull these from CFI/SFDP, but these values should be good + * enough for now. + */ + timeout = max(CHIP_ERASE_2MB_READY_WAIT, + CHIP_ERASE_2MB_READY_WAIT * + (uint64_t)(mtd->size / SZ_2M)); + ret = spi_nor_wait_till_ready_with_timeout(nor, timeout); if (ret) goto erase_err; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 2c075db..3f848a4 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -123,6 +123,7 @@ { struct device_d *dev; struct resource *res = NULL, temp_res; + resource_size_t resinval; int i, j, ret, num_reg = 0, match; if (!of_device_is_available(np)) @@ -183,9 +184,11 @@ dev->num_resources = num_reg; of_device_make_bus_id(dev); - debug("%s: register device %s, io=" PRINTF_CONVERSION_RESOURCE "\n", + resinval = (-1); + + debug("%s: register device %s, io=%pa\n", __func__, dev_name(dev), - (num_reg) ? dev->resource[0].start : (-1)); + (num_reg) ? &dev->resource[0].start : &resinval); ret = platform_device_register(dev); if (!ret) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 9b35a30..3d375a8 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -26,12 +26,6 @@ struct list_head sibling; }; -#ifdef CONFIG_PHYS_ADDR_T_64BIT -#define PRINTF_CONVERSION_RESOURCE "0x%016llx" -#else -#define PRINTF_CONVERSION_RESOURCE "0x%08x" -#endif - /* * IO resources have these defined flags. */ diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 9b8e8cf..00b8863 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -237,6 +237,29 @@ return string(buf, end, uuid, field_width, precision, flags); } +static noinline_for_stack +char *address_val(char *buf, char *end, const void *addr, + int field_width, int precision, int flags, const char *fmt) +{ + unsigned long long num; + + flags |= SPECIAL | SMALL | ZEROPAD; + + switch (fmt[1]) { + case 'd': + num = *(const dma_addr_t *)addr; + field_width = sizeof(dma_addr_t) * 2 + 2; + break; + case 'p': + default: + num = *(const phys_addr_t *)addr; + field_width = sizeof(phys_addr_t) * 2 + 2; + break; + } + + return number(buf, end, num, 16, field_width, precision, flags); +} + /* * Show a '%p' thing. A kernel extension is that the '%p' is followed * by an extra set of alphanumeric characters that are extended format @@ -256,6 +279,8 @@ * [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15] * little endian output byte order is: * [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15] + * - 'a[pd]' For address types [p] phys_addr_t, [d] dma_addr_t and derivatives + * (default assumed to be phys_addr_t, passed by reference) * * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 * function pointers are really function descriptors, which contain a @@ -270,6 +295,8 @@ if (IS_ENABLED(CONFIG_PRINTF_UUID)) return uuid_string(buf, end, ptr, field_width, precision, flags, fmt); break; + case 'a': + return address_val(buf, end, ptr, field_width, precision, flags, fmt); } flags |= SMALL; if (field_width == -1) {