HAOUAS Elyes has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37818 )
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
{drivers,southbridge}: Replace min() with MIN()
Change-Id: Ica03d9aec8a81f57709abcac655dfb0ebce3f8c6 Signed-off-by: Elyes HAOUAS ehaouas@noos.fr --- M src/drivers/i2c/tpm/cr50.c M src/drivers/i2c/tpm/tis_atmel.c M src/drivers/pc80/tpm/tis.c M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/eon.c M src/drivers/spi/flashconsole.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/spi-generic.c M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/southbridge/intel/common/spi.c 16 files changed, 37 insertions(+), 37 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/18/37818/1
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index 8ea544d..34873dc 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -28,6 +28,7 @@ */
#include <commonlib/endian.h> +#include <commonlib/helpers.h> #include <string.h> #include <types.h> #include <delay.h> @@ -36,7 +37,6 @@ #include <endian.h> #include <timer.h> #include <security/tpm/tis.h> -#include <stdlib.h>
#include "tpm.h"
@@ -341,7 +341,7 @@ if (cr50_i2c_wait_burststs(chip, mask, &burstcnt, &status) < 0) goto out_err;
- len = min(burstcnt, expected - current); + len = MIN(burstcnt, expected - current); if (cr50_i2c_read(chip, addr, buf + current, len) != 0) { printk(BIOS_ERR, "%s: Read failed\n", __func__); goto out_err; @@ -400,7 +400,7 @@
/* Use burstcnt - 1 to account for the address byte * that is inserted by cr50_i2c_write() */ - limit = min(burstcnt - 1, len); + limit = MIN(burstcnt - 1, len); if (cr50_i2c_write(chip, TPM_DATA_FIFO(chip->vendor.locality), &buf[sent], limit) != 0) { printk(BIOS_ERR, "%s: Write failed\n", __func__); diff --git a/src/drivers/i2c/tpm/tis_atmel.c b/src/drivers/i2c/tpm/tis_atmel.c index 793418a..74b4830 100644 --- a/src/drivers/i2c/tpm/tis_atmel.c +++ b/src/drivers/i2c/tpm/tis_atmel.c @@ -14,13 +14,13 @@
#include <assert.h> #include <commonlib/endian.h> +#include <commonlib/helpers.h> #include <console/console.h> #include <delay.h> #include <device/i2c_simple.h> #include <endian.h> #include <lib.h> #include <security/tpm/tis.h> -#include <stdlib.h> #include <timer.h> #include <types.h>
@@ -99,7 +99,7 @@ return -1;
/* Determine the number of bytes remaining */ - recv_bytes = min(be32_to_cpu(*(uint32_t *)&header->length), + recv_bytes = MIN(be32_to_cpu(*(uint32_t *)&header->length), max_recv_bytes);
/* Determine if there is additional response data */ diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c index 39fa70d..e9f1485 100644 --- a/src/drivers/pc80/tpm/tis.c +++ b/src/drivers/pc80/tpm/tis.c @@ -21,7 +21,7 @@ * Infineon slb9635), so this driver provides access to locality 0 only. */
-#include <stdlib.h> +#include <commonlib/helpers.h> #include <string.h> #include <delay.h> #include <device/mmio.h> @@ -488,7 +488,7 @@ * changes to zero exactly after the last byte is fed into the * FIFO. */ - count = min(burst, len - offset - 1); + count = MIN(burst, len - offset - 1); while (count--) tpm_write_data(data[offset++], locality);
diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index f671247..974f8ad 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -18,7 +18,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <string.h> #include <spi_flash.h> #include <spi-generic.h> @@ -162,7 +162,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_AT25DF_PP; diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index 9a23d9b..254a5b2 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -133,7 +133,7 @@ byte_addr = offset % page_size;
for (actual = 0; actual < len; actual += chunk_len) { - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_A25_PP; diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c index 88321f0..4496f4b 100644 --- a/src/drivers/spi/atmel.c +++ b/src/drivers/spi/atmel.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -117,7 +117,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_AT25_PP; diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c index a469fe2..2cdbdbb 100644 --- a/src/drivers/spi/eon.c +++ b/src/drivers/spi/eon.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -249,7 +249,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
ret = spi_flash_cmd(&flash->spi, CMD_EN25_WREN, NULL, 0); diff --git a/src/drivers/spi/flashconsole.c b/src/drivers/spi/flashconsole.c index 98f3cb4..80c63e0 100644 --- a/src/drivers/spi/flashconsole.c +++ b/src/drivers/spi/flashconsole.c @@ -11,12 +11,12 @@ * GNU General Public License for more details. */
+#include <commonlib/helpers.h> #include <commonlib/region.h> #include <boot_device.h> #include <fmap.h> #include <console/console.h> #include <console/flash.h> -#include <stdlib.h> #include <types.h>
#define LINE_BUFFER_SIZE 128 @@ -55,7 +55,7 @@ for (i = 0; i < len && offset < size;) { // Fill the buffer on first iteration if (i == 0) { - len = min(READ_BUFFER_SIZE, size - offset); + len = MIN(READ_BUFFER_SIZE, size - offset); if (rdev_readat(&rdev, buffer, offset, len) != len) return; } diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index 9afc355..65494fa 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -178,7 +178,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
ret = spi_flash_cmd(&flash->spi, CMD_GD25_WREN, NULL, 0); diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 29489ee..6643dfa 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -214,7 +214,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_MX25XX_PP; diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c index cb665d0..0b119eb 100644 --- a/src/drivers/spi/spansion.c +++ b/src/drivers/spi/spansion.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -232,7 +232,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_S25FLXX_PP; diff --git a/src/drivers/spi/spi-generic.c b/src/drivers/spi/spi-generic.c index 05bfb82..bc4fb08 100644 --- a/src/drivers/spi/spi-generic.c +++ b/src/drivers/spi/spi-generic.c @@ -13,9 +13,9 @@ */
#include <assert.h> +#include <commonlib/helpers.h> #include <spi-generic.h> #include <stddef.h> -#include <stdlib.h> #include <string.h>
int spi_claim_bus(const struct spi_slave *slave) @@ -113,7 +113,7 @@ if (deduct_cmd_len && (ctrlr_max > cmd_len)) ctrlr_max -= cmd_len;
- return min(ctrlr_max, buf_len); + return MIN(ctrlr_max, buf_len); }
void __weak spi_init(void) diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c index 5367b70..6223cf9 100644 --- a/src/drivers/spi/sst.c +++ b/src/drivers/spi/sst.c @@ -17,7 +17,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -217,7 +217,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_SST_BP; diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index d397e6e..ad0a0dc 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -298,7 +298,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_M25PXX_PP; diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index 432ad6a..3790ce7 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -310,7 +310,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_W25_PP; @@ -366,7 +366,7 @@ struct region *out) { size_t protected_size = - min(bp ? granularity << (bp - 1) : 0, flash_size); + MIN(bp ? granularity << (bp - 1) : 0, flash_size);
if (cmp) { protected_size = flash_size - protected_size; diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index cf67817..63206d0 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -18,8 +18,8 @@ #define __SIMPLE_DEVICE__
/* This file is derived from the flashrom project. */ + #include <stdint.h> -#include <stdlib.h> #include <string.h> #include <bootstate.h> #include <commonlib/helpers.h> @@ -637,9 +637,9 @@ writel_(trans.offset & 0x00FFFFFF, cntlr.addr);
if (trans.bytesout) - data_length = min(trans.bytesout, cntlr.databytes); + data_length = MIN(trans.bytesout, cntlr.databytes); else - data_length = min(trans.bytesin, cntlr.databytes); + data_length = MIN(trans.bytesin, cntlr.databytes);
/* Program data into FDATA0 to N */ if (trans.bytesout) { @@ -815,7 +815,7 @@ writew_(readw_(&cntlr.ich9_spi->hsfs), &cntlr.ich9_spi->hsfs);
while (len > 0) { - block_len = min(len, cntlr.databytes); + block_len = MIN(len, cntlr.databytes); if (block_len > (~addr & 0xff)) block_len = (~addr & 0xff) + 1; ich_hwseq_set_addr(addr); @@ -883,7 +883,7 @@ writew_(readw_(&cntlr.ich9_spi->hsfs), &cntlr.ich9_spi->hsfs);
while (len > 0) { - block_len = min(len, cntlr.databytes); + block_len = MIN(len, cntlr.databytes); if (block_len > (~addr & 0xff)) block_len = (~addr & 0xff) + 1;
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37818 )
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37818/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37818/2//COMMIT_MSG@7 PS2, Line 7: {drivers,southbridge}: Replace min() with MIN() Why?
Hello Kyösti Mälkki, Patrick Rudolph, Philipp Deppenwiese, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/37818
to look at the new patch set (#3).
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
{drivers,southbridge}: Replace min() with MIN()
This is to remove min/max() from <stdlib.h>.
Change-Id: Ica03d9aec8a81f57709abcac655dfb0ebce3f8c6 Signed-off-by: Elyes HAOUAS ehaouas@noos.fr --- M src/drivers/i2c/tpm/cr50.c M src/drivers/i2c/tpm/tis_atmel.c M src/drivers/pc80/tpm/tis.c M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/eon.c M src/drivers/spi/flashconsole.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/spi-generic.c M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/southbridge/intel/common/spi.c 16 files changed, 37 insertions(+), 37 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/18/37818/3
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37818 )
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37818/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/37818/2//COMMIT_MSG@7 PS2, Line 7: {drivers,southbridge}: Replace min() with MIN()
Why?
1- min()/max() , here looks like a function not a macro 2- to remove min()/max() from stdlib.h
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37818 )
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
Patch Set 4: Code-Review+1
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37818 )
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
Patch Set 4: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/37818 )
Change subject: {drivers,southbridge}: Replace min() with MIN() ......................................................................
{drivers,southbridge}: Replace min() with MIN()
This is to remove min/max() from <stdlib.h>.
Change-Id: Ica03d9aec8a81f57709abcac655dfb0ebce3f8c6 Signed-off-by: Elyes HAOUAS ehaouas@noos.fr Reviewed-on: https://review.coreboot.org/c/coreboot/+/37818 Reviewed-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-by: Patrick Georgi pgeorgi@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/i2c/tpm/cr50.c M src/drivers/i2c/tpm/tis_atmel.c M src/drivers/pc80/tpm/tis.c M src/drivers/spi/adesto.c M src/drivers/spi/amic.c M src/drivers/spi/atmel.c M src/drivers/spi/eon.c M src/drivers/spi/flashconsole.c M src/drivers/spi/gigadevice.c M src/drivers/spi/macronix.c M src/drivers/spi/spansion.c M src/drivers/spi/spi-generic.c M src/drivers/spi/sst.c M src/drivers/spi/stmicro.c M src/drivers/spi/winbond.c M src/southbridge/intel/common/spi.c 16 files changed, 37 insertions(+), 37 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved Kyösti Mälkki: Looks good to me, but someone else must approve
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index 8ea544d..34873dc 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -28,6 +28,7 @@ */
#include <commonlib/endian.h> +#include <commonlib/helpers.h> #include <string.h> #include <types.h> #include <delay.h> @@ -36,7 +37,6 @@ #include <endian.h> #include <timer.h> #include <security/tpm/tis.h> -#include <stdlib.h>
#include "tpm.h"
@@ -341,7 +341,7 @@ if (cr50_i2c_wait_burststs(chip, mask, &burstcnt, &status) < 0) goto out_err;
- len = min(burstcnt, expected - current); + len = MIN(burstcnt, expected - current); if (cr50_i2c_read(chip, addr, buf + current, len) != 0) { printk(BIOS_ERR, "%s: Read failed\n", __func__); goto out_err; @@ -400,7 +400,7 @@
/* Use burstcnt - 1 to account for the address byte * that is inserted by cr50_i2c_write() */ - limit = min(burstcnt - 1, len); + limit = MIN(burstcnt - 1, len); if (cr50_i2c_write(chip, TPM_DATA_FIFO(chip->vendor.locality), &buf[sent], limit) != 0) { printk(BIOS_ERR, "%s: Write failed\n", __func__); diff --git a/src/drivers/i2c/tpm/tis_atmel.c b/src/drivers/i2c/tpm/tis_atmel.c index 793418a..74b4830 100644 --- a/src/drivers/i2c/tpm/tis_atmel.c +++ b/src/drivers/i2c/tpm/tis_atmel.c @@ -14,13 +14,13 @@
#include <assert.h> #include <commonlib/endian.h> +#include <commonlib/helpers.h> #include <console/console.h> #include <delay.h> #include <device/i2c_simple.h> #include <endian.h> #include <lib.h> #include <security/tpm/tis.h> -#include <stdlib.h> #include <timer.h> #include <types.h>
@@ -99,7 +99,7 @@ return -1;
/* Determine the number of bytes remaining */ - recv_bytes = min(be32_to_cpu(*(uint32_t *)&header->length), + recv_bytes = MIN(be32_to_cpu(*(uint32_t *)&header->length), max_recv_bytes);
/* Determine if there is additional response data */ diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c index 39fa70d..e9f1485 100644 --- a/src/drivers/pc80/tpm/tis.c +++ b/src/drivers/pc80/tpm/tis.c @@ -21,7 +21,7 @@ * Infineon slb9635), so this driver provides access to locality 0 only. */
-#include <stdlib.h> +#include <commonlib/helpers.h> #include <string.h> #include <delay.h> #include <device/mmio.h> @@ -488,7 +488,7 @@ * changes to zero exactly after the last byte is fed into the * FIFO. */ - count = min(burst, len - offset - 1); + count = MIN(burst, len - offset - 1); while (count--) tpm_write_data(data[offset++], locality);
diff --git a/src/drivers/spi/adesto.c b/src/drivers/spi/adesto.c index f671247..974f8ad 100644 --- a/src/drivers/spi/adesto.c +++ b/src/drivers/spi/adesto.c @@ -18,7 +18,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <string.h> #include <spi_flash.h> #include <spi-generic.h> @@ -162,7 +162,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_AT25DF_PP; diff --git a/src/drivers/spi/amic.c b/src/drivers/spi/amic.c index 9a23d9b..254a5b2 100644 --- a/src/drivers/spi/amic.c +++ b/src/drivers/spi/amic.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -133,7 +133,7 @@ byte_addr = offset % page_size;
for (actual = 0; actual < len; actual += chunk_len) { - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_A25_PP; diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c index 88321f0..4496f4b 100644 --- a/src/drivers/spi/atmel.c +++ b/src/drivers/spi/atmel.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -117,7 +117,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_AT25_PP; diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c index a469fe2..2cdbdbb 100644 --- a/src/drivers/spi/eon.c +++ b/src/drivers/spi/eon.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -249,7 +249,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
ret = spi_flash_cmd(&flash->spi, CMD_EN25_WREN, NULL, 0); diff --git a/src/drivers/spi/flashconsole.c b/src/drivers/spi/flashconsole.c index 98f3cb4..80c63e0 100644 --- a/src/drivers/spi/flashconsole.c +++ b/src/drivers/spi/flashconsole.c @@ -11,12 +11,12 @@ * GNU General Public License for more details. */
+#include <commonlib/helpers.h> #include <commonlib/region.h> #include <boot_device.h> #include <fmap.h> #include <console/console.h> #include <console/flash.h> -#include <stdlib.h> #include <types.h>
#define LINE_BUFFER_SIZE 128 @@ -55,7 +55,7 @@ for (i = 0; i < len && offset < size;) { // Fill the buffer on first iteration if (i == 0) { - len = min(READ_BUFFER_SIZE, size - offset); + len = MIN(READ_BUFFER_SIZE, size - offset); if (rdev_readat(&rdev, buffer, offset, len) != len) return; } diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index 9afc355..65494fa 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -178,7 +178,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
ret = spi_flash_cmd(&flash->spi, CMD_GD25_WREN, NULL, 0); diff --git a/src/drivers/spi/macronix.c b/src/drivers/spi/macronix.c index 29489ee..6643dfa 100644 --- a/src/drivers/spi/macronix.c +++ b/src/drivers/spi/macronix.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -214,7 +214,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_MX25XX_PP; diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c index cb665d0..0b119eb 100644 --- a/src/drivers/spi/spansion.c +++ b/src/drivers/spi/spansion.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -232,7 +232,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_S25FLXX_PP; diff --git a/src/drivers/spi/spi-generic.c b/src/drivers/spi/spi-generic.c index 05bfb82..bc4fb08 100644 --- a/src/drivers/spi/spi-generic.c +++ b/src/drivers/spi/spi-generic.c @@ -13,9 +13,9 @@ */
#include <assert.h> +#include <commonlib/helpers.h> #include <spi-generic.h> #include <stddef.h> -#include <stdlib.h> #include <string.h>
int spi_claim_bus(const struct spi_slave *slave) @@ -113,7 +113,7 @@ if (deduct_cmd_len && (ctrlr_max > cmd_len)) ctrlr_max -= cmd_len;
- return min(ctrlr_max, buf_len); + return MIN(ctrlr_max, buf_len); }
void __weak spi_init(void) diff --git a/src/drivers/spi/sst.c b/src/drivers/spi/sst.c index 5367b70..6223cf9 100644 --- a/src/drivers/spi/sst.c +++ b/src/drivers/spi/sst.c @@ -17,7 +17,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -217,7 +217,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_SST_BP; diff --git a/src/drivers/spi/stmicro.c b/src/drivers/spi/stmicro.c index d397e6e..ad0a0dc 100644 --- a/src/drivers/spi/stmicro.c +++ b/src/drivers/spi/stmicro.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -298,7 +298,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_M25PXX_PP; diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index 432ad6a..3790ce7 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -13,7 +13,7 @@ */
#include <console/console.h> -#include <stdlib.h> +#include <commonlib/helpers.h> #include <spi_flash.h> #include <spi-generic.h> #include <string.h> @@ -310,7 +310,7 @@
for (actual = 0; actual < len; actual += chunk_len) { byte_addr = offset % page_size; - chunk_len = min(len - actual, page_size - byte_addr); + chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len);
cmd[0] = CMD_W25_PP; @@ -366,7 +366,7 @@ struct region *out) { size_t protected_size = - min(bp ? granularity << (bp - 1) : 0, flash_size); + MIN(bp ? granularity << (bp - 1) : 0, flash_size);
if (cmp) { protected_size = flash_size - protected_size; diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index cf67817..63206d0 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -18,8 +18,8 @@ #define __SIMPLE_DEVICE__
/* This file is derived from the flashrom project. */ + #include <stdint.h> -#include <stdlib.h> #include <string.h> #include <bootstate.h> #include <commonlib/helpers.h> @@ -637,9 +637,9 @@ writel_(trans.offset & 0x00FFFFFF, cntlr.addr);
if (trans.bytesout) - data_length = min(trans.bytesout, cntlr.databytes); + data_length = MIN(trans.bytesout, cntlr.databytes); else - data_length = min(trans.bytesin, cntlr.databytes); + data_length = MIN(trans.bytesin, cntlr.databytes);
/* Program data into FDATA0 to N */ if (trans.bytesout) { @@ -815,7 +815,7 @@ writew_(readw_(&cntlr.ich9_spi->hsfs), &cntlr.ich9_spi->hsfs);
while (len > 0) { - block_len = min(len, cntlr.databytes); + block_len = MIN(len, cntlr.databytes); if (block_len > (~addr & 0xff)) block_len = (~addr & 0xff) + 1; ich_hwseq_set_addr(addr); @@ -883,7 +883,7 @@ writew_(readw_(&cntlr.ich9_spi->hsfs), &cntlr.ich9_spi->hsfs);
while (len > 0) { - block_len = min(len, cntlr.databytes); + block_len = MIN(len, cntlr.databytes); if (block_len > (~addr & 0xff)) block_len = (~addr & 0xff) + 1;