-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: allow to retrieve device structure by the name prefix #21709
drivers: allow to retrieve device structure by the name prefix #21709
Conversation
This patch allows to retrieve available drivers for certain types of devices based on the prefix in the name. If the name is formed according to the rule TYPE_DEVICE then a subsystem can find a appropriate drivers/devices without additional configuration. For example: a display could have the name DISPLAY_SSD1306, a IEEE802154 transceiver the name 802154_MCR20A, and a temperature sensor TSENSOR_HDC1010. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Remove LVGL_DISPLAY_DEV_NAME and unify configuration. Use device type "DISPLAY" prefix for DT labels. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Shame, it fails with newlib, I guess because |
Both minimal libc and newlib support It looks like we will need to globally 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.
What is the final purpose of this? (let me block the pr until then)
Note that the device name is something that should be removed (someday... ). And its only purpose is to get the device bindings. And it was introduced only because there were no other nice ways to do it. But it's useless besides this.
@jfischer-phytec-iot, can you check #21560 ? |
That is what I am absolute against, we should not mix DT and Kconfig. Also #21560 do not resolve the issue with the subsystem, only one device/driver is configurable/can be selected. It is not possible to discover number of devices, e.g. number of displays or transceivers. Also see last commit as example, overhead of the prefix is minimal. |
You can see the last commit as minimal example. Regardless what display controller driver is selected, both subsystems CFB and LVGL can retrieve device structure by the prefix, also more then one display can be used, e.g. EPD connected to SPI and OLED connected to I2C. An other example is to use one or more temperature sensors in the application like |
@jfischer-phytec-iot I see. But your approach is creating another dependency on device name (bringing all the issues of using the name with it also: it's slow etc...), and I don't want to see that happen. Then it will be even more complicated to better integrate DTS and get rid of this name afterwards. Both your PR and #21560 (I agree we must not mix DTS and Kconfig) are, imo, wrong solutions. They are q&d fix for a real issue. I think it's worth spending a bit more thinking on that, I am sure something better can be found. |
@tbursztyka I know about slowness and accept as it happens only once at start. Also thought about sections in the rom for particular device type, something like Edit: device_type is deprecated, DT self looks like an accident. |
I know, all of this need to be fixed. Let's wake up @galak |
Probably device_type could be used for that, see also discussion in #17976 |
Yes, though it would need to be reworked against new dts script. I did not make it that time, but it does not mean it could not go now since we would have use case for it. But sounds like a good approach, I really support doing things statically as much as possible since we do have all the information statically via dts. Such types could be introduced in the various base yaml files (spi-controller.yaml, pwm-controller.yaml etc... there are some missing but it would be trivial to add). |
@jfischer-phytec-iot this looks like it may be related to the work in #20253; have you looked at that? |
outdated |
This patch allows to retrieve available drivers for certain
types of devices based on the prefix in the name.
If the name is formed according to the rule TYPE_DEVICE then
a subsystem can find a appropriate drivers/devices
without additional configuration.
For example: a display could have the name DISPLAY_SSD1306,
a IEEE802154 transceiver the name 802154_MCR20A,
and a temperature sensor TSENSOR_HDC1010.
TODO: add test to
tests/kernel/device