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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 26 Jun 2020 18:32:20 +0900
From:   Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
To:     ulf.hansson@...aro.org, lgirdwood@...il.com, broonie@...nel.org,
        geert+renesas@...der.be, magnus.damm@...il.com
Cc:     linux-mmc@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-renesas-soc@...r.kernel.org,
        Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
Subject: [PATCH/RFC v4 2/4] regulator: fixed: add regulator_ops members for suspend/resume

The regulator-fixed driver is possible to be off by firmware
like PSCI while the system is suspended. If a consumer could get
such a condition from regulator_is_enabled(), it's useful by
consumers.

So, add some regulator_ops members for it. And then, if
regulator-fixed nodes have suitable sub-nodes and properties [1],
regulator_is_enabled() will return false while suspend() of
a consumer.

[1]
 - The node has regulator-state-(standby|mem|disk) sub-nodes.
 - The node doesn't have regulator-always-on.
 - The sub-node has regulator-off-in-suspend property.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>
---
 drivers/regulator/fixed.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index d54830e..0bd4a1a 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -35,6 +35,7 @@ struct fixed_voltage_data {
 
 	struct clk *enable_clock;
 	unsigned int clk_enable_counter;
+	bool disabled_in_suspend;
 };
 
 struct fixed_dev_type {
@@ -49,6 +50,31 @@ static const struct fixed_dev_type fixed_clkenable_data = {
 	.has_enable_clock = true,
 };
 
+static int reg_is_enabled(struct regulator_dev *rdev)
+{
+	struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
+
+	return !priv->disabled_in_suspend;
+}
+
+static int reg_prepare_disable(struct regulator_dev *rdev)
+{
+	struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
+
+	priv->disabled_in_suspend = true;
+
+	return 0;
+}
+
+static int reg_resume_early_disable(struct regulator_dev *rdev)
+{
+	struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
+
+	priv->disabled_in_suspend = false;
+
+	return 0;
+}
+
 static int reg_clock_enable(struct regulator_dev *rdev)
 {
 	struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
@@ -132,6 +158,9 @@ of_get_fixed_voltage_config(struct device *dev,
 }
 
 static struct regulator_ops fixed_voltage_ops = {
+	.is_enabled = reg_is_enabled,
+	.set_prepare_disable = reg_prepare_disable,
+	.clear_resume_early_disable = reg_resume_early_disable,
 };
 
 static struct regulator_ops fixed_voltage_clkenabled_ops = {
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ