[PATCH 0/2] Handle EINVAL from RTC_RD_TIME when RTC time is not set

Thomas Perrot via busybox <[email protected]> Tue, 26 May 2026 11:21:46 +0200
Newsgroups gmane.linux.busybox
Message-ID <[email protected]>
Some RTC drivers (e.g. rtc-nxp-bbnsm) return EINVAL from RTC_RD_TIME
when the hardware counter has never been initialized. This is the case
on freshly manufactured boards that have never had their time set.

Previously this caused hwclock and rtcwake to exit immediately with:

  hwclock: RTC_RD_TIME: Invalid argument

This series fixes the problem in two steps:
- Patch 1 changes rtc_read_tm() to return -errno instead of dying,
  giving callers a chance to inspect the error code.
- Patch 2 updates hwclock and rtcwake to map EINVAL to an informative
  "RTC time is not set" message instead of aborting.

---
Thomas Perrot (2):
      libbb/rtc: rtc_read_tm: return error code on RTC_RD_TIME failure
      hwclock, rtcwake: handle EINVAL from RTC_RD_TIME as "time not set"

 include/rtc_.h       |  2 +-
 libbb/rtc.c          |  6 ++++--
 util-linux/hwclock.c | 15 +++++++++++++--
 util-linux/rtcwake.c |  8 +++++++-
 4 files changed, 25 insertions(+), 6 deletions(-)
---
base-commit: 244c0a01eece537e9d7e8318a5c320a836cc604b
change-id: 20260522-rtc-not-set-handling-a68699f5e2b2

Best regards,
-- 
Thomas Perrot <[email protected]>