-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
RFC: API: Counter: counter_read() has no way of indicating failure #21846
Comments
Sounds ok. Counter API was initially created for internal peripherals thus direct readout but as it fits external devices then it should be extended. |
Great. Thanks for your feedback. What is the next step here? Should I create a pull request? |
Yes, and you can also deprecate EDIT: @henrikbrixandersen I was wrong, this is listed as an unstable API so the only thing you need to do is to change the API call directly (no need to rename it, just change the signature) and then add a small note in the release notes. |
PR creation is awaiting #22030. |
+1 to this proposal |
Introduce a new counter API function for reading the current counter value (counter_get_value()) and deprecate the former counter_read() in favor of this. Update all drivers and calling code to match the new counter API. The previous counter driver API function for reading the current value of the counter (counter_read()) did not support indicating whether the read suceeded. This is fine for counters internal to the SoC where the read always succeeds but insufficient for external counters (e.g. I2C or SPI slaves). Fixes zephyrproject-rtos#21846. Signed-off-by: Henrik Brix Andersen <[email protected]>
Introduce a new counter API function for reading the current counter value (counter_get_value()) and deprecate the former counter_read() in favor of this. Update all drivers and calling code to match the new counter API. The previous counter driver API function for reading the current value of the counter (counter_read()) did not support indicating whether the read suceeded. This is fine for counters internal to the SoC where the read always succeeds but insufficient for external counters (e.g. I2C or SPI slaves). Fixes #21846. Signed-off-by: Henrik Brix Andersen <[email protected]>
Introduction
The counter API has a method for reading the current counter value with the following function prototype:
This API function does not allow any standard way of indicating a "read failure" since the return value is just the raw, 32-bit counter value.
Problem description
Counters, like most other devices, may be connected to the SoC/MCU using an external bus (I2C, SPI, ...) where communication errors can occur. Our current counter API allows indicating failures from all other API functions than the
counter_read()
function.Proposed change
I suggest introducing a new counter API function for reading the counter value with the current function prototype:
This new API function will effectively replace
counter_read()
, which can then be deprecated. During the deprecation period,counter_read()
can be implemented using the newly introducedcounter_get_value()
API function and return0
ifcounter_get_value()
returned a negative error code.Detailed RFC
counter_get_value()
counter API syscall and handlercounter_read()
counter API syscall and handler and reimplement it usingcounter_get_value()
counter_api_get_value()
typedef to replace existingcounter_api_get_value()
Proposed change (Detailed)
See above.
Dependencies
This change will require users updating any out-of-tree counter drivers, but the application API can remain the same during the deprecation period.
Concerns and Unresolved Questions
None so far.
Alternatives
None so far.
The text was updated successfully, but these errors were encountered: