-
Notifications
You must be signed in to change notification settings - Fork 8.2k
devicetree: Add DT_CHILD_BY_UNIT_ADDR #99120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9bf2b99 to
e3c70ba
Compare
e51dfee to
5eac67f
Compare
Fix dts formatting issues with dts-linter. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
fa20529 to
2c51d4f
Compare
aaddcc3 to
6d71377
Compare
include/zephyr/devicetree.h
Outdated
| * @brief Get a node identifier for a child node by a reg address | ||
| * | ||
| * Example devicetree fragment: | ||
| * | ||
| * @code{.dts} | ||
| * / { | ||
| * soc-label: soc { | ||
| * serial1: serial@40001000 { | ||
| * status = "okay"; | ||
| * current-speed = <115200>; | ||
| * ... | ||
| * }; | ||
| * }; | ||
| * }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the description you say it's by reg address, but I don't see a reg property here in the example, unless you mean to refer to the unit address, in which case the name of the macro is also wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a proper _BY_UNIT_ADDR variant, which is needed to fix the adc dt spec. I could drop the _BY_REG_ADDR, but it doesn't harm I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it makes sense either given #99120 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR
include/zephyr/devicetree.h
Outdated
| * | ||
| * @return node identifier for the child node with the reg address at a specified index | ||
| */ | ||
| #define DT_CHILD_BY_REG_ADDR(node_id, idx, addr) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are going to do this, then i suggest you make a _BY_IDX version , and make this one do index 0. and also could be useful to add a _BY_NAME version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that resources can be shared between multiple nodes (reg property addresses do not need to be unique across nodes).
6d71377 to
21c217a
Compare
Can you elaborate a bit on the use case, please? |
I've added a commit that replaces the |
f7ba568 to
3c5f497
Compare
bc74e56 to
04106bf
Compare
mathieuchopstm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
04106bf to
3d2eaf9
Compare
3d2eaf9 to
19ab0dd
Compare
Allow fetching child node identifiers by unit address. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Introduce test cases to the devicetree API test suite for DT_CHILD_BY_UNIT_ADDR and DT_INST_CHILD_BY_UNIT_ADDR. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The macro to initialise a struct adc_dt_spec instance uses a FOREACH macro, which can be problematic when nesting in other FOREACH macros, for example in driver implementations. Replace it with DT_CHILD_BY_UNIT_ADDR. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add a DeviceTree section and entries for the new C macros. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
19ab0dd to
dd22799
Compare
|



Allow fetching child node identifiers by unit address.
It also modifies the
ADC_DT_SPEC_STRUCTmacro to not useFOREACHmacro expansion, which doesn't play nice withCOND_CODE_Xand other macro loops.