-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[RFC] edtlib: enhance for pin controller, clock controller, partitions, special nodes #22255
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
Conversation
|
All checks are passing now. checkpatch (informational only, not a failure)Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
scripts/dts/edtlib.py
Outdated
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.
Quick look, but this function looks pretty long and hard to follow.
Could you try splitting it up into some smaller functions, so that each functions is like 30 lines maximum? Maybe some common stuff could be factored out at the same time.
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.
Split. Did not reach 30 lines. Where do get this limit from?
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.
Just some number I pulled out that feels like the right ballpark. Short and focused functions with few parameters are considered a good practice at least. See e.g. the Linux kernel coding style.
Alright to have it a bit longer if it's just a big switch or whatever with only one or two levels of indent, because then it's more like many small functions.
Good idea to go through PEP 8 once too. Check this section for how to format continuation lines (e.g. for function parameters).
Strive for having few parameters too, and for all combinations of parameters to make sense (i.e., no dependencies between parameters, if it can be avoided).
Might be a bit busy next week, but will look more at the logic.
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 saying I'm perfect re. that stuff. Think it might be possible to shorten some of this stuff though, and have some simple helpers with just a few parameters.
scripts/dts/edtlib.py
Outdated
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.
Ditto here. See if it can be split up a bit.
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.
Split. Did not reach 30 lines.
|
Will need to add tests in |
scripts/dts/edtlib.py
Outdated
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.
Could make it a bit easier to read like this:
if "clock-output-names" in node.props:
clock_output_names = node.props["clock-output-names"].to_strings()
else:
clock_output_names = []I try to avoid the "set a variable to a value that might be wrong, do a check, and then overwrite it with the right value" pattern. Gets confusing when scanning for where a variable is set.
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.
Changed programming style to be in line.
Instead of catching DeviceTreeCheck exceptions from test(e)dtlib.py all the way up in main(), catch them in the DeviceTreeCheck test itself, and report them with ComplianceTest.error(). That way, other tests (e.g. pylint) can still run and report to GitHub when there are internal errors in test(e)dtlib.py. Motivated by zephyrproject-rtos/zephyr#22255. Signed-off-by: Ulf Magnusson <[email protected]>
|
Improved the CI script so that it still runs other tests when there's an internal error in There's these issues reported by pylint in the meantime (would normally get reported automatically by CI): Can run pylint manually like this after cloning down the ci-tools repo. |
scripts/dts/edtlib.py
Outdated
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 think we should avoid magic hardcoded strings like these that "piggyback" on dictionaries used for other stuff. Better to use regular attributes.
Maybe a new class could be added.
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.
New class 'Partition' used.
scripts/dts/edtlib.py
Outdated
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.
Better to have this as part of the EDT class, since it's possible to have multiple EDT instances. The library itself has no global state.
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.
Moved to EDT. Made some collateral moves necessary as _warn now needs EDT.
Instead of catching DeviceTreeCheck exceptions from test(e)dtlib.py all the way up in main(), catch them in the DeviceTreeCheck test itself, and report them with ComplianceTest.error(). That way, other tests (e.g. pylint) can still run and report to GitHub when there are internal errors in test(e)dtlib.py. Motivated by zephyrproject-rtos/zephyr#22255. Signed-off-by: Ulf Magnusson <[email protected]>
fcb3fa5 to
a8dd73a
Compare
Extract the gpio led child node of gpio leds controller nodes.
Extend the Node class with properties for:
gpio_leds:
A list of ControllerAndData objects of the leds a gpio leds
controller controls. The list is empty if the node is not a
gpio leds controller or it does not have gpio led children.
Signed-off-by: Bobby Noelte <[email protected]>
Tests for edtlib features: - enable bindings for special nodes without compatibles - allow binding override by binding file name - allow extraction of gpio-ranges properties - extract pinctrl state and pin configuration nodes - extract clock inputs and clock outputs - extract partitions nodes - extract gpio led nodes Signed-off-by: Bobby Noelte <[email protected]>
4ec1d4e to
c761f92
Compare
|
Stale too long |
A set of edtlib.py enhancements that proved useful to implement an OOT pin controller driver, clock controller driver, flash driver, gpio leds driver (using code generation).
This makes edtlib more complete. It should also simplify defines generation in gen_defines.py, especially for pin controllers and clock controllers.
Comments welcome.
dts: edtlib: enable bindings for special nodes without compatibles
dts: edtlib: allow binding override by binding file name
dts: edtlib: allow extraction of gpio-ranges properties
Handling of 'gpio-ranges' is a must to implement pin controllers.
dts: edtlib: extract pinctrl state and pin configuration nodes
dts: edtlib: extract clock inputs and clock outputs
dts: edtlib: extract partitions nodes
dts: edtlib: extract gpio led nodes
dts: edtlib: issue same warning only once
Repeating the same warning is just an annoyance.