-
Notifications
You must be signed in to change notification settings - Fork 8.2k
device: refactor declare/define macros to support device definition and reference from devicetree nodes #30196
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
|
Note that the compliance failures related to macro style are inappropriate and should be ignored. |
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.
Do we care about having a convention of using device_pm_control_nop vs NULL?
I don't know. ebe20f9 added it for a reason, and I remember finding it useful to have it explicit in another situation (but not why, or whether that effort got anywhere). It'll all be reworked when we get moving on device power management anyway. |
Any sense if its better/more useful for it to be NULL or |
Right now, no. I don't want to deal with this until I get to device_pm. |
|
@nashif with my explanation and other people thinking it's ok, do you still insist on replacing I'd like to get this wrapped up. |
I still think we need a better API, I dislike having "if" in the API name. |
6571d73 to
62ad784
Compare
|
OK, so here are the options I've considered to be acceptable:
I don't consider these to be acceptable:
Comment if there are others so we know what to discuss. |
The dev_name is the canonical DT node identifier encoding the devicetree path; the drv_name is the label of the corresponding node. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
For devices defined using devicetree nodes we need to pass the devicetree node, and to infer names for the device and the driver from it. Devices defined in the classical way don't need this. Introduce another level of private abstraction that accepts the information from either source, falling back to the old parameters when the provided node is invalid. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the clock devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Use the devicetree node as the source of object name and other information used when defining the device structure. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
When using a devicetree node as an identifier we know the identifier used to define the device structure. This allows code to directly reference that structure, avoiding the need to look it up by label at runtime. Change the macros so DEVICE_DT_* device objects are globally visible using the node identifier as the object identifier. Also add the necessary API to verify that a device that was captured at build time successfully completed initialization and any other steps necessary before it can be safely used. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Avoid the private API now that there's a public equivalent. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Provide a helper to extract the devicetree node_id for a GPIO controller from a gpio phandle array. This can be used with DEVICE_DT_GET() to directly reference the corresponding controller device. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
62ad784 to
1e84fe0
Compare
This pulls the macro refactorization out of #29644, allow driver implementations to define devices using information from devicetree nodes directly. Ultimately this will enable storing device dependencies and other metadata inferred from the devicetree source.
Now it allows a well-defined unique public identifier for device structures that can be used to reference the device object at build time, avoiding the need for
device_get_binding()and ultimately eliminating many uses of thelabelproperty as a device identifier.The devicetree binding API for gpio has been updated to support this, and the blinky example to use the new capability.