lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  1 Feb 2023 15:34:27 +0100
From:   Frieder Schrempf <frieder@...s.de>
To:     Alessandro Zummo <a.zummo@...ertech.it>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        linux-kernel@...r.kernel.org, linux-rtc@...r.kernel.org
Cc:     Frieder Schrempf <frieder.schrempf@...tron.de>,
        keliu <liuke94@...wei.com>,
        Shang XiaoJing <shangxiaojing@...wei.com>,
        Vincent Whitchurch <vincent.whitchurch@...s.com>,
        Yang Yingliang <yangyingliang@...wei.com>
Subject: [PATCH 5/7] rtc: class: Support setting backup switch mode from devicetree

From: Frieder Schrempf <frieder.schrempf@...tron.de>

Some RTC devices like the RV3028 have BSM disabled as factory default.
This makes the RTC quite useless if it is expected to preserve the
time on hardware that has a battery buffered supply for the RTC.

Let boards that have a buffered supply for the RTC available force
the BSM to the desired value via devicetree by setting the
'backup-switch-mode' property.

Signed-off-by: Frieder Schrempf <frieder.schrempf@...tron.de>
---
 drivers/rtc/class.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index e5b7b48cffac..79417d1fbeee 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -391,6 +391,11 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 	struct rtc_wkalrm alrm;
 	int err;
 
+	struct rtc_param bsm = {
+		.param = RTC_PARAM_BACKUP_SWITCH_MODE,
+		.uvalue = RTC_BSM_DISABLED,
+	};
+
 	if (!rtc->ops) {
 		dev_dbg(&rtc->dev, "no ops set\n");
 		return -EINVAL;
@@ -402,6 +407,15 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 	if (rtc->ops->set_offset)
 		set_bit(RTC_FEATURE_CORRECTION, rtc->features);
 
+	/* setup backup switching mode */
+	if (test_bit(RTC_FEATURE_BACKUP_SWITCH_MODE, rtc->features) &&
+	    !device_property_read_u32(rtc->dev.parent, "backup-switch-mode",
+				      (u32 *)&bsm.uvalue)) {
+		err = rtc->ops->param_set(rtc->dev.parent, &bsm);
+		if (err && err != -EINVAL)
+			return err;
+	}
+
 	rtc->owner = owner;
 	rtc_device_get_offset(rtc);
 
-- 
2.39.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ