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 <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Samuel Holland
2024-11-11 14:02:45 -08:00
committed by Anup Patel
parent 23ef9c5f00
commit df1c100001
12 changed files with 26 additions and 38 deletions

View File

@@ -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;