summaryrefslogtreecommitdiff
path: root/lib/utils/serial
diff options
context:
space:
mode:
authorSamuel Holland <[email protected]>2024-11-11 14:02:45 -0800
committerAnup Patel <[email protected]>2024-11-28 17:09:17 +0530
commitdf1c1000014049d95d65de831f9015a2dcf9fa34 (patch)
tree09ada6ab220ee86c1169a85777c32f2f2a6a1c47 /lib/utils/serial
parent23ef9c5f00b81cffbbf7ff6894f241fad07ee4b7 (diff)
treewide: Make carray arrays const and NULL-terminated
This allows the compiler to generate significantly better code, because it does not have to maintain either the loop counter or loop limit. Plus there are half as many symbols to relocate. This also simplifies passing carray arrays to helper functions. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib/utils/serial')
-rw-r--r--lib/utils/serial/fdt_serial.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/utils/serial/fdt_serial.c b/lib/utils/serial/fdt_serial.c
index a2a96cb2..a7129bdd 100644
--- a/lib/utils/serial/fdt_serial.c
+++ b/lib/utils/serial/fdt_serial.c
@@ -14,8 +14,7 @@
#include <sbi_utils/serial/fdt_serial.h>
/* List of FDT serial drivers generated at compile time */
-extern struct fdt_serial *fdt_serial_drivers[];
-extern unsigned long fdt_serial_drivers_size;
+extern struct fdt_serial *const fdt_serial_drivers[];
int fdt_serial_init(const void *fdt)
{
@@ -46,7 +45,7 @@ int fdt_serial_init(const void *fdt)
}
/* First check DT node pointed by stdout-path */
- for (pos = 0; pos < fdt_serial_drivers_size && -1 < noff; pos++) {
+ for (pos = 0; fdt_serial_drivers[pos] && -1 < noff; pos++) {
drv = fdt_serial_drivers[pos];
match = fdt_match_node(fdt, noff, drv->match_table);
@@ -64,7 +63,7 @@ int fdt_serial_init(const void *fdt)
}
/* Lastly check all DT nodes */
- for (pos = 0; pos < fdt_serial_drivers_size; pos++) {
+ for (pos = 0; fdt_serial_drivers[pos]; pos++) {
drv = fdt_serial_drivers[pos];
noff = -1;