summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/i2c/tpm/cr50.c6
-rw-r--r--src/drivers/i2c/tpm/tis_atmel.c4
-rw-r--r--src/drivers/pc80/tpm/tis.c4
-rw-r--r--src/drivers/spi/adesto.c4
-rw-r--r--src/drivers/spi/amic.c4
-rw-r--r--src/drivers/spi/atmel.c4
-rw-r--r--src/drivers/spi/eon.c4
-rw-r--r--src/drivers/spi/flashconsole.c4
-rw-r--r--src/drivers/spi/gigadevice.c4
-rw-r--r--src/drivers/spi/macronix.c4
-rw-r--r--src/drivers/spi/spansion.c4
-rw-r--r--src/drivers/spi/spi-generic.c4
-rw-r--r--src/drivers/spi/sst.c4
-rw-r--r--src/drivers/spi/stmicro.c4
-rw-r--r--src/drivers/spi/winbond.c6
-rw-r--r--src/southbridge/intel/common/spi.c10
16 files changed, 37 insertions, 37 deletions
diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c
index 8ea544d0db..34873dc9e4 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 @@ static int cr50_i2c_tis_recv(struct tpm_chip *chip, uint8_t *buf,
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 @@ static int cr50_i2c_tis_send(struct tpm_chip *chip, uint8_t *buf, size_t len)
/* 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 793418a96a..74b4830b6a 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 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t sbuf_size,
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 39fa70db3f..e9f14854c4 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 @@ static u32 tis_senddata(const u8 *const data, u32 len)
* 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 f671247fba..974f8ad146 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 @@ static int adesto_write(const struct spi_flash *flash, u32 offset, size_t len,
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 9a23d9b527..254a5b2cff 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 @@ static int amic_write(const struct spi_flash *flash, u32 offset, size_t len,
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 88321f03a2..4496f4b08c 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 @@ static int atmel_write(const struct spi_flash *flash, u32 offset, size_t len,
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 a469fe228a..2cdbdbbe8d 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 @@ static int eon_write(const struct spi_flash *flash,
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 98f3cb4796..80c63e07ea 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 @@ void flashconsole_init(void)
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 9afc355336..65494fa240 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 @@ static int gigadevice_write(const struct spi_flash *flash, u32 offset,
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 29489ee235..6643dfa579 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 @@ static int macronix_write(const struct spi_flash *flash, u32 offset, size_t len,
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 cb665d0a59..0b119ebe98 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 @@ static int spansion_write(const struct spi_flash *flash, u32 offset, size_t len,
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 05bfb82bf8..bc4fb086cd 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 @@ unsigned int spi_crop_chunk(const struct spi_slave *slave, unsigned int cmd_len,
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 5367b70d21..6223cf98da 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 @@ static int sst_write_256(const struct spi_flash *flash, u32 offset, size_t len,
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 d397e6e669..ad0a0dc538 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 @@ static int stmicro_write(const struct spi_flash *flash,
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 432ad6a47e..3790ce7bf1 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 @@ static int winbond_write(const struct spi_flash *flash, u32 offset, size_t len,
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 @@ static void winbond_bpbits_to_region(const size_t granularity,
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 cf678176ab..63206d0a83 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 @@ static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
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 @@ static int ich_hwseq_read(const struct spi_flash *flash, u32 addr, size_t len,
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 @@ static int ich_hwseq_write(const struct spi_flash *flash, u32 addr, size_t len,
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;