forked from Mirrors/opensbi
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:

committed by
Anup Patel

parent
23ef9c5f00
commit
df1c100001
@@ -13,8 +13,7 @@
|
||||
#include <sbi_utils/gpio/fdt_gpio.h>
|
||||
|
||||
/* List of FDT gpio drivers generated at compile time */
|
||||
extern struct fdt_gpio *fdt_gpio_drivers[];
|
||||
extern unsigned long fdt_gpio_drivers_size;
|
||||
extern struct fdt_gpio *const fdt_gpio_drivers[];
|
||||
|
||||
static int fdt_gpio_init(const void *fdt, int nodeoff)
|
||||
{
|
||||
@@ -27,7 +26,7 @@ static int fdt_gpio_init(const void *fdt, int nodeoff)
|
||||
return SBI_EINVAL;
|
||||
|
||||
/* Try all GPIO drivers one-by-one */
|
||||
for (pos = 0; pos < fdt_gpio_drivers_size; pos++) {
|
||||
for (pos = 0; fdt_gpio_drivers[pos]; pos++) {
|
||||
drv = fdt_gpio_drivers[pos];
|
||||
|
||||
match = fdt_match_node(fdt, nodeoff, drv->match_table);
|
||||
|
@@ -17,8 +17,7 @@
|
||||
#include <sbi_utils/i2c/fdt_i2c.h>
|
||||
|
||||
/* List of FDT i2c adapter drivers generated at compile time */
|
||||
extern struct fdt_i2c_adapter *fdt_i2c_adapter_drivers[];
|
||||
extern unsigned long fdt_i2c_adapter_drivers_size;
|
||||
extern struct fdt_i2c_adapter *const fdt_i2c_adapter_drivers[];
|
||||
|
||||
static int fdt_i2c_adapter_init(const void *fdt, int nodeoff)
|
||||
{
|
||||
@@ -27,7 +26,7 @@ static int fdt_i2c_adapter_init(const void *fdt, int nodeoff)
|
||||
const struct fdt_match *match;
|
||||
|
||||
/* Try all I2C drivers one-by-one */
|
||||
for (pos = 0; pos < fdt_i2c_adapter_drivers_size; pos++) {
|
||||
for (pos = 0; fdt_i2c_adapter_drivers[pos]; pos++) {
|
||||
drv = fdt_i2c_adapter_drivers[pos];
|
||||
match = fdt_match_node(fdt, nodeoff, drv->match_table);
|
||||
if (match && drv->init) {
|
||||
|
@@ -13,8 +13,7 @@
|
||||
#include <sbi_utils/ipi/fdt_ipi.h>
|
||||
|
||||
/* List of FDT ipi drivers generated at compile time */
|
||||
extern struct fdt_ipi *fdt_ipi_drivers[];
|
||||
extern unsigned long fdt_ipi_drivers_size;
|
||||
extern struct fdt_ipi *const fdt_ipi_drivers[];
|
||||
|
||||
int fdt_ipi_init(void)
|
||||
{
|
||||
@@ -23,7 +22,7 @@ int fdt_ipi_init(void)
|
||||
const struct fdt_match *match;
|
||||
const void *fdt = fdt_get_address();
|
||||
|
||||
for (pos = 0; pos < fdt_ipi_drivers_size; pos++) {
|
||||
for (pos = 0; fdt_ipi_drivers[pos]; pos++) {
|
||||
drv = fdt_ipi_drivers[pos];
|
||||
|
||||
noff = -1;
|
||||
|
@@ -13,8 +13,7 @@
|
||||
#include <sbi_utils/irqchip/fdt_irqchip.h>
|
||||
|
||||
/* List of FDT irqchip drivers generated at compile time */
|
||||
extern struct fdt_irqchip *fdt_irqchip_drivers[];
|
||||
extern unsigned long fdt_irqchip_drivers_size;
|
||||
extern struct fdt_irqchip *const fdt_irqchip_drivers[];
|
||||
|
||||
int fdt_irqchip_init(void)
|
||||
{
|
||||
@@ -23,7 +22,7 @@ int fdt_irqchip_init(void)
|
||||
const struct fdt_match *match;
|
||||
const void *fdt = fdt_get_address();
|
||||
|
||||
for (pos = 0; pos < fdt_irqchip_drivers_size; pos++) {
|
||||
for (pos = 0; fdt_irqchip_drivers[pos]; pos++) {
|
||||
drv = fdt_irqchip_drivers[pos];
|
||||
|
||||
noff = -1;
|
||||
|
@@ -13,8 +13,7 @@
|
||||
#include <sbi_utils/regmap/fdt_regmap.h>
|
||||
|
||||
/* List of FDT regmap drivers generated at compile time */
|
||||
extern struct fdt_regmap *fdt_regmap_drivers[];
|
||||
extern unsigned long fdt_regmap_drivers_size;
|
||||
extern struct fdt_regmap *const fdt_regmap_drivers[];
|
||||
|
||||
static int fdt_regmap_init(const void *fdt, int nodeoff)
|
||||
{
|
||||
@@ -23,7 +22,7 @@ static int fdt_regmap_init(const void *fdt, int nodeoff)
|
||||
const struct fdt_match *match;
|
||||
|
||||
/* Try all I2C drivers one-by-one */
|
||||
for (pos = 0; pos < fdt_regmap_drivers_size; pos++) {
|
||||
for (pos = 0; fdt_regmap_drivers[pos]; pos++) {
|
||||
drv = fdt_regmap_drivers[pos];
|
||||
match = fdt_match_node(fdt, nodeoff, drv->match_table);
|
||||
if (match && drv->init) {
|
||||
|
@@ -14,8 +14,7 @@
|
||||
#include <sbi_utils/reset/fdt_reset.h>
|
||||
|
||||
/* List of FDT reset drivers generated at compile time */
|
||||
extern struct fdt_reset *fdt_reset_drivers[];
|
||||
extern unsigned long fdt_reset_drivers_size;
|
||||
extern struct fdt_reset *const fdt_reset_drivers[];
|
||||
|
||||
int fdt_reset_driver_init(const void *fdt, struct fdt_reset *drv)
|
||||
{
|
||||
@@ -46,6 +45,6 @@ void fdt_reset_init(const void *fdt)
|
||||
{
|
||||
int pos;
|
||||
|
||||
for (pos = 0; pos < fdt_reset_drivers_size; pos++)
|
||||
for (pos = 0; fdt_reset_drivers[pos]; pos++)
|
||||
fdt_reset_driver_init(fdt, fdt_reset_drivers[pos]);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -13,8 +13,7 @@
|
||||
#include <sbi_utils/timer/fdt_timer.h>
|
||||
|
||||
/* List of FDT timer drivers generated at compile time */
|
||||
extern struct fdt_timer *fdt_timer_drivers[];
|
||||
extern unsigned long fdt_timer_drivers_size;
|
||||
extern struct fdt_timer *const fdt_timer_drivers[];
|
||||
|
||||
int fdt_timer_init(void)
|
||||
{
|
||||
@@ -23,7 +22,7 @@ int fdt_timer_init(void)
|
||||
const struct fdt_match *match;
|
||||
const void *fdt = fdt_get_address();
|
||||
|
||||
for (pos = 0; pos < fdt_timer_drivers_size; pos++) {
|
||||
for (pos = 0; fdt_timer_drivers[pos]; pos++) {
|
||||
drv = fdt_timer_drivers[pos];
|
||||
|
||||
noff = -1;
|
||||
|
Reference in New Issue
Block a user