summaryrefslogtreecommitdiff
path: root/src/drivers/spi
diff options
context:
space:
mode:
authorElyes HAOUAS <ehaouas@noos.fr>2019-12-18 21:26:33 +0100
committerPatrick Georgi <pgeorgi@google.com>2019-12-20 17:48:00 +0000
commit361a935332489c635192b39204c7ec7af1667c8f (patch)
treed9e7589a4c475ba8c991c873c5600d6631f4d62d /src/drivers/spi
parentf97c1c9d86ff56ba9d1de4fc7c9499742224d365 (diff)
downloadcoreboot-361a935332489c635192b39204c7ec7af1667c8f.tar.xz
{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>
Diffstat (limited to 'src/drivers/spi')
-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
12 files changed, 25 insertions, 25 deletions
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;