Re: [kvm-unit-tests PATCH v3 06/27] devicetree: Check if fdt is NULL before returning that a DT is available

Andrew Jones
2022-07-01T09:55:30Z

Hi Nikos,

nit: The summary is a bit long. We could probably drop the "before..."
part.

On Thu, Jun 30, 2022 at 11:03:03AM +0100, Nikos Nikoleris wrote:
> Up until now, for platfroms that support DT, KUT would unconditionally
> use DT to configure the system and the code made the assumption that
> the fdt will always be a valid pointer.
>
> In Arm systems that support both ACPI and DT, we plat to follow the

s/plat/plan/

> same convension as the Linux kernel. First, we attempt to configure
> the system using the DT. If an FDT was not provided then we attempt to
> configure the system using ACPI.
>
> As a result, for Arm systems with support for ACPI the fdt pointer can
> be NULL. This change modifies dt_available() to check if the fdt is a
> valid pointer and return if we can use information from the DT.
>
> Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
> ---
> lib/devicetree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/devicetree.c b/lib/devicetree.c
> index 78c1f6f..3ff9d16 100644
> --- a/lib/devicetree.c
> +++ b/lib/devicetree.c
> @@ -16,7 +16,7 @@ const void *dt_fdt(void)
>
> bool dt_available(void)
> {
> - return fdt_check_header(fdt) == 0;
> + return fdt && fdt_check_header(fdt) == 0;
> }
>
> int dt_get_nr_cells(int fdtnode, u32 *nr_address_cells, u32 *nr_size_cells)
> --
> 2.25.1
>

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>

Thanks,
drew