Skip to content
Snippets Groups Projects
Commit 71105f50 authored by Przemyslaw Marczak's avatar Przemyslaw Marczak Committed by Simon Glass
Browse files

fdt: fix address cell count checking in fdt_translate_address()


Commit: dm: core: Enable optional use of fdt_translate_address()

Enables use of this function as default, but after this it's not
possible to get dev address for the case in which: '#size-cells == 0'

This causes errors when getting address for some GPIOs, for which
the '#size-cells' is set to 0.

Example error:
'__of_translate_address: Bad cell count for gpx0'

Allowing for that case by modifying the macro 'OF_CHECK_COUNTS',
(called from )__of_translate_address(), fixes the issue.

Now, this macro doesn't check, that '#size-cells' is greater than 0.

This is possible from the specification point of view, but I'm not sure
that it doesn't introduce a regression for other configs.

Please test and share the results.

Tested-on: Odroid U3, Odroid X2, Odroid XU3, Sandbox.

Signed-off-by: default avatarPrzemyslaw Marczak <p.marczak@samsung.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Tested-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
Tested-by: default avatarLukasz Majewski <l.majewski@samsung.com>
parent 8a834870
No related branches found
No related tags found
No related merge requests found
...@@ -952,8 +952,7 @@ void fdt_del_node_and_alias(void *blob, const char *alias) ...@@ -952,8 +952,7 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
/* Max address size we deal with */ /* Max address size we deal with */
#define OF_MAX_ADDR_CELLS 4 #define OF_MAX_ADDR_CELLS 4
#define OF_BAD_ADDR FDT_ADDR_T_NONE #define OF_BAD_ADDR FDT_ADDR_T_NONE
#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ #define OF_CHECK_COUNTS(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS)
(ns) > 0)
/* Debug utility */ /* Debug utility */
#ifdef DEBUG #ifdef DEBUG
...@@ -1121,7 +1120,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in ...@@ -1121,7 +1120,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in
/* Cound address cells & copy address locally */ /* Cound address cells & copy address locally */
bus->count_cells(blob, parent, &na, &ns); bus->count_cells(blob, parent, &na, &ns);
if (!OF_CHECK_COUNTS(na, ns)) { if (!OF_CHECK_COUNTS(na)) {
printf("%s: Bad cell count for %s\n", __FUNCTION__, printf("%s: Bad cell count for %s\n", __FUNCTION__,
fdt_get_name(blob, node_offset, NULL)); fdt_get_name(blob, node_offset, NULL));
goto bail; goto bail;
...@@ -1148,7 +1147,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in ...@@ -1148,7 +1147,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in
/* Get new parent bus and counts */ /* Get new parent bus and counts */
pbus = &of_busses[0]; pbus = &of_busses[0];
pbus->count_cells(blob, parent, &pna, &pns); pbus->count_cells(blob, parent, &pna, &pns);
if (!OF_CHECK_COUNTS(pna, pns)) { if (!OF_CHECK_COUNTS(pna)) {
printf("%s: Bad cell count for %s\n", __FUNCTION__, printf("%s: Bad cell count for %s\n", __FUNCTION__,
fdt_get_name(blob, node_offset, NULL)); fdt_get_name(blob, node_offset, NULL));
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment