Commit ffccb84c1a8e276fa7263ec4ca8186f06312305c

Authored by Hans de Goede
Committed by Simon Glass
1 parent 0bd4e39d2b

fdt: Fix regression in fdt_pack_reg()

After commit 933cdbb479: "fdt: Try to use fdt_address_cells()/fdt_size_cells()"
I noticed that allwinner boards would no longer boot.

Switching to fdt_address_cells / fdt_size_cells changes the result from
bytes to 32 bit words, so when we increment pointers into the blob, we must
do so by 32 bit words now.

This commit makes allwinner boards boot again.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Stefan Roese <sr@denx.de>
Tested-by: Vince Hsu <vinceh@nvidia.com>

Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff

common/fdt_support.c
... ... @@ -370,22 +370,22 @@
370 370 int n)
371 371 {
372 372 int i;
373   - int address_len = fdt_address_cells(fdt, 0);
374   - int size_len = fdt_size_cells(fdt, 0);
  373 + int address_cells = fdt_address_cells(fdt, 0);
  374 + int size_cells = fdt_size_cells(fdt, 0);
375 375 char *p = buf;
376 376  
377 377 for (i = 0; i < n; i++) {
378   - if (address_len == 2)
  378 + if (address_cells == 2)
379 379 *(fdt64_t *)p = cpu_to_fdt64(address[i]);
380 380 else
381 381 *(fdt32_t *)p = cpu_to_fdt32(address[i]);
382   - p += address_len;
  382 + p += 4 * address_cells;
383 383  
384   - if (size_len == 2)
  384 + if (size_cells == 2)
385 385 *(fdt64_t *)p = cpu_to_fdt64(size[i]);
386 386 else
387 387 *(fdt32_t *)p = cpu_to_fdt32(size[i]);
388   - p += size_len;
  388 + p += 4 * size_cells;
389 389 }
390 390  
391 391 return p - (char *)buf;