-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
device: supported devices API #37836
device: supported devices API #37836
Conversation
cool, I have the same feature implemented in a different pr #37723. Lets me try my feature on top of your supported devices implementation. I'm prone to your implementation, it is looking cleaner than mine. |
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.
Can you please split the functional changes from the whitespace changes?
Done |
I hadn't realized there was already an implementation, or I wouldn't have bothered to try it myself. |
Agree, as soon as this pr gets in, I'll rebase that one. |
* @return The number of devices that were visited if all visits succeed, or | ||
* the negative value returned from the first visit that did not succeed. | ||
*/ | ||
int device_supported_foreach(const struct device *dev, |
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.
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.
Supports is the terminology used in the existing API's. I do agree it makes for awkward documentation.
zephyr/include/devicetree/ordinals.h
Lines 47 to 61 in cc760c5
* @brief Get a list of dependency ordinals of what depends directly on a node | |
* | |
* There is a comma after each ordinal in the expansion, **including** | |
* the last one: | |
* | |
* DT_SUPPORTS_DEP_ORDS(my_node) // supported_ord_1, ..., supported_ord_n, | |
* | |
* DT_SUPPORTS_DEP_ORDS() may expand to nothing. This happens when @p node_id | |
* refers to a leaf node that nothing else depends on. | |
* | |
* @param node_id Node identifier | |
* @return a list of dependency ordinals, with each ordinal followed | |
* by a comma (<tt>,</tt>), or an empty expansion | |
*/ | |
#define DT_SUPPORTS_DEP_ORDS(node_id) DT_CAT(node_id, _SUPPORTS_ORDS) |
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.
Supports is the terminology used in the existing API's. I do agree it makes for awkward documentation.
yes it looks very awkward for someone not familiar with the DT APIs. Is this a zephyr thing or does this come from the devicetree spec? @mbolivar-nordic @galak
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.
Is this a zephyr thing or does this come from the devicetree spec? @mbolivar-nordic @galak
It's a zephyr thing.
Remove double spaces after full stops in doxygen comments. Signed-off-by: Jordan Yates <[email protected]>
Optimize the handles array by making the following observations: * The devicetree ordinal at index 0 in pass1 is discarded by gen_handles.py, and therefore does not appear in the pass2 array. * gen_handles.py does not need `DEVICE_HANDLE_ENDS` to determine the end of the handle array, as that information is present in the .elf. Therefore, instead of replacing the devicetree ordinal with an additional `DEVICE_HANDLE_ENDS` at the end (to preserve lengths), we can simply move the ordinal to the end and have it be the original `DEVICE_HANDLE_ENDS` symbol. This reduces the size of the array by one handle per device (2 bytes). Signed-off-by: Jordan Yates <[email protected]>
Force the inclusion of a `DEVICE_HANDLE_SEP` at the end of the devicetree dependency section of the array. This lets us simplify the implementation of `device_required_handles_get`, as there is only one symbol the section ends with. This does not use any extra ROM as the array is padded out to the original size with `DEVICE_HANDLE_ENDS` anyway. Also adds a description of the array format where the array is instantiated. Signed-off-by: Jordan Yates <[email protected]>
Add supported device information to the device `handles` array. This enables API's to iterate over supported devices for power management purposes. Signed-off-by: Jordan Yates <[email protected]>
Adds an API to query and visit supported devices. Follows the example set by the required devices API. Implements #37793. Signed-off-by: Jordan Yates <[email protected]>
Add tests for the supported devices API. Signed-off-by: Jordan Yates <[email protected]>
Implements an API to iterate over devicetree devices that an arbitrary device supports.
Follows the conventions setup by the dependent devices API.
Includes a minor optimization to the handles array (saves one handle per array), which offsets the cost of the additional
DEVICE_HANDLE_SEP
. Therefore the ROM increase is purely a function of the number of supported devices per device (2 bytes per).Implements #37793.