Commit b41411954d4ccf6ddaa581178462017557b82b5d
Committed by
Tom Rini
1 parent
111396ccb9
Exists in
v2017.01-smarct4x
and in
37 other branches
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>
Showing 54 changed files with 180 additions and 160 deletions Side-by-side Diff
- arch/arm/cpu/arm1176/tnetv107x/clock.c
- arch/arm/cpu/armv7/exynos/clock.c
- arch/arm/cpu/armv7/exynos/spl_boot.c
- arch/arm/cpu/armv7/tegra20/display.c
- arch/avr32/cpu/at32ap700x/clk.c
- arch/blackfin/cpu/jtag-console.c
- arch/blackfin/lib/string.c
- arch/powerpc/cpu/mpc85xx/tlb.c
- arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c
- arch/powerpc/lib/bootm.c
- arch/sandbox/cpu/start.c
- arch/x86/cpu/coreboot/pci.c
- arch/x86/cpu/coreboot/sdram.c
- board/freescale/common/sys_eeprom.c
- board/gdsys/p1022/controlcenterd-id.c
- board/imgtec/malta/malta.c
- common/cmd_elf.c
- common/cmd_sf.c
- common/env_nand.c
- common/fdt_support.c
- common/lcd.c
- common/usb_hub.c
- drivers/block/ahci.c
- drivers/ddr/fsl/ctrl_regs.c
- drivers/ddr/fsl/lc_common_dimm_params.c
- drivers/ddr/fsl/main.c
- drivers/dfu/dfu.c
- drivers/i2c/fsl_i2c.c
- drivers/misc/cros_ec_spi.c
- drivers/mmc/fsl_esdhc.c
- drivers/mmc/pxa_mmc_gen.c
- drivers/mtd/nand/denali_spl.c
- drivers/mtd/spi/sandbox.c
- drivers/mtd/spi/sf_ops.c
- drivers/net/netconsole.c
- drivers/pci/pci.c
- drivers/pci/pci_auto.c
- drivers/serial/usbtty.c
- drivers/spi/fsl_espi.c
- drivers/spi/mxc_spi.c
- drivers/spi/spi-uclass.c
- drivers/tpm/tpm_tis_lpc.c
- drivers/usb/gadget/composite.c
- drivers/usb/gadget/designware_udc.c
- drivers/usb/gadget/pxa27x_udc.c
- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
- drivers/usb/host/dwc2.c
- drivers/usb/host/ehci-hcd.c
- drivers/usb/host/xhci-ring.c
- drivers/usb/host/xhci.c
- drivers/video/cfb_console.c
- fs/ext4/dev.c
- fs/fat/fat.c
- include/linux/kernel.h
arch/arm/cpu/arm1176/tnetv107x/clock.c
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | #define BIT(x) (1 << (x)) |
17 | 17 | |
18 | 18 | #define MAX_PREDIV 64 |
19 | -#define MAX_POSTDIV 8 | |
19 | +#define MAX_POSTDIV 8UL | |
20 | 20 | #define MAX_MULT 512 |
21 | 21 | #define MAX_DIV (MAX_PREDIV * MAX_POSTDIV) |
22 | 22 | |
... | ... | @@ -362,7 +362,7 @@ |
362 | 362 | pllctl_reg_write(data->pll, ctl, tmp); |
363 | 363 | |
364 | 364 | mult = data->pll_freq / fpll; |
365 | - for (mult = max(mult, 1); mult <= MAX_MULT; mult++) { | |
365 | + for (mult = max(mult, 1UL); mult <= MAX_MULT; mult++) { | |
366 | 366 | div = (fpll * mult) / data->pll_freq; |
367 | 367 | if (div < 1 || div > MAX_DIV) |
368 | 368 | continue; |
arch/arm/cpu/armv7/exynos/clock.c
... | ... | @@ -1422,8 +1422,8 @@ |
1422 | 1422 | return 1; |
1423 | 1423 | |
1424 | 1424 | for (i = 1; i <= loops; i++) { |
1425 | - const unsigned int effective_div = max(min(input_rate / i / | |
1426 | - target_rate, cap), 1); | |
1425 | + const unsigned int effective_div = | |
1426 | + max(min(input_rate / i / target_rate, cap), 1U); | |
1427 | 1427 | const unsigned int effective_rate = input_rate / i / |
1428 | 1428 | effective_div; |
1429 | 1429 | const int error = target_rate - effective_rate; |
arch/arm/cpu/armv7/exynos/spl_boot.c
... | ... | @@ -151,7 +151,7 @@ |
151 | 151 | } |
152 | 152 | |
153 | 153 | for (upto = 0, i = 0; upto < uboot_size; upto += todo, i++) { |
154 | - todo = min(uboot_size - upto, (1 << 15)); | |
154 | + todo = min(uboot_size - upto, (unsigned int)(1 << 15)); | |
155 | 155 | spi_rx_tx(regs, todo, (void *)(uboot_addr), |
156 | 156 | (void *)(SPI_FLASH_UBOOT_POS), i); |
157 | 157 | } |
arch/arm/cpu/armv7/tegra20/display.c
... | ... | @@ -45,8 +45,8 @@ |
45 | 45 | writel(0, &dc->win.h_initial_dda); |
46 | 46 | writel(0, &dc->win.v_initial_dda); |
47 | 47 | |
48 | - h_dda = (win->w * 0x1000) / max(win->out_w - 1, 1); | |
49 | - v_dda = (win->h * 0x1000) / max(win->out_h - 1, 1); | |
48 | + h_dda = (win->w * 0x1000) / max(win->out_w - 1, 1U); | |
49 | + v_dda = (win->h * 0x1000) / max(win->out_h - 1, 1U); | |
50 | 50 | |
51 | 51 | val = h_dda << H_DDA_INC_SHIFT; |
52 | 52 | val |= v_dda << V_DDA_INC_SHIFT; |
arch/avr32/cpu/at32ap700x/clk.c
... | ... | @@ -72,7 +72,7 @@ |
72 | 72 | sm_writel(PM_GCCTRL(id), parent | SM_BIT(CEN)); |
73 | 73 | rate = parent_rate; |
74 | 74 | } else { |
75 | - divider = min(255, divider / 2 - 1); | |
75 | + divider = min(255UL, divider / 2 - 1); | |
76 | 76 | sm_writel(PM_GCCTRL(id), parent | SM_BIT(CEN) | SM_BIT(DIVEN) |
77 | 77 | | SM_BF(DIV, divider)); |
78 | 78 | rate = parent_rate / (2 * (divider + 1)); |
arch/blackfin/cpu/jtag-console.c
arch/blackfin/lib/string.c
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | *dshift = WDSIZE_P; |
122 | 122 | #endif |
123 | 123 | |
124 | - *bpos = min(limit, ffs(ldst | lsrc | count)) - 1; | |
124 | + *bpos = min(limit, (unsigned long)ffs(ldst | lsrc | count)) - 1; | |
125 | 125 | } |
126 | 126 | |
127 | 127 | /* This version misbehaves for count values of 0 and 2^16+. |
... | ... | @@ -157,7 +157,7 @@ |
157 | 157 | |
158 | 158 | #ifdef PSIZE |
159 | 159 | /* The max memory DMA peripheral transfer size is 4 bytes. */ |
160 | - dsize |= min(2, bpos) << PSIZE_P; | |
160 | + dsize |= min(2UL, bpos) << PSIZE_P; | |
161 | 161 | #endif |
162 | 162 | |
163 | 163 | /* Copy sram functions from sdram to sram */ |
arch/powerpc/cpu/mpc85xx/tlb.c
... | ... | @@ -300,7 +300,7 @@ |
300 | 300 | unsigned int ram_tlb_address = (unsigned int)CONFIG_SYS_DDR_SDRAM_BASE; |
301 | 301 | u64 memsize = (u64)memsize_in_meg << 20; |
302 | 302 | |
303 | - memsize = min(memsize, CONFIG_MAX_MEM_MAPPED); | |
303 | + memsize = min(memsize, (u64)CONFIG_MAX_MEM_MAPPED); | |
304 | 304 | memsize = tlb_map_range(ram_tlb_address, p_addr, memsize, TLB_MAP_RAM); |
305 | 305 | |
306 | 306 | if (memsize) |
arch/powerpc/cpu/ppc4xx/44x_spd_ddr2.c
... | ... | @@ -1661,7 +1661,7 @@ |
1661 | 1661 | for (dimm_num = 0; dimm_num < num_dimm_banks; dimm_num++) { |
1662 | 1662 | /* If a dimm is installed in a particular slot ... */ |
1663 | 1663 | if (dimm_populated[dimm_num] != SDRAM_NONE) |
1664 | - t_wr_ns = max(t_wr_ns, | |
1664 | + t_wr_ns = max(t_wr_ns, (unsigned long) | |
1665 | 1665 | spd_read(iic0_dimm_addr[dimm_num], 36) >> 2); |
1666 | 1666 | } |
1667 | 1667 | |
... | ... | @@ -1838,12 +1838,18 @@ |
1838 | 1838 | else |
1839 | 1839 | sdram_ddr1 = false; |
1840 | 1840 | |
1841 | - t_rcd_ns = max(t_rcd_ns, spd_read(iic0_dimm_addr[dimm_num], 29) >> 2); | |
1842 | - t_rrd_ns = max(t_rrd_ns, spd_read(iic0_dimm_addr[dimm_num], 28) >> 2); | |
1843 | - t_rp_ns = max(t_rp_ns, spd_read(iic0_dimm_addr[dimm_num], 27) >> 2); | |
1844 | - t_ras_ns = max(t_ras_ns, spd_read(iic0_dimm_addr[dimm_num], 30)); | |
1845 | - t_rc_ns = max(t_rc_ns, spd_read(iic0_dimm_addr[dimm_num], 41)); | |
1846 | - t_rfc_ns = max(t_rfc_ns, spd_read(iic0_dimm_addr[dimm_num], 42)); | |
1841 | + t_rcd_ns = max(t_rcd_ns, | |
1842 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 29) >> 2); | |
1843 | + t_rrd_ns = max(t_rrd_ns, | |
1844 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 28) >> 2); | |
1845 | + t_rp_ns = max(t_rp_ns, | |
1846 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 27) >> 2); | |
1847 | + t_ras_ns = max(t_ras_ns, | |
1848 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 30)); | |
1849 | + t_rc_ns = max(t_rc_ns, | |
1850 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 41)); | |
1851 | + t_rfc_ns = max(t_rfc_ns, | |
1852 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 42)); | |
1847 | 1853 | } |
1848 | 1854 | } |
1849 | 1855 | |
... | ... | @@ -1916,9 +1922,12 @@ |
1916 | 1922 | for (dimm_num = 0; dimm_num < num_dimm_banks; dimm_num++) { |
1917 | 1923 | /* If a dimm is installed in a particular slot ... */ |
1918 | 1924 | if (dimm_populated[dimm_num] != SDRAM_NONE) { |
1919 | - t_wpc_ns = max(t_wtr_ns, spd_read(iic0_dimm_addr[dimm_num], 36) >> 2); | |
1920 | - t_wtr_ns = max(t_wtr_ns, spd_read(iic0_dimm_addr[dimm_num], 37) >> 2); | |
1921 | - t_rpc_ns = max(t_rpc_ns, spd_read(iic0_dimm_addr[dimm_num], 38) >> 2); | |
1925 | + t_wpc_ns = max(t_wtr_ns, | |
1926 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 36) >> 2); | |
1927 | + t_wtr_ns = max(t_wtr_ns, | |
1928 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 37) >> 2); | |
1929 | + t_rpc_ns = max(t_rpc_ns, | |
1930 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 38) >> 2); | |
1922 | 1931 | } |
1923 | 1932 | } |
1924 | 1933 | |
... | ... | @@ -2314,7 +2323,8 @@ |
2314 | 2323 | for (dimm_num = 0; dimm_num < MAXDIMMS; dimm_num++) { |
2315 | 2324 | /* If a dimm is installed in a particular slot ... */ |
2316 | 2325 | if (dimm_populated[dimm_num] != SDRAM_NONE) |
2317 | - ecc = max(ecc, spd_read(iic0_dimm_addr[dimm_num], 11)); | |
2326 | + ecc = max(ecc, | |
2327 | + (unsigned long)spd_read(iic0_dimm_addr[dimm_num], 11)); | |
2318 | 2328 | } |
2319 | 2329 | if (ecc == 0) |
2320 | 2330 | return; |
arch/powerpc/lib/bootm.c
... | ... | @@ -126,7 +126,7 @@ |
126 | 126 | #endif |
127 | 127 | |
128 | 128 | size = min(bootm_size, get_effective_memsize()); |
129 | - size = min(size, CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE); | |
129 | + size = min(size, (ulong)CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE); | |
130 | 130 | |
131 | 131 | if (size < bootm_size) { |
132 | 132 | ulong base = bootmap_base + size; |
arch/sandbox/cpu/start.c
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | |
40 | 40 | max_arg_len = 0; |
41 | 41 | for (i = 0; i < num_options; ++i) |
42 | - max_arg_len = max(strlen(sb_opt[i]->flag), max_arg_len); | |
42 | + max_arg_len = max((int)strlen(sb_opt[i]->flag), max_arg_len); | |
43 | 43 | max_noarg_len = max_arg_len + 7; |
44 | 44 | |
45 | 45 | for (i = 0; i < num_options; ++i) { |
arch/x86/cpu/coreboot/pci.c
arch/x86/cpu/coreboot/sdram.c
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | { |
23 | 23 | int i; |
24 | 24 | |
25 | - unsigned num_entries = min(lib_sysinfo.n_memranges, max_entries); | |
25 | + unsigned num_entries = min((unsigned)lib_sysinfo.n_memranges, max_entries); | |
26 | 26 | if (num_entries < lib_sysinfo.n_memranges) { |
27 | 27 | printf("Warning: Limiting e820 map to %d entries.\n", |
28 | 28 | num_entries); |
board/freescale/common/sys_eeprom.c
... | ... | @@ -114,7 +114,7 @@ |
114 | 114 | e.date[3] & 0x80 ? "PM" : ""); |
115 | 115 | |
116 | 116 | /* Show MAC addresses */ |
117 | - for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) { | |
117 | + for (i = 0; i < min(e.mac_count, (u8)MAX_NUM_PORTS); i++) { | |
118 | 118 | |
119 | 119 | u8 *p = e.mac[i]; |
120 | 120 | |
... | ... | @@ -223,7 +223,7 @@ |
223 | 223 | */ |
224 | 224 | for (i = 0, p = &e; i < sizeof(e); i += 8, p += 8) { |
225 | 225 | ret = i2c_write(CONFIG_SYS_I2C_EEPROM_ADDR, i, CONFIG_SYS_I2C_EEPROM_ADDR_LEN, |
226 | - p, min((sizeof(e) - i), 8)); | |
226 | + p, min((int)(sizeof(e) - i), 8)); | |
227 | 227 | if (ret) |
228 | 228 | break; |
229 | 229 | udelay(5000); /* 5ms write cycle timing */ |
... | ... | @@ -461,7 +461,7 @@ |
461 | 461 | memset(e.mac[8], 0xff, 6); |
462 | 462 | #endif |
463 | 463 | |
464 | - for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) { | |
464 | + for (i = 0; i < min(e.mac_count, (u8)MAX_NUM_PORTS); i++) { | |
465 | 465 | if (memcmp(&e.mac[i], "\0\0\0\0\0\0", 6) && |
466 | 466 | memcmp(&e.mac[i], "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) { |
467 | 467 | char ethaddr[18]; |
board/gdsys/p1022/controlcenterd-id.c
... | ... | @@ -236,7 +236,7 @@ |
236 | 236 | tmp_buf); |
237 | 237 | if (!n) |
238 | 238 | goto failure; |
239 | - result = min(size, blk_len - ofs); | |
239 | + result = min(size, (int)(blk_len - ofs)); | |
240 | 240 | memcpy(dst, tmp_buf + ofs, result); |
241 | 241 | dst += result; |
242 | 242 | size -= result; |
... | ... | @@ -736,7 +736,8 @@ |
736 | 736 | src_buf = buf; |
737 | 737 | for (ptr = (uint8_t *)src_buf, i = 20; i > 0; |
738 | 738 | i -= data_size, ptr += data_size) |
739 | - memcpy(ptr, data, min(i, data_size)); | |
739 | + memcpy(ptr, data, | |
740 | + min_t(size_t, i, data_size)); | |
740 | 741 | } |
741 | 742 | } |
742 | 743 | bin_func(dst_reg->digest, src_buf, 20); |
board/imgtec/malta/malta.c
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | void *reg = (void *)CKSEG1ADDR(MALTA_ASCIIPOS0); |
38 | 38 | |
39 | 39 | /* print up to 8 characters of the string */ |
40 | - for (i = 0; i < min(strlen(str), 8); i++) { | |
40 | + for (i = 0; i < min((int)strlen(str), 8); i++) { | |
41 | 41 | __raw_writel(str[i], reg); |
42 | 42 | reg += MALTA_ASCIIPOS1 - MALTA_ASCIIPOS0; |
43 | 43 | } |
common/cmd_elf.c
... | ... | @@ -210,9 +210,9 @@ |
210 | 210 | */ |
211 | 211 | bootline = getenv("bootargs"); |
212 | 212 | if (bootline) { |
213 | - memcpy((void *) bootaddr, bootline, | |
214 | - max(strlen(bootline), 255)); | |
215 | - flush_cache(bootaddr, max(strlen(bootline), 255)); | |
213 | + memcpy((void *)bootaddr, bootline, | |
214 | + max(strlen(bootline), (size_t)255)); | |
215 | + flush_cache(bootaddr, max(strlen(bootline), (size_t)255)); | |
216 | 216 | } else { |
217 | 217 | sprintf(build_buf, CONFIG_SYS_VXWORKS_BOOT_DEVICE); |
218 | 218 | tmp = getenv("bootfile"); |
... | ... | @@ -240,9 +240,9 @@ |
240 | 240 | CONFIG_SYS_VXWORKS_ADD_PARAMS); |
241 | 241 | #endif |
242 | 242 | |
243 | - memcpy((void *) bootaddr, build_buf, | |
244 | - max(strlen(build_buf), 255)); | |
245 | - flush_cache(bootaddr, max(strlen(build_buf), 255)); | |
243 | + memcpy((void *)bootaddr, build_buf, | |
244 | + max(strlen(build_buf), (size_t)255)); | |
245 | + flush_cache(bootaddr, max(strlen(build_buf), (size_t)255)); | |
246 | 246 | } |
247 | 247 | |
248 | 248 | /* |
common/cmd_sf.c
... | ... | @@ -18,7 +18,6 @@ |
18 | 18 | |
19 | 19 | static struct spi_flash *flash; |
20 | 20 | |
21 | - | |
22 | 21 | /* |
23 | 22 | * This function computes the length argument for the erase command. |
24 | 23 | * The length on which the command is to operate can be given in two forms: |
25 | 24 | |
... | ... | @@ -71,9 +70,9 @@ |
71 | 70 | { |
72 | 71 | /* less accurate but avoids overflow */ |
73 | 72 | if (len >= ((unsigned int) -1) / 1024) |
74 | - return len / (max(get_timer(start_ms) / 1024, 1)); | |
73 | + return len / (max(get_timer(start_ms) / 1024, 1UL)); | |
75 | 74 | else |
76 | - return 1024 * len / max(get_timer(start_ms), 1); | |
75 | + return 1024 * len / max(get_timer(start_ms), 1UL); | |
77 | 76 | } |
78 | 77 | |
79 | 78 | static int do_spi_flash_probe(int argc, char * const argv[]) |
... | ... | @@ -223,7 +222,7 @@ |
223 | 222 | ulong last_update = get_timer(0); |
224 | 223 | |
225 | 224 | for (; buf < end && !err_oper; buf += todo, offset += todo) { |
226 | - todo = min(end - buf, flash->sector_size); | |
225 | + todo = min_t(size_t, end - buf, flash->sector_size); | |
227 | 226 | if (get_timer(last_update) > 100) { |
228 | 227 | printf(" \rUpdating, %zu%% %lu B/s", |
229 | 228 | 100 - (end - buf) / scale, |
... | ... | @@ -421,7 +420,8 @@ |
421 | 420 | for (i = 0; i < len; i++) { |
422 | 421 | if (vbuf[i] != 0xff) { |
423 | 422 | printf("Check failed at %d\n", i); |
424 | - print_buffer(i, vbuf + i, 1, min(len - i, 0x40), 0); | |
423 | + print_buffer(i, vbuf + i, 1, | |
424 | + min_t(uint, len - i, 0x40), 0); | |
425 | 425 | return -1; |
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
... | ... | @@ -443,9 +443,11 @@ |
443 | 443 | for (i = 0; i < len; i++) { |
444 | 444 | if (buf[i] != vbuf[i]) { |
445 | 445 | printf("Verify failed at %d, good data:\n", i); |
446 | - print_buffer(i, buf + i, 1, min(len - i, 0x40), 0); | |
446 | + print_buffer(i, buf + i, 1, | |
447 | + min_t(uint, len - i, 0x40), 0); | |
447 | 448 | printf("Bad data:\n"); |
448 | - print_buffer(i, vbuf + i, 1, min(len - i, 0x40), 0); | |
449 | + print_buffer(i, vbuf + i, 1, | |
450 | + min_t(uint, len - i, 0x40), 0); | |
449 | 451 | return -1; |
450 | 452 | } |
451 | 453 | } |
common/env_nand.c
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 | u_char *char_ptr; |
133 | 133 | |
134 | 134 | blocksize = nand_info[0].erasesize; |
135 | - len = min(blocksize, CONFIG_ENV_SIZE); | |
135 | + len = min(blocksize, (size_t)CONFIG_ENV_SIZE); | |
136 | 136 | |
137 | 137 | while (amount_saved < CONFIG_ENV_SIZE && offset < end) { |
138 | 138 | if (nand_block_isbad(&nand_info[0], offset)) { |
... | ... | @@ -244,7 +244,7 @@ |
244 | 244 | if (!blocksize) |
245 | 245 | return 1; |
246 | 246 | |
247 | - len = min(blocksize, CONFIG_ENV_SIZE); | |
247 | + len = min(blocksize, (size_t)CONFIG_ENV_SIZE); | |
248 | 248 | |
249 | 249 | while (amount_loaded < CONFIG_ENV_SIZE && offset < end) { |
250 | 250 | if (nand_block_isbad(&nand_info[0], offset)) { |
common/fdt_support.c
... | ... | @@ -1199,7 +1199,8 @@ |
1199 | 1199 | */ |
1200 | 1200 | int fdt_alloc_phandle(void *blob) |
1201 | 1201 | { |
1202 | - int offset, phandle = 0; | |
1202 | + int offset; | |
1203 | + uint32_t phandle = 0; | |
1203 | 1204 | |
1204 | 1205 | for (offset = fdt_next_node(blob, -1, NULL); offset >= 0; |
1205 | 1206 | offset = fdt_next_node(blob, offset, NULL)) { |
common/lcd.c
... | ... | @@ -746,7 +746,7 @@ |
746 | 746 | else |
747 | 747 | return; |
748 | 748 | |
749 | - *axis = max(0, axis_alignment); | |
749 | + *axis = max(0, (int)axis_alignment); | |
750 | 750 | } |
751 | 751 | #endif |
752 | 752 | |
... | ... | @@ -1145,8 +1145,8 @@ |
1145 | 1145 | |
1146 | 1146 | void lcd_position_cursor(unsigned col, unsigned row) |
1147 | 1147 | { |
1148 | - console_col = min(col, CONSOLE_COLS - 1); | |
1149 | - console_row = min(row, CONSOLE_ROWS - 1); | |
1148 | + console_col = min_t(short, col, CONSOLE_COLS - 1); | |
1149 | + console_row = min_t(short, row, CONSOLE_ROWS - 1); | |
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | int lcd_get_pixel_width(void) |
common/usb_hub.c
... | ... | @@ -300,7 +300,8 @@ |
300 | 300 | } |
301 | 301 | descriptor = (struct usb_hub_descriptor *)buffer; |
302 | 302 | |
303 | - length = min(descriptor->bLength, sizeof(struct usb_hub_descriptor)); | |
303 | + length = min_t(int, descriptor->bLength, | |
304 | + sizeof(struct usb_hub_descriptor)); | |
304 | 305 | |
305 | 306 | if (usb_get_hub_descriptor(dev, buffer, length) < 0) { |
306 | 307 | debug("usb_hub_configure: failed to get hub " \ |
drivers/block/ahci.c
... | ... | @@ -730,7 +730,7 @@ |
730 | 730 | u16 now_blocks; /* number of blocks per iteration */ |
731 | 731 | u32 transfer_size; /* number of bytes per iteration */ |
732 | 732 | |
733 | - now_blocks = min(MAX_SATA_BLOCKS_READ_WRITE, blocks); | |
733 | + now_blocks = min((u16)MAX_SATA_BLOCKS_READ_WRITE, blocks); | |
734 | 734 | |
735 | 735 | transfer_size = ATA_SECT_SIZE * now_blocks; |
736 | 736 | if (transfer_size > user_buffer_size) { |
drivers/ddr/fsl/ctrl_regs.c
... | ... | @@ -303,7 +303,7 @@ |
303 | 303 | |
304 | 304 | #ifdef CONFIG_SYS_FSL_DDR4 |
305 | 305 | /* tXP=max(4nCK, 6ns) */ |
306 | - int txp = max(mclk_ps * 4, 6000); /* unit=ps */ | |
306 | + int txp = max((int)mclk_ps * 4, 6000); /* unit=ps */ | |
307 | 307 | trwt_mclk = 2; |
308 | 308 | twrt_mclk = 1; |
309 | 309 | act_pd_exit_mclk = picos_to_mclk(txp); |
... | ... | @@ -312,7 +312,7 @@ |
312 | 312 | * MRS_CYC = max(tMRD, tMOD) |
313 | 313 | * tMRD = 8nCK, tMOD = max(24nCK, 15ns) |
314 | 314 | */ |
315 | - tmrd_mclk = max(24, picos_to_mclk(15000)); | |
315 | + tmrd_mclk = max(24U, picos_to_mclk(15000)); | |
316 | 316 | #elif defined(CONFIG_SYS_FSL_DDR3) |
317 | 317 | unsigned int data_rate = get_ddr_freq(0); |
318 | 318 | int txp; |
... | ... | @@ -325,7 +325,7 @@ |
325 | 325 | * spec has not the tAXPD, we use |
326 | 326 | * tAXPD=1, need design to confirm. |
327 | 327 | */ |
328 | - txp = max(mclk_ps * 3, (mclk_ps > 1540 ? 7500 : 6000)); | |
328 | + txp = max((int)mclk_ps * 3, (mclk_ps > 1540 ? 7500 : 6000)); | |
329 | 329 | |
330 | 330 | tmrd_mclk = 4; |
331 | 331 | /* set the turnaround time */ |
... | ... | @@ -511,8 +511,8 @@ |
511 | 511 | #ifdef CONFIG_SYS_FSL_DDR4 |
512 | 512 | refrec_ctrl = picos_to_mclk(common_dimm->trfc1_ps) - 8; |
513 | 513 | wrrec_mclk = picos_to_mclk(common_dimm->twr_ps); |
514 | - acttoact_mclk = max(picos_to_mclk(common_dimm->trrds_ps), 4); | |
515 | - wrtord_mclk = max(2, picos_to_mclk(2500)); | |
514 | + acttoact_mclk = max(picos_to_mclk(common_dimm->trrds_ps), 4U); | |
515 | + wrtord_mclk = max(2U, picos_to_mclk(2500)); | |
516 | 516 | if ((wrrec_mclk < 1) || (wrrec_mclk > 24)) |
517 | 517 | printf("Error: WRREC doesn't support %d clocks\n", wrrec_mclk); |
518 | 518 | else |
519 | 519 | |
... | ... | @@ -627,14 +627,14 @@ |
627 | 627 | wr_data_delay = popts->write_data_delay; |
628 | 628 | #ifdef CONFIG_SYS_FSL_DDR4 |
629 | 629 | cpo = 0; |
630 | - cke_pls = max(3, picos_to_mclk(5000)); | |
630 | + cke_pls = max(3U, picos_to_mclk(5000)); | |
631 | 631 | #elif defined(CONFIG_SYS_FSL_DDR3) |
632 | 632 | /* |
633 | 633 | * cke pulse = max(3nCK, 7.5ns) for DDR3-800 |
634 | 634 | * max(3nCK, 5.625ns) for DDR3-1066, 1333 |
635 | 635 | * max(3nCK, 5ns) for DDR3-1600, 1866, 2133 |
636 | 636 | */ |
637 | - cke_pls = max(3, picos_to_mclk(mclk_ps > 1870 ? 7500 : | |
637 | + cke_pls = max(3U, picos_to_mclk(mclk_ps > 1870 ? 7500 : | |
638 | 638 | (mclk_ps > 1245 ? 5625 : 5000))); |
639 | 639 | #else |
640 | 640 | cke_pls = FSL_DDR_MIN_TCKE_PULSE_WIDTH_DDR; |
... | ... | @@ -1810,9 +1810,9 @@ |
1810 | 1810 | unsigned int txpr, tcksre, tcksrx; |
1811 | 1811 | unsigned int cke_rst, cksre, cksrx, par_lat, cs_to_cmd; |
1812 | 1812 | |
1813 | - txpr = max(5, picos_to_mclk(common_dimm->trfc1_ps + 10000)); | |
1814 | - tcksre = max(5, picos_to_mclk(10000)); | |
1815 | - tcksrx = max(5, picos_to_mclk(10000)); | |
1813 | + txpr = max(5U, picos_to_mclk(common_dimm->trfc1_ps + 10000)); | |
1814 | + tcksre = max(5U, picos_to_mclk(10000)); | |
1815 | + tcksrx = max(5U, picos_to_mclk(10000)); | |
1816 | 1816 | par_lat = 0; |
1817 | 1817 | cs_to_cmd = 0; |
1818 | 1818 | |
... | ... | @@ -1877,7 +1877,7 @@ |
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | acttoact_bg = picos_to_mclk(common_dimm->trrdl_ps); |
1880 | - wrtord_bg = max(4, picos_to_mclk(7500)); | |
1880 | + wrtord_bg = max(4U, picos_to_mclk(7500)); | |
1881 | 1881 | if (popts->otf_burst_chop_en) |
1882 | 1882 | wrtord_bg += 2; |
1883 | 1883 |
drivers/ddr/fsl/lc_common_dimm_params.c
... | ... | @@ -289,48 +289,58 @@ |
289 | 289 | * Find minimum tckmax_ps to find fastest slow speed, |
290 | 290 | * i.e., this is the slowest the whole system can go. |
291 | 291 | */ |
292 | - tckmax_ps = min(tckmax_ps, dimm_params[i].tckmax_ps); | |
292 | + tckmax_ps = min(tckmax_ps, | |
293 | + (unsigned int)dimm_params[i].tckmax_ps); | |
293 | 294 | #if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4) |
294 | - taamin_ps = max(taamin_ps, dimm_params[i].taa_ps); | |
295 | + taamin_ps = max(taamin_ps, | |
296 | + (unsigned int)dimm_params[i].taa_ps); | |
295 | 297 | #endif |
296 | - tckmin_x_ps = max(tckmin_x_ps, dimm_params[i].tckmin_x_ps); | |
297 | - trcd_ps = max(trcd_ps, dimm_params[i].trcd_ps); | |
298 | - trp_ps = max(trp_ps, dimm_params[i].trp_ps); | |
299 | - tras_ps = max(tras_ps, dimm_params[i].tras_ps); | |
298 | + tckmin_x_ps = max(tckmin_x_ps, | |
299 | + (unsigned int)dimm_params[i].tckmin_x_ps); | |
300 | + trcd_ps = max(trcd_ps, (unsigned int)dimm_params[i].trcd_ps); | |
301 | + trp_ps = max(trp_ps, (unsigned int)dimm_params[i].trp_ps); | |
302 | + tras_ps = max(tras_ps, (unsigned int)dimm_params[i].tras_ps); | |
300 | 303 | #ifdef CONFIG_SYS_FSL_DDR4 |
301 | - trfc1_ps = max(trfc1_ps, dimm_params[i].trfc1_ps); | |
302 | - trfc2_ps = max(trfc2_ps, dimm_params[i].trfc2_ps); | |
303 | - trfc4_ps = max(trfc4_ps, dimm_params[i].trfc4_ps); | |
304 | - trrds_ps = max(trrds_ps, dimm_params[i].trrds_ps); | |
305 | - trrdl_ps = max(trrdl_ps, dimm_params[i].trrdl_ps); | |
306 | - tccdl_ps = max(tccdl_ps, dimm_params[i].tccdl_ps); | |
304 | + trfc1_ps = max(trfc1_ps, | |
305 | + (unsigned int)dimm_params[i].trfc1_ps); | |
306 | + trfc2_ps = max(trfc2_ps, | |
307 | + (unsigned int)dimm_params[i].trfc2_ps); | |
308 | + trfc4_ps = max(trfc4_ps, | |
309 | + (unsigned int)dimm_params[i].trfc4_ps); | |
310 | + trrds_ps = max(trrds_ps, | |
311 | + (unsigned int)dimm_params[i].trrds_ps); | |
312 | + trrdl_ps = max(trrdl_ps, | |
313 | + (unsigned int)dimm_params[i].trrdl_ps); | |
314 | + tccdl_ps = max(tccdl_ps, | |
315 | + (unsigned int)dimm_params[i].tccdl_ps); | |
307 | 316 | #else |
308 | - twr_ps = max(twr_ps, dimm_params[i].twr_ps); | |
309 | - twtr_ps = max(twtr_ps, dimm_params[i].twtr_ps); | |
310 | - trfc_ps = max(trfc_ps, dimm_params[i].trfc_ps); | |
311 | - trrd_ps = max(trrd_ps, dimm_params[i].trrd_ps); | |
312 | - trtp_ps = max(trtp_ps, dimm_params[i].trtp_ps); | |
317 | + twr_ps = max(twr_ps, (unsigned int)dimm_params[i].twr_ps); | |
318 | + twtr_ps = max(twtr_ps, (unsigned int)dimm_params[i].twtr_ps); | |
319 | + trfc_ps = max(trfc_ps, (unsigned int)dimm_params[i].trfc_ps); | |
320 | + trrd_ps = max(trrd_ps, (unsigned int)dimm_params[i].trrd_ps); | |
321 | + trtp_ps = max(trtp_ps, (unsigned int)dimm_params[i].trtp_ps); | |
313 | 322 | #endif |
314 | - trc_ps = max(trc_ps, dimm_params[i].trc_ps); | |
323 | + trc_ps = max(trc_ps, (unsigned int)dimm_params[i].trc_ps); | |
315 | 324 | #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2) |
316 | - tis_ps = max(tis_ps, dimm_params[i].tis_ps); | |
317 | - tih_ps = max(tih_ps, dimm_params[i].tih_ps); | |
318 | - tds_ps = max(tds_ps, dimm_params[i].tds_ps); | |
319 | - tdh_ps = max(tdh_ps, dimm_params[i].tdh_ps); | |
320 | - tqhs_ps = max(tqhs_ps, dimm_params[i].tqhs_ps); | |
325 | + tis_ps = max(tis_ps, (unsigned int)dimm_params[i].tis_ps); | |
326 | + tih_ps = max(tih_ps, (unsigned int)dimm_params[i].tih_ps); | |
327 | + tds_ps = max(tds_ps, (unsigned int)dimm_params[i].tds_ps); | |
328 | + tdh_ps = max(tdh_ps, (unsigned int)dimm_params[i].tdh_ps); | |
329 | + tqhs_ps = max(tqhs_ps, (unsigned int)dimm_params[i].tqhs_ps); | |
321 | 330 | /* |
322 | 331 | * Find maximum tdqsq_max_ps to find slowest. |
323 | 332 | * |
324 | 333 | * FIXME: is finding the slowest value the correct |
325 | 334 | * strategy for this parameter? |
326 | 335 | */ |
327 | - tdqsq_max_ps = max(tdqsq_max_ps, dimm_params[i].tdqsq_max_ps); | |
336 | + tdqsq_max_ps = max(tdqsq_max_ps, | |
337 | + (unsigned int)dimm_params[i].tdqsq_max_ps); | |
328 | 338 | #endif |
329 | 339 | refresh_rate_ps = max(refresh_rate_ps, |
330 | - dimm_params[i].refresh_rate_ps); | |
340 | + (unsigned int)dimm_params[i].refresh_rate_ps); | |
331 | 341 | /* extended_op_srt is either 0 or 1, 0 having priority */ |
332 | 342 | extended_op_srt = min(extended_op_srt, |
333 | - dimm_params[i].extended_op_srt); | |
343 | + (unsigned int)dimm_params[i].extended_op_srt); | |
334 | 344 | } |
335 | 345 | |
336 | 346 | outpdimm->ndimms_present = number_of_dimms - temp1; |
drivers/ddr/fsl/main.c
... | ... | @@ -106,7 +106,8 @@ |
106 | 106 | i2c_write(SPD_SPA1_ADDRESS, 0, 1, &dummy, 1); |
107 | 107 | ret = i2c_read(i2c_address, 0, 1, |
108 | 108 | (uchar *)((ulong)spd + 256), |
109 | - min(256, sizeof(generic_spd_eeprom_t) - 256)); | |
109 | + min(256, | |
110 | + (int)sizeof(generic_spd_eeprom_t) - 256)); | |
110 | 111 | } |
111 | 112 | #else |
112 | 113 | ret = i2c_read(i2c_address, 0, 1, (uchar *)spd, |
drivers/dfu/dfu.c
drivers/i2c/fsl_i2c.c
... | ... | @@ -127,7 +127,7 @@ |
127 | 127 | static unsigned int set_i2c_bus_speed(const struct fsl_i2c *dev, |
128 | 128 | unsigned int i2c_clk, unsigned int speed) |
129 | 129 | { |
130 | - unsigned short divider = min(i2c_clk / speed, (unsigned short) -1); | |
130 | + unsigned short divider = min(i2c_clk / speed, (unsigned int)USHRT_MAX); | |
131 | 131 | |
132 | 132 | /* |
133 | 133 | * We want to choose an FDR/DFSR that generates an I2C bus speed that |
drivers/misc/cros_ec_spi.c
drivers/mmc/fsl_esdhc.c
drivers/mmc/pxa_mmc_gen.c
... | ... | @@ -197,7 +197,7 @@ |
197 | 197 | while (len) { |
198 | 198 | /* The controller has data ready */ |
199 | 199 | if (readl(®s->i_reg) & MMC_I_REG_RXFIFO_RD_REQ) { |
200 | - size = min(len, PXAMMC_FIFO_SIZE); | |
200 | + size = min(len, (uint32_t)PXAMMC_FIFO_SIZE); | |
201 | 201 | len -= size; |
202 | 202 | size /= 4; |
203 | 203 | |
204 | 204 | |
... | ... | @@ -233,14 +233,14 @@ |
233 | 233 | while (len) { |
234 | 234 | /* The controller is ready to receive data */ |
235 | 235 | if (readl(®s->i_reg) & MMC_I_REG_TXFIFO_WR_REQ) { |
236 | - size = min(len, PXAMMC_FIFO_SIZE); | |
236 | + size = min(len, (uint32_t)PXAMMC_FIFO_SIZE); | |
237 | 237 | len -= size; |
238 | 238 | size /= 4; |
239 | 239 | |
240 | 240 | while (size--) |
241 | 241 | writel(*buf++, ®s->txfifo); |
242 | 242 | |
243 | - if (min(len, PXAMMC_FIFO_SIZE) < 32) | |
243 | + if (min(len, (uint32_t)PXAMMC_FIFO_SIZE) < 32) | |
244 | 244 | writel(MMC_PRTBUF_BUF_PART_FULL, ®s->prtbuf); |
245 | 245 | } |
246 | 246 |
drivers/mtd/nand/denali_spl.c
drivers/mtd/spi/sandbox.c
drivers/mtd/spi/sf_ops.c
... | ... | @@ -313,10 +313,11 @@ |
313 | 313 | return ret; |
314 | 314 | #endif |
315 | 315 | byte_addr = offset % page_size; |
316 | - chunk_len = min(len - actual, page_size - byte_addr); | |
316 | + chunk_len = min(len - actual, (size_t)(page_size - byte_addr)); | |
317 | 317 | |
318 | 318 | if (flash->spi->max_write_size) |
319 | - chunk_len = min(chunk_len, flash->spi->max_write_size); | |
319 | + chunk_len = min(chunk_len, | |
320 | + (size_t)flash->spi->max_write_size); | |
320 | 321 | |
321 | 322 | spi_flash_addr(write_addr, cmd); |
322 | 323 |
drivers/net/netconsole.c
drivers/pci/pci.c
... | ... | @@ -662,13 +662,15 @@ |
662 | 662 | #endif |
663 | 663 | |
664 | 664 | #ifdef CONFIG_PCI_PNP |
665 | - sub_bus = max(pciauto_config_device(hose, dev), sub_bus); | |
665 | + sub_bus = max((unsigned int)pciauto_config_device(hose, dev), | |
666 | + sub_bus); | |
666 | 667 | #else |
667 | 668 | cfg = pci_find_config(hose, class, vendor, device, |
668 | 669 | PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev)); |
669 | 670 | if (cfg) { |
670 | 671 | cfg->config_device(hose, dev, cfg); |
671 | - sub_bus = max(sub_bus, hose->current_busno); | |
672 | + sub_bus = max(sub_bus, | |
673 | + (unsigned int)hose->current_busno); | |
672 | 674 | } |
673 | 675 | #endif |
674 | 676 |
drivers/pci/pci_auto.c
... | ... | @@ -387,7 +387,7 @@ |
387 | 387 | n = pci_hose_scan_bus(hose, hose->current_busno); |
388 | 388 | |
389 | 389 | /* figure out the deepest we've gone for this leg */ |
390 | - sub_bus = max(n, sub_bus); | |
390 | + sub_bus = max((unsigned int)n, sub_bus); | |
391 | 391 | pciauto_postscan_setup_bridge(hose, dev, sub_bus); |
392 | 392 | |
393 | 393 | sub_bus = hose->current_busno; |
drivers/serial/usbtty.c
drivers/spi/fsl_espi.c
... | ... | @@ -273,7 +273,7 @@ |
273 | 273 | spi_cs_deactivate(slave); |
274 | 274 | return 0; |
275 | 275 | } |
276 | - buf_len = 2 * cmd_len + min(data_len, max_tran_len); | |
276 | + buf_len = 2 * cmd_len + min(data_len, (size_t)max_tran_len); | |
277 | 277 | len = cmd_len + data_len; |
278 | 278 | rx_offset = cmd_len; |
279 | 279 | buffer = (unsigned char *)malloc(buf_len); |
... | ... | @@ -306,7 +306,7 @@ |
306 | 306 | if (data_in) |
307 | 307 | din = buffer + rx_offset; |
308 | 308 | dout = buffer; |
309 | - tran_len = min(data_len , max_tran_len); | |
309 | + tran_len = min(data_len, (size_t)max_tran_len); | |
310 | 310 | num_blks = DIV_ROUND_UP(tran_len + cmd_len, 4); |
311 | 311 | num_bytes = (tran_len + cmd_len) % 4; |
312 | 312 | fsl->data_len = tran_len + cmd_len; |
drivers/spi/mxc_spi.c
... | ... | @@ -315,7 +315,7 @@ |
315 | 315 | tmp = reg_read(®s->rxdata); |
316 | 316 | data = cpu_to_be32(tmp); |
317 | 317 | debug("SPI Rx: 0x%x 0x%x\n", tmp, data); |
318 | - cnt = min(nbytes, sizeof(data)); | |
318 | + cnt = min_t(u32, nbytes, sizeof(data)); | |
319 | 319 | if (din) { |
320 | 320 | memcpy(din, &data, cnt); |
321 | 321 | din += cnt; |
drivers/spi/spi-uclass.c
drivers/tpm/tpm_tis_lpc.c
... | ... | @@ -274,7 +274,7 @@ |
274 | 274 | * changes to zero exactly after the last byte is fed into the |
275 | 275 | * FIFO. |
276 | 276 | */ |
277 | - count = min(burst, len - offset - 1); | |
277 | + count = min((u32)burst, len - offset - 1); | |
278 | 278 | while (count--) |
279 | 279 | tpm_write_byte(data[offset++], |
280 | 280 | &lpc_tpm_dev[locality].data); |
drivers/usb/gadget/composite.c
... | ... | @@ -743,8 +743,8 @@ |
743 | 743 | if (!gadget_is_dualspeed(gadget)) |
744 | 744 | break; |
745 | 745 | device_qual(cdev); |
746 | - value = min(w_length, | |
747 | - sizeof(struct usb_qualifier_descriptor)); | |
746 | + value = min_t(int, w_length, | |
747 | + sizeof(struct usb_qualifier_descriptor)); | |
748 | 748 | break; |
749 | 749 | case USB_DT_OTHER_SPEED_CONFIG: |
750 | 750 | if (!gadget_is_dualspeed(gadget)) |
drivers/usb/gadget/designware_udc.c
... | ... | @@ -269,8 +269,8 @@ |
269 | 269 | UDCDBGA("urb->buffer %p, buffer_length %d, actual_length %d", |
270 | 270 | urb->buffer, urb->buffer_length, urb->actual_length); |
271 | 271 | |
272 | - last = min(urb->actual_length - endpoint->sent, | |
273 | - endpoint->tx_packetSize); | |
272 | + last = min_t(u32, urb->actual_length - endpoint->sent, | |
273 | + endpoint->tx_packetSize); | |
274 | 274 | |
275 | 275 | if (last) { |
276 | 276 | u8 *cp = urb->buffer + endpoint->sent; |
drivers/usb/gadget/pxa27x_udc.c
... | ... | @@ -65,7 +65,8 @@ |
65 | 65 | if (!urb || !urb->actual_length) |
66 | 66 | return -1; |
67 | 67 | |
68 | - n = min(urb->actual_length - endpoint->sent, endpoint->tx_packetSize); | |
68 | + n = min_t(unsigned int, urb->actual_length - endpoint->sent, | |
69 | + endpoint->tx_packetSize); | |
69 | 70 | if (n <= 0) |
70 | 71 | return -1; |
71 | 72 |
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c
... | ... | @@ -97,8 +97,8 @@ |
97 | 97 | u32 ep_num = ep_index(ep); |
98 | 98 | |
99 | 99 | buf = req->req.buf + req->req.actual; |
100 | - length = min(req->req.length - req->req.actual, | |
101 | - ep_num ? DMA_BUFFER_SIZE : ep->ep.maxpacket); | |
100 | + length = min_t(u32, req->req.length - req->req.actual, | |
101 | + ep_num ? DMA_BUFFER_SIZE : ep->ep.maxpacket); | |
102 | 102 | |
103 | 103 | ep->len = length; |
104 | 104 | ep->dma_buf = buf; |
drivers/usb/host/dwc2.c
... | ... | @@ -503,23 +503,23 @@ |
503 | 503 | case 0: |
504 | 504 | switch (wValue & 0xff00) { |
505 | 505 | case 0x0100: /* device descriptor */ |
506 | - len = min3(txlen, sizeof(root_hub_dev_des), wLength); | |
506 | + len = min3(txlen, (int)sizeof(root_hub_dev_des), (int)wLength); | |
507 | 507 | memcpy(buffer, root_hub_dev_des, len); |
508 | 508 | break; |
509 | 509 | case 0x0200: /* configuration descriptor */ |
510 | - len = min3(txlen, sizeof(root_hub_config_des), wLength); | |
510 | + len = min3(txlen, (int)sizeof(root_hub_config_des), (int)wLength); | |
511 | 511 | memcpy(buffer, root_hub_config_des, len); |
512 | 512 | break; |
513 | 513 | case 0x0300: /* string descriptors */ |
514 | 514 | switch (wValue & 0xff) { |
515 | 515 | case 0x00: |
516 | - len = min3(txlen, sizeof(root_hub_str_index0), | |
517 | - wLength); | |
516 | + len = min3(txlen, (int)sizeof(root_hub_str_index0), | |
517 | + (int)wLength); | |
518 | 518 | memcpy(buffer, root_hub_str_index0, len); |
519 | 519 | break; |
520 | 520 | case 0x01: |
521 | - len = min3(txlen, sizeof(root_hub_str_index1), | |
522 | - wLength); | |
521 | + len = min3(txlen, (int)sizeof(root_hub_str_index1), | |
522 | + (int)wLength); | |
523 | 523 | memcpy(buffer, root_hub_str_index1, len); |
524 | 524 | break; |
525 | 525 | } |
... | ... | @@ -556,7 +556,7 @@ |
556 | 556 | data[10] = data[9]; |
557 | 557 | } |
558 | 558 | |
559 | - len = min3(txlen, data[0], wLength); | |
559 | + len = min3(txlen, (int)data[0], (int)wLength); | |
560 | 560 | memcpy(buffer, data, len); |
561 | 561 | break; |
562 | 562 | default: |
drivers/usb/host/ehci-hcd.c
drivers/usb/host/xhci-ring.c
... | ... | @@ -511,7 +511,7 @@ |
511 | 511 | union xhci_trb *event, int length) |
512 | 512 | { |
513 | 513 | udev->act_len = min(length, length - |
514 | - EVENT_TRB_LEN(le32_to_cpu(event->trans_event.transfer_len))); | |
514 | + (int)EVENT_TRB_LEN(le32_to_cpu(event->trans_event.transfer_len))); | |
515 | 515 | |
516 | 516 | switch (GET_COMP_CODE(le32_to_cpu(event->trans_event.transfer_len))) { |
517 | 517 | case COMP_SUCCESS: |
drivers/usb/host/xhci.c
... | ... | @@ -829,7 +829,7 @@ |
829 | 829 | debug("scrlen = %d\n req->length = %d\n", |
830 | 830 | srclen, le16_to_cpu(req->length)); |
831 | 831 | |
832 | - len = min(srclen, le16_to_cpu(req->length)); | |
832 | + len = min(srclen, (int)le16_to_cpu(req->length)); | |
833 | 833 | |
834 | 834 | if (srcptr != NULL && len > 0) |
835 | 835 | memcpy(buffer, srcptr, len); |
drivers/video/cfb_console.c
... | ... | @@ -1541,14 +1541,14 @@ |
1541 | 1541 | |
1542 | 1542 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
1543 | 1543 | if (x == BMP_ALIGN_CENTER) |
1544 | - x = max(0, (VIDEO_VISIBLE_COLS - width) / 2); | |
1544 | + x = max(0, (int)(VIDEO_VISIBLE_COLS - width) / 2); | |
1545 | 1545 | else if (x < 0) |
1546 | - x = max(0, VIDEO_VISIBLE_COLS - width + x + 1); | |
1546 | + x = max(0, (int)(VIDEO_VISIBLE_COLS - width + x + 1)); | |
1547 | 1547 | |
1548 | 1548 | if (y == BMP_ALIGN_CENTER) |
1549 | - y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2); | |
1549 | + y = max(0, (int)(VIDEO_VISIBLE_ROWS - height) / 2); | |
1550 | 1550 | else if (y < 0) |
1551 | - y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1); | |
1551 | + y = max(0, (int)(VIDEO_VISIBLE_ROWS - height + y + 1)); | |
1552 | 1552 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
1553 | 1553 | |
1554 | 1554 | /* |
1555 | 1555 | |
1556 | 1556 | |
1557 | 1557 | |
... | ... | @@ -1874,14 +1874,14 @@ |
1874 | 1874 | |
1875 | 1875 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
1876 | 1876 | if (x == BMP_ALIGN_CENTER) |
1877 | - x = max(0, (VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2); | |
1877 | + x = max(0, (int)(VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2); | |
1878 | 1878 | else if (x < 0) |
1879 | - x = max(0, VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1); | |
1879 | + x = max(0, (int)(VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1)); | |
1880 | 1880 | |
1881 | 1881 | if (y == BMP_ALIGN_CENTER) |
1882 | - y = max(0, (VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2); | |
1882 | + y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2); | |
1883 | 1883 | else if (y < 0) |
1884 | - y = max(0, VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1); | |
1884 | + y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1)); | |
1885 | 1885 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
1886 | 1886 | |
1887 | 1887 | dest = (unsigned char *)screen + (y * width + x) * VIDEO_PIXEL_SIZE; |
... | ... | @@ -2028,7 +2028,7 @@ |
2028 | 2028 | * we need to adjust the logo height |
2029 | 2029 | */ |
2030 | 2030 | if (video_logo_ypos == BMP_ALIGN_CENTER) |
2031 | - video_logo_height += max(0, (VIDEO_VISIBLE_ROWS - \ | |
2031 | + video_logo_height += max(0, (int)(VIDEO_VISIBLE_ROWS - | |
2032 | 2032 | VIDEO_LOGO_HEIGHT) / 2); |
2033 | 2033 | else if (video_logo_ypos > 0) |
2034 | 2034 | video_logo_height += video_logo_ypos; |
fs/ext4/dev.c
... | ... | @@ -73,6 +73,7 @@ |
73 | 73 | debug(" <" LBAFU ", %d, %d>\n", sector, byte_offset, byte_len); |
74 | 74 | |
75 | 75 | if (byte_offset != 0) { |
76 | + int readlen; | |
76 | 77 | /* read first part which isn't aligned with start of sector */ |
77 | 78 | if (ext4fs_block_dev_desc-> |
78 | 79 | block_read(ext4fs_block_dev_desc->dev, |
... | ... | @@ -81,13 +82,11 @@ |
81 | 82 | printf(" ** ext2fs_devread() read error **\n"); |
82 | 83 | return 0; |
83 | 84 | } |
84 | - memcpy(buf, sec_buf + byte_offset, | |
85 | - min(ext4fs_block_dev_desc->blksz | |
86 | - - byte_offset, byte_len)); | |
87 | - buf += min(ext4fs_block_dev_desc->blksz | |
88 | - - byte_offset, byte_len); | |
89 | - byte_len -= min(ext4fs_block_dev_desc->blksz | |
90 | - - byte_offset, byte_len); | |
85 | + readlen = min((int)ext4fs_block_dev_desc->blksz - byte_offset, | |
86 | + byte_len); | |
87 | + memcpy(buf, sec_buf + byte_offset, readlen); | |
88 | + buf += readlen; | |
89 | + byte_len -= readlen; | |
91 | 90 | sector++; |
92 | 91 | } |
93 | 92 |
fs/fat/fat.c
... | ... | @@ -364,7 +364,7 @@ |
364 | 364 | |
365 | 365 | /* align to beginning of next cluster if any */ |
366 | 366 | if (pos) { |
367 | - actsize = min(filesize, bytesperclust); | |
367 | + actsize = min(filesize, (unsigned long)bytesperclust); | |
368 | 368 | if (get_cluster(mydata, curclust, get_contents_vfatname_block, |
369 | 369 | (int)actsize) != 0) { |
370 | 370 | printf("Error reading cluster\n"); |
include/linux/kernel.h
... | ... | @@ -150,26 +150,17 @@ |
150 | 150 | #define min(x, y) ({ \ |
151 | 151 | typeof(x) _min1 = (x); \ |
152 | 152 | typeof(y) _min2 = (y); \ |
153 | + (void) (&_min1 == &_min2); \ | |
153 | 154 | _min1 < _min2 ? _min1 : _min2; }) |
154 | 155 | |
155 | 156 | #define max(x, y) ({ \ |
156 | 157 | typeof(x) _max1 = (x); \ |
157 | 158 | typeof(y) _max2 = (y); \ |
159 | + (void) (&_max1 == &_max2); \ | |
158 | 160 | _max1 > _max2 ? _max1 : _max2; }) |
159 | 161 | |
160 | -#define min3(x, y, z) ({ \ | |
161 | - typeof(x) _min1 = (x); \ | |
162 | - typeof(y) _min2 = (y); \ | |
163 | - typeof(z) _min3 = (z); \ | |
164 | - _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ | |
165 | - (_min2 < _min3 ? _min2 : _min3); }) | |
166 | - | |
167 | -#define max3(x, y, z) ({ \ | |
168 | - typeof(x) _max1 = (x); \ | |
169 | - typeof(y) _max2 = (y); \ | |
170 | - typeof(z) _max3 = (z); \ | |
171 | - _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ | |
172 | - (_max2 > _max3 ? _max2 : _max3); }) | |
162 | +#define min3(x, y, z) min((typeof(x))min(x, y), z) | |
163 | +#define max3(x, y, z) max((typeof(x))max(x, y), z) | |
173 | 164 | |
174 | 165 | /** |
175 | 166 | * min_not_zero - return the minimum that is _not_ zero, unless both are zero |