-
Notifications
You must be signed in to change notification settings - Fork 7.7k
drivers: sensor: Refactor drivers to use SENSOR_DEVICE_DT_INST_DEFINE #51352
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
drivers: sensor: Refactor drivers to use SENSOR_DEVICE_DT_INST_DEFINE #51352
Conversation
Refactors all sensor drivers to use SENSOR_DEVICE_DT_INST_DEFINE, which is a sensor-specific variant of DEVICE_DT_INST_DEFINE that provides a common place to instantiate additional data structures for the future sensor subsystem and/or sensor driver stats. This approach was inspired by I2C_DEVICE_DT_INST_DEFINE to streamline adding I2C stats support across all I2C drivers. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
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.
This seems to be a 1:1 wrapper around DEVICE_DT_DEFINE
, why is this needed now? I2C/CAN have a use case for it.
This is needed to enable the sensor info iterable section and shell command in #49294. That PR introduced several new concepts (vendor and model names, base sensor devicetree properties, sensor info section and shell command, and virtual sensors), so I've been cleaning up and resubmitting each part separately to reduce the scope and get into a mergeable state. See #49489, #50015, #50929 |
@gmarull ping |
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 we move init level (POST_KERNEL
) and priority CONFIG_SENSOR_INIT_PRIORITY
to be hidden inside of SENSOR_DEVICE_DT_DEFINE
?
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.
Should we even allow SENSOR_DEVICE_DT_DEFINE? Meaning should we just have everyone use SENSOR_DEVICE_DT_INST_DEFINE and thus have new sensor drivers be multi-instance to start?
Marked DNM to wait to get feedback on my questions. |
I'd not remove that unless we have a real alternative. If for whatever reason a sensor needs to be initialized before Kernel, there'll be no choice. There's actually one sensor in |
I think this would be going a step too far.
I'm fine with this. |
I don't see why we should limit sensor drivers in this regard. For some (e.g. on-die) sensor types will only make sense to support one single instance. |
Refactors all sensor drivers to use SENSOR_DEVICE_DT_INST_DEFINE, which is a sensor-specific variant of DEVICE_DT_INST_DEFINE that provides a common place to instantiate additional data structures for the future sensor subsystem and/or sensor driver stats.
This approach was inspired by I2C_DEVICE_DT_INST_DEFINE to streamline adding I2C stats support across all I2C drivers.
Signed-off-by: Maureen Helm maureen.helm@intel.com
cc: @huhebo
This PR is another piece of #49294