include/console/uart: make index parameter unsigned
The UART index is never negative, so make it unsigned and drop the
checks for the index to be non-negative.
Change-Id: I64bd60bd2a3b82552cb3ac6524792b9ac6c09a94
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/45294
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
diff --git a/src/drivers/uart/oxpcie_early.c b/src/drivers/uart/oxpcie_early.c
index b012c5a..ff7d0cf 100644
--- a/src/drivers/uart/oxpcie_early.c
+++ b/src/drivers/uart/oxpcie_early.c
@@ -55,9 +55,9 @@
return oxpcie_present;
}
-uintptr_t uart_platform_base(int idx)
+uintptr_t uart_platform_base(unsigned int idx)
{
- if ((idx >= 0) && (idx < 8) && oxpcie_uart_active())
+ if ((idx < 8) && oxpcie_uart_active())
return uart0_base + idx * 0x200;
return 0;
}
diff --git a/src/drivers/uart/pl011.c b/src/drivers/uart/pl011.c
index 2b81e76..0a73d82 100644
--- a/src/drivers/uart/pl011.c
+++ b/src/drivers/uart/pl011.c
@@ -5,11 +5,11 @@
#include <console/uart.h>
#include <drivers/uart/pl011.h>
-void uart_init(int idx)
+void uart_init(unsigned int idx)
{
}
-void uart_tx_byte(int idx, unsigned char data)
+void uart_tx_byte(unsigned int idx, unsigned char data)
{
struct pl011_uart *regs = uart_platform_baseptr(idx);
@@ -17,7 +17,7 @@
uart_tx_flush(idx);
}
-void uart_tx_flush(int idx)
+void uart_tx_flush(unsigned int idx)
{
struct pl011_uart *regs = uart_platform_baseptr(idx);
@@ -26,7 +26,7 @@
;
}
-unsigned char uart_rx_byte(int idx)
+unsigned char uart_rx_byte(unsigned int idx)
{
struct pl011_uart *regs = uart_platform_baseptr(idx);
diff --git a/src/drivers/uart/sifive.c b/src/drivers/uart/sifive.c
index 0c94c6a..31181aa 100644
--- a/src/drivers/uart/sifive.c
+++ b/src/drivers/uart/sifive.c
@@ -45,7 +45,7 @@
write32(®s->rxctrl, RXCTRL_RXEN|RXCTRL_RXCNT(0));
}
-void uart_init(int idx)
+void uart_init(unsigned int idx)
{
unsigned int div;
div = uart_baudrate_divisor(get_uart_baudrate(),
@@ -58,7 +58,7 @@
return !(read32(®s->txdata) & TXDATA_FULL);
}
-void uart_tx_byte(int idx, unsigned char data)
+void uart_tx_byte(unsigned int idx, unsigned char data)
{
struct sifive_uart_registers *regs = uart_platform_baseptr(idx);
@@ -68,7 +68,7 @@
write32(®s->txdata, data);
}
-void uart_tx_flush(int idx)
+void uart_tx_flush(unsigned int idx)
{
struct sifive_uart_registers *regs = uart_platform_baseptr(idx);
uint32_t ip;
@@ -79,7 +79,7 @@
} while (!(ip & IP_TXWM));
}
-unsigned char uart_rx_byte(int idx)
+unsigned char uart_rx_byte(unsigned int idx)
{
struct sifive_uart_registers *regs = uart_platform_baseptr(idx);
uint32_t rxdata;
diff --git a/src/drivers/uart/uart8250io.c b/src/drivers/uart/uart8250io.c
index 22b79e8..d0841de 100644
--- a/src/drivers/uart/uart8250io.c
+++ b/src/drivers/uart/uart8250io.c
@@ -77,14 +77,14 @@
static const unsigned int bases[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
-uintptr_t uart_platform_base(int idx)
+uintptr_t uart_platform_base(unsigned int idx)
{
if (idx < ARRAY_SIZE(bases))
return bases[idx];
return 0;
}
-void uart_init(int idx)
+void uart_init(unsigned int idx)
{
if (!CONFIG(DRIVERS_UART_8250IO_SKIP_INIT)) {
unsigned int div;
@@ -94,17 +94,17 @@
}
}
-void uart_tx_byte(int idx, unsigned char data)
+void uart_tx_byte(unsigned int idx, unsigned char data)
{
uart8250_tx_byte(uart_platform_base(idx), data);
}
-unsigned char uart_rx_byte(int idx)
+unsigned char uart_rx_byte(unsigned int idx)
{
return uart8250_rx_byte(uart_platform_base(idx));
}
-void uart_tx_flush(int idx)
+void uart_tx_flush(unsigned int idx)
{
uart8250_tx_flush(uart_platform_base(idx));
}
diff --git a/src/drivers/uart/uart8250mem.c b/src/drivers/uart/uart8250mem.c
index 8d73272..1834095 100644
--- a/src/drivers/uart/uart8250mem.c
+++ b/src/drivers/uart/uart8250mem.c
@@ -97,7 +97,7 @@
uart8250_write(base, UART8250_LCR, CONFIG_TTYS0_LCS);
}
-void uart_init(int idx)
+void uart_init(unsigned int idx)
{
void *base = uart_platform_baseptr(idx);
if (!base)
@@ -109,7 +109,7 @@
uart8250_mem_init(base, div);
}
-void uart_tx_byte(int idx, unsigned char data)
+void uart_tx_byte(unsigned int idx, unsigned char data)
{
void *base = uart_platform_baseptr(idx);
if (!base)
@@ -117,7 +117,7 @@
uart8250_mem_tx_byte(base, data);
}
-unsigned char uart_rx_byte(int idx)
+unsigned char uart_rx_byte(unsigned int idx)
{
void *base = uart_platform_baseptr(idx);
if (!base)
@@ -125,7 +125,7 @@
return uart8250_mem_rx_byte(base);
}
-void uart_tx_flush(int idx)
+void uart_tx_flush(unsigned int idx)
{
void *base = uart_platform_baseptr(idx);
if (!base)