lib: utils/reset: Pass the FDT to fdt_reset_init()

Indicate that this function does not modify the FDT blob, and
deduplicate the call to fdt_get_address().

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Samuel Holland
2024-07-30 21:58:55 -07:00
committed by Anup Patel
parent 6e5db7b09c
commit fa6dfce017
3 changed files with 4 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ int fdt_reset_driver_init(const void *fdt, struct fdt_reset *drv);
* *
* This function shall be invoked in final init. * This function shall be invoked in final init.
*/ */
void fdt_reset_init(void); void fdt_reset_init(const void *fdt);
#else #else
@@ -37,7 +37,7 @@ static inline int fdt_reset_driver_init(const void *fdt, struct fdt_reset *drv)
{ {
return 0; return 0;
} }
static inline void fdt_reset_init(void) { } static inline void fdt_reset_init(const void *fdt) { }
#endif #endif

View File

@@ -42,10 +42,9 @@ int fdt_reset_driver_init(const void *fdt, struct fdt_reset *drv)
return cnt > 0 ? 0 : SBI_ENODEV; return cnt > 0 ? 0 : SBI_ENODEV;
} }
void fdt_reset_init(void) void fdt_reset_init(const void *fdt)
{ {
int pos; int pos;
const void *fdt = fdt_get_address();
for (pos = 0; pos < fdt_reset_drivers_size; pos++) for (pos = 0; pos < fdt_reset_drivers_size; pos++)
fdt_reset_driver_init(fdt, fdt_reset_drivers[pos]); fdt_reset_driver_init(fdt, fdt_reset_drivers[pos]);

View File

@@ -225,7 +225,7 @@ static int generic_early_init(bool cold_boot)
int rc; int rc;
if (cold_boot) { if (cold_boot) {
fdt_reset_init(); fdt_reset_init(fdt);
if (semihosting_enabled()) if (semihosting_enabled())
rc = semihosting_init(); rc = semihosting_init();