{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>
This commit is contained in:
parent
f97c1c9d86
commit
361a935332
|
@ -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__);
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue