summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/barebox/barebox,state.rst2
-rw-r--r--commands/devinfo.c8
-rw-r--r--commands/iomemport.c6
-rw-r--r--common/bootm.c8
-rw-r--r--common/hush.c34
-rw-r--r--common/uimage.c7
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c37
-rw-r--r--drivers/of/platform.c7
-rw-r--r--include/linux/ioport.h6
-rw-r--r--lib/vsprintf.c27
10 files changed, 99 insertions, 43 deletions
diff --git a/Documentation/devicetree/bindings/barebox/barebox,state.rst b/Documentation/devicetree/bindings/barebox/barebox,state.rst
index d1b0627edf..d507657053 100644
--- a/Documentation/devicetree/bindings/barebox/barebox,state.rst
+++ b/Documentation/devicetree/bindings/barebox/barebox,state.rst
@@ -43,7 +43,7 @@ Variable nodes
These are subnodes of a state node each describing a single
variable. The node name may end with ``@<ADDRESS>``, 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 c78efcbed4..9d5e8b86eb 100644
--- a/commands/devinfo.c
+++ b/commands/devinfo.c
@@ -77,13 +77,15 @@ static int do_devinfo(int argc, char *argv[])
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 5294c13b81..6d97c5711b 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 1199cb7ccc..79833e045d 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -246,7 +246,7 @@ done:
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 int bootm_open_os_uimage(struct image_data *data)
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 832bc7bdb2..d3f7bf330d 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -863,29 +863,29 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi)
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 a7011a7623..59d7b65c90 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -354,10 +354,9 @@ static int uimage_sdram_flush(void *buf, unsigned int len)
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 27f4abc03e..908aacb6a2 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -15,6 +15,7 @@
#include <driver.h>
#include <errno.h>
#include <linux/err.h>
+#include <linux/sizes.h>
#include <linux/math64.h>
#include <linux/mod_devicetable.h>
#include <linux/mtd/mtd.h>
@@ -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 @@ static int spi_nor_ready(struct spi_nor *nor)
* 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 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor)
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 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
/* whole-chip erase? */
if (len == mtd->size) {
+ uint64_t timeout;
+
write_enable(nor);
if (erase_chip(nor)) {
@@ -325,7 +347,16 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
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 2c075dbae3..3f848a4396 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -123,6 +123,7 @@ struct device_d *of_platform_device_create(struct device_node *np,
{
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 @@ struct device_d *of_platform_device_create(struct device_node *np,
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 9b35a30e66..3d375a8740 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -26,12 +26,6 @@ struct resource {
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 9b8e8cf5f8..00b8863957 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -237,6 +237,29 @@ char *uuid_string(char *buf, char *end, const u8 *addr, int field_width,
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 @@ char *uuid_string(char *buf, char *end, const u8 *addr, int field_width,
* [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 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field
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) {