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>] [day] [month] [year] [list]
Date:   Mon,  7 Mar 2022 11:17:32 -0300
From:   Alifer Moraes <alifer.m@...iscite.com>
To:     linux-kernel@...r.kernel.org
Cc:     a.zummo@...ertech.it, eran.m@...iscite.com,
        linux-rtc@...r.kernel.org, pierluigi.p@...iscite.com,
        Felix Radensky <felix.r@...iscite.com>,
        Alifer Moraes <alifer.m@...iscite.com>
Subject: [PATCH] rtc: ds1307: implement suspend/resume function

From: Felix Radensky <felix.r@...iscite.com>

Implement the suspend/resume function in rtc-ds1307's driver
to control irq_wake flag and handle as wakeup source.

Signed-off-by: Felix Radensky <felix.r@...iscite.com>
Signed-off-by: Alifer Moraes <alifer.m@...iscite.com>
---
 drivers/rtc/rtc-ds1307.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 336cb9aa5e33..fab6e2ba345c 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -2006,9 +2006,36 @@ static int ds1307_probe(struct i2c_client *client,
 	return err;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int ds1307_suspend(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	if (client->irq && device_may_wakeup(dev))
+		return enable_irq_wake(client->irq);
+
+	return 0;
+}
+
+static int ds1307_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	if (client->irq && device_may_wakeup(dev))
+		return disable_irq_wake(client->irq);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(ds1307_pm_ops, ds1307_suspend, ds1307_resume);
+#endif
+
 static struct i2c_driver ds1307_driver = {
 	.driver = {
 		.name	= "rtc-ds1307",
+#ifdef CONFIG_PM_SLEEP
+		.pm     = &ds1307_pm_ops,
+#endif
 		.of_match_table = ds1307_of_match,
 	},
 	.probe		= ds1307_probe,
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ