mirror of
https://xff.cz/git/u-boot/
synced 2025-09-06 03:02:18 +02:00
dm: core: fdtaddr: Avoid multiple calls to fdt_parent_offset()
Use of fdt_parent_offset() is very expensive as detailed by the function
documentation:
NOTE: This function is expensive, as it must scan the device tree
structure from the start to nodeoffset, *twice*.
Re-use the returned value from a single call instead of having to make
multiple calls for same nodeoffset.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit d6330529a5
)
This commit is contained in:
committed by
Ondrej Jirman
parent
b177d61708
commit
26f4ff9c4f
@@ -19,11 +19,10 @@
|
|||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
#if CONFIG_IS_ENABLED(OF_REAL) || CONFIG_IS_ENABLED(OF_CONTROL)
|
||||||
|
fdt_addr_t devfdt_get_addr_index_parent(const struct udevice *dev, int index,
|
||||||
|
int offset, int parent)
|
||||||
{
|
{
|
||||||
#if CONFIG_IS_ENABLED(OF_REAL)
|
|
||||||
int offset = dev_of_offset(dev);
|
|
||||||
int parent = fdt_parent_offset(gd->fdt_blob, offset);
|
|
||||||
fdt_addr_t addr;
|
fdt_addr_t addr;
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
|
if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
|
||||||
@@ -89,6 +88,15 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
|
||||||
|
{
|
||||||
|
#if CONFIG_IS_ENABLED(OF_REAL)
|
||||||
|
int offset = dev_of_offset(dev);
|
||||||
|
int parent = fdt_parent_offset(gd->fdt_blob, offset);
|
||||||
|
return devfdt_get_addr_index_parent(dev, index, offset, parent);
|
||||||
#else
|
#else
|
||||||
return FDT_ADDR_T_NONE;
|
return FDT_ADDR_T_NONE;
|
||||||
#endif
|
#endif
|
||||||
@@ -113,14 +121,16 @@ fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
|
|||||||
* next call to the exisiting dev_get_xxx function which handles
|
* next call to the exisiting dev_get_xxx function which handles
|
||||||
* all config options.
|
* all config options.
|
||||||
*/
|
*/
|
||||||
fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev),
|
int offset = dev_of_offset(dev);
|
||||||
|
int parent = fdt_parent_offset(gd->fdt_blob, offset);
|
||||||
|
fdtdec_get_addr_size_auto_parent(gd->fdt_blob, parent, offset,
|
||||||
"reg", index, size, false);
|
"reg", index, size, false);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the base address via the existing function which handles
|
* Get the base address via the existing function which handles
|
||||||
* all Kconfig cases
|
* all Kconfig cases
|
||||||
*/
|
*/
|
||||||
return devfdt_get_addr_index(dev, index);
|
return devfdt_get_addr_index_parent(dev, index, offset, parent);
|
||||||
#else
|
#else
|
||||||
return FDT_ADDR_T_NONE;
|
return FDT_ADDR_T_NONE;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user