aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.m@jp.panasonic.com>2014-11-07 03:03:31 +0900
committerTom Rini <trini@ti.com>2014-11-23 06:48:30 -0500
commitb41411954d4ccf6ddaa581178462017557b82b5d (patch)
treef9439432d8dfa1073b0ba7b84f8289c4a9835c5f /common
parent111396ccb9a8d3e1f0e9d9921d3dbd6c7a70423f (diff)
downloadu-boot-midas-b41411954d4ccf6ddaa581178462017557b82b5d.tar.gz
u-boot-midas-b41411954d4ccf6ddaa581178462017557b82b5d.tar.bz2
u-boot-midas-b41411954d4ccf6ddaa581178462017557b82b5d.zip
linux/kernel.h: sync min, max, min3, max3 macros with Linux
U-Boot has never cared about the type when we get max/min of two values, but Linux Kernel does. This commit gets min, max, min3, max3 macros synced with the kernel introducing type checks. Many of references of those macros must be fixed to suppress warnings. We have two options: - Use min, max, min3, max3 only when the arguments have the same type (or add casts to the arguments) - Use min_t/max_t instead with the appropriate type for the first argument Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Pavel Machek <pavel@denx.de> Acked-by: Lukasz Majewski <l.majewski@samsung.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com> [trini: Fixup arch/blackfin/lib/string.c] Signed-off-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_elf.c12
-rw-r--r--common/cmd_sf.c16
-rw-r--r--common/env_nand.c4
-rw-r--r--common/fdt_support.c3
-rw-r--r--common/lcd.c6
-rw-r--r--common/usb_hub.c3
6 files changed, 24 insertions, 20 deletions
diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 42a52965c2..58b61c2640 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -210,9 +210,9 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*/
bootline = getenv("bootargs");
if (bootline) {
- memcpy((void *) bootaddr, bootline,
- max(strlen(bootline), 255));
- flush_cache(bootaddr, max(strlen(bootline), 255));
+ memcpy((void *)bootaddr, bootline,
+ max(strlen(bootline), (size_t)255));
+ flush_cache(bootaddr, max(strlen(bootline), (size_t)255));
} else {
sprintf(build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE);
tmp = getenv("bootfile");
@@ -240,9 +240,9 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
CONFIG_SYS_VXWORKS_ADD_PARAMS);
#endif
- memcpy((void *) bootaddr, build_buf,
- max(strlen(build_buf), 255));
- flush_cache(bootaddr, max(strlen(build_buf), 255));
+ memcpy((void *)bootaddr, build_buf,
+ max(strlen(build_buf), (size_t)255));
+ flush_cache(bootaddr, max(strlen(build_buf), (size_t)255));
}
/*
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 95a6f89a84..5c788e96bd 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -18,7 +18,6 @@
static struct spi_flash *flash;
-
/*
* This function computes the length argument for the erase command.
* The length on which the command is to operate can be given in two forms:
@@ -71,9 +70,9 @@ static ulong bytes_per_second(unsigned int len, ulong start_ms)
{
/* less accurate but avoids overflow */
if (len >= ((unsigned int) -1) / 1024)
- return len / (max(get_timer(start_ms) / 1024, 1));
+ return len / (max(get_timer(start_ms) / 1024, 1UL));
else
- return 1024 * len / max(get_timer(start_ms), 1);
+ return 1024 * len / max(get_timer(start_ms), 1UL);
}
static int do_spi_flash_probe(int argc, char * const argv[])
@@ -223,7 +222,7 @@ static int spi_flash_update(struct spi_flash *flash, u32 offset,
ulong last_update = get_timer(0);
for (; buf < end && !err_oper; buf += todo, offset += todo) {
- todo = min(end - buf, flash->sector_size);
+ todo = min_t(size_t, end - buf, flash->sector_size);
if (get_timer(last_update) > 100) {
printf(" \rUpdating, %zu%% %lu B/s",
100 - (end - buf) / scale,
@@ -421,7 +420,8 @@ static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
for (i = 0; i < len; i++) {
if (vbuf[i] != 0xff) {
printf("Check failed at %d\n", i);
- print_buffer(i, vbuf + i, 1, min(len - i, 0x40), 0);
+ print_buffer(i, vbuf + i, 1,
+ min_t(uint, len - i, 0x40), 0);
return -1;
}
}
@@ -443,9 +443,11 @@ static int spi_flash_test(struct spi_flash *flash, uint8_t *buf, ulong len,
for (i = 0; i < len; i++) {
if (buf[i] != vbuf[i]) {
printf("Verify failed at %d, good data:\n", i);
- print_buffer(i, buf + i, 1, min(len - i, 0x40), 0);
+ print_buffer(i, buf + i, 1,
+ min_t(uint, len - i, 0x40), 0);
printf("Bad data:\n");
- print_buffer(i, vbuf + i, 1, min(len - i, 0x40), 0);
+ print_buffer(i, vbuf + i, 1,
+ min_t(uint, len - i, 0x40), 0);
return -1;
}
}
diff --git a/common/env_nand.c b/common/env_nand.c
index 749605fe3f..9c9bb82c0f 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -132,7 +132,7 @@ static int writeenv(size_t offset, u_char *buf)
u_char *char_ptr;
blocksize = nand_info[0].erasesize;
- len = min(blocksize, CONFIG_ENV_SIZE);
+ len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
while (amount_saved < CONFIG_ENV_SIZE && offset < end) {
if (nand_block_isbad(&nand_info[0], offset)) {
@@ -244,7 +244,7 @@ static int readenv(size_t offset, u_char *buf)
if (!blocksize)
return 1;
- len = min(blocksize, CONFIG_ENV_SIZE);
+ len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {
if (nand_block_isbad(&nand_info[0], offset)) {
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 3f641566b9..2d3c3870b1 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1199,7 +1199,8 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
*/
int fdt_alloc_phandle(void *blob)
{
- int offset, phandle = 0;
+ int offset;
+ uint32_t phandle = 0;
for (offset = fdt_next_node(blob, -1, NULL); offset >= 0;
offset = fdt_next_node(blob, offset, NULL)) {
diff --git a/common/lcd.c b/common/lcd.c
index 37147af805..d8e13715c1 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -746,7 +746,7 @@ static void splash_align_axis(int *axis, unsigned long panel_size,
else
return;
- *axis = max(0, axis_alignment);
+ *axis = max(0, (int)axis_alignment);
}
#endif
@@ -1145,8 +1145,8 @@ U_BOOT_ENV_CALLBACK(splashimage, on_splashimage);
void lcd_position_cursor(unsigned col, unsigned row)
{
- console_col = min(col, CONSOLE_COLS - 1);
- console_row = min(row, CONSOLE_ROWS - 1);
+ console_col = min_t(short, col, CONSOLE_COLS - 1);
+ console_row = min_t(short, row, CONSOLE_ROWS - 1);
}
int lcd_get_pixel_width(void)
diff --git a/common/usb_hub.c b/common/usb_hub.c
index 0f1eab4486..66b4a725d1 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -300,7 +300,8 @@ static int usb_hub_configure(struct usb_device *dev)
}
descriptor = (struct usb_hub_descriptor *)buffer;
- length = min(descriptor->bLength, sizeof(struct usb_hub_descriptor));
+ length = min_t(int, descriptor->bLength,
+ sizeof(struct usb_hub_descriptor));
if (usb_get_hub_descriptor(dev, buffer, length) < 0) {
debug("usb_hub_configure: failed to get hub " \