RFC: hwclock-rtc: add RTC_PARAM_BATTERY_LOW_DETECT support - #4513
Draft
KarlK90 wants to merge 2 commits into
Draft
RFC: hwclock-rtc: add RTC_PARAM_BATTERY_LOW_DETECT support#4513KarlK90 wants to merge 2 commits into
KarlK90 wants to merge 2 commits into
Conversation
KarlK90
force-pushed
the
feature/hwclock-rtc/bld
branch
from
July 30, 2026 12:18
5424d9e to
018cc92
Compare
karelzak
reviewed
Aug 3, 2026
| # define RTC_PARAM_CORRECTION 1 | ||
| # define RTC_PARAM_BACKUP_SWITCH_MODE 2 | ||
| # define RTC_PARAM_BATTERY_LOW_DETECT 3 | ||
| #endif /* RTC_PARAM_GET */ |
Collaborator
There was a problem hiding this comment.
You cannot define it in the ifndef RTC_PARAM_GET block, do it later
#if defined(RTC_PARAM_GET) && !defined(RTC_PARAM_BATTERY_LOW_DETECT)
# define RTC_PARAM_BATTERY_LOW_DETECT 3
#endif
Author
There was a problem hiding this comment.
Done. But won't that result in compilation error in the case that RTC_PARAM_GET is undefined?
Collaborator
There was a problem hiding this comment.
Good point, RTC_PARAM_GET is required, but the code in this case is not strict enough. I'll improve it.
Collaborator
There was a problem hiding this comment.
f089382 should make RTC_PARAM_GET use more robust.
Author
There was a problem hiding this comment.
Thanks! I have cherry-picked your commit and updated my commit on top of it.
KarlK90
force-pushed
the
feature/hwclock-rtc/bld
branch
from
August 3, 2026 12:51
018cc92 to
870e88f
Compare
Replace broad #ifndef __GNU__ guards with feature-specific #ifdef RTC_PARAM_GET and #ifdef RTC_VL_READ to guard the code that depends on these ioctls. Move the fallback definitions for RTC_PARAM_GET, RTC_PARAM_SET, RTC_VL_READ, and RTC_VL_CLR from hwclock-rtc.c to hwclock.h under feature macros consistently. Signed-off-by: Karel Zak <kzak@redhat.com>
Some rtcs like the pcf2131 do not enable low battery detection by default. A new linux patch series[1] exposes a parameter to enable the detection, support is implemented in this commit. [1]: https://lore.kernel.org/all/20260311200237.3531981-1-hugo@hugovil.com/ Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
KarlK90
force-pushed
the
feature/hwclock-rtc/bld
branch
from
August 10, 2026 15:17
870e88f to
6252cea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft PR - depends on pending linux patch series
Some rtcs like the pcf2131 do not enable low battery detection by default. A new linux patch series1 exposes a parameter to enable the detection, support is implemented in this commit.