[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250428-enable-rtc-v4-0-2b2f7e3f9349@baylibre.com>
Date: Mon, 28 Apr 2025 12:06:46 +0200
From: Alexandre Mergnat <amergnat@...libre.com>
To: Alexandre Belloni <alexandre.belloni@...tlin.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>
Cc: Uwe Kleine-König <u.kleine-koenig@...libre.com>,
linux-rtc@...r.kernel.org, linux-kernel@...r.kernel.org,
Alexandre Mergnat <amergnat@...libre.com>
Subject: [PATCH v4 0/5] Fix pre-1970 date handling
This series fixes pre-1970 date handling in the RTC subsystem. The changes
are particularly important for MediaTek platforms using the rtc-mt6397
driver, which can only store dates from 1900-01-01 to 2027-12-31.
The handling of pre-1970 dates in time conversion functions is improved, which
is essential for hardware that must reuse earlier dates once their native format
limits are reached. Sign-related comparison issues causing incorrect offset
calculations are fixed, and the test infrastructure is enhanced to validate time
conversions across the entire date range.
These improvements ensure the RTC subsystem functions correctly when hardware
date limits are reached, particularly relevant as the rtc-mt6397 driver will
hit its upper limit in less than three years.
---
Changes in v4:
- Remove "rtc: mt6359: Add mt6357 support" to send it in another serie.
- Change title serie to "Fix pre-1970 date handling " because MT6357
support is no more related to this.
- Remove "arm64: dts: mediatek: Set RTC start year property" because it
is not requiered to have MTK RTC working.
- Remove "rtc: mt6397: Remove start time parameters".
- Rework time comparison fix to avoid cast.
- Remove change in rtc_valid_tm.
- Improve rtc_time64_to_tm change for readability and efficiency.
- Extend conversion test cover to reach 1900 year value.
- Link to v3: https://lore.kernel.org/r/20250109-enable-rtc-v3-0-f003e8144419@baylibre.com
Changes in v3:
- Rebase on top of rtc-6.15
- Added explicit start-year property in DTSIs for MT6357, MT6358, and
MT6359 PMIC RTCs to ensure consistent values between hardware
registers and the RTC framework.
- Removed hardcoded offset and start_secs parameter in mt6397 driver
in favor of using the DTS start-year property.
- Fixed type comparison issues between signed time64_t and unsigned
range values to correctly handle dates before 1970.
- Added proper handling of negative time values (pre-1970 dates) in
time conversion functions.
- Modified rtc_time64_to_tm() to correctly handle negative timestamp
values.
- Removed the tm_year < 70 restriction in rtc_valid_tm() to allow
pre-1970 dates to be validated correctly .
- Link to v2: https://lore.kernel.org/all/20250109-enable-rtc-v2-0-d7ddc3e73c57@baylibre.com/
Changes in v2:
- Split the patch to have:
- Add MT6357 support
- Fix hwclock issue
- Handle the year offset in another way, but the V1 way still viable.
- Link to v1: https://lore.kernel.org/r/20250109-enable-rtc-v1-0-e8223bf55bb8@baylibre.com
---
Alexandre Mergnat (2):
rtc: Make rtc_time64_to_tm() support dates before 1970
rtc: Fix offset calculation for .start_secs < 0
Uwe Kleine-König (3):
rtc: test: Emit the seconds-since-1970 value instead of days-since-1970
rtc: test: Also test time and wday outcome of rtc_time64_to_tm()
rtc: test: Test date conversion for dates starting in 1900
drivers/rtc/class.c | 2 +-
drivers/rtc/lib.c | 24 +++++++++++++++++++-----
drivers/rtc/lib_test.c | 27 ++++++++++++++++-----------
3 files changed, 36 insertions(+), 17 deletions(-)
---
base-commit: 424dfcd441f035769890e6d1faec2081458627b9
change-id: 20250109-enable-rtc-b2ff435af2d5
Best regards,
--
Alexandre Mergnat <amergnat@...libre.com>
Powered by blists - more mailing lists