
Hi Simon,
2017-05-20 11:29 GMT+09:00 Simon Glass sjg@chromium.org:
Hi Masahiro,
On 16 May 2017 at 04:35, Masahiro Yamada yamada.masahiro@socionext.com wrote:
Hi Simon,
2017-05-02 0:18 GMT+09:00 Simon Glass sjg@chromium.org:
With live tree we need a struct device_node * to reference a node. With the existing flat tree, we need an int offset. We need to unify these into a single value which can represent both.
Add an ofnode union for this and adjust existing code to move to this.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
drivers/core/device.c | 2 +- drivers/core/root.c | 2 +- include/dm.h | 1 + include/dm/device.h | 14 +++++-- include/dm/ofnode.h | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 include/dm/ofnode.h
When you add a new header, please make sure it is self-contained.
You use bool for offset_toofnode() and ofnode_equal(). So you need to include <stdbool.h> from this header.
(or, use "int" for the return type.)
I'm wondering about this problem:
In general we want to minimise the size of headers included by U-Boot. For something like ofnode which is used by several header files we end up including it many times, once per header.
It is no problem if the header body is surrounded by an include guard.
With include guards, each header is _parsed_ only once even if _included_ multiple times.
With dm.h we avoid this since the header is only included ones (and in the correct order).
Generally, we should not rely on a specific include order.
Even if we compel drivers to include dm.h, each of dm/{device.h, platdata.h, uclass.h} should be self-contained.
We usually sort includes alphabetically, but technically it should work in any order. It would be possible if each header is self-contained.
What is the best solution to this?