
Hi Stephen,
On 6 August 2015 at 15:31, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties.
This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells.
dev_get_addr() is updated to use the new functions.
Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them.
Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit".
Based-on-work-by: Thierry Reding treding@nvidia.com Cc: Thierry Reding treding@nvidia.com Cc: Simon Glass sjg@chromium.org Cc: Michal Suchanek hramrach@gmail.com Signed-off-by: Stephen Warren swarren@nvidia.com
For patch context, this patch relies on Thierry's "fdt: Fix fdtdec_get_addr_size() for 64-bit" having been reverted.
drivers/core/device.c | 5 ++- include/fdtdec.h | 111 +++++++++++++++++++++++++++++++++++++++++++---- lib/fdtdec.c | 116 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 202 insertions(+), 30 deletions(-)
Acked-by: Simon Glass sjg@chromium.org
This looks perfect to me, and covers all cases. Thank you for resolving this.
Re SPL I'll be getting back to that before long and taking another look at code size. If anything needs tweaking in dev_get_addr() I'll send a patch then.
I'll wait to see if there are other comments and apply this to the fdt tree early next week.
Regards, Simon