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]
Message-Id: <20220504065252.6955-6-zev@bewilderbeest.net>
Date:   Tue,  3 May 2022 23:52:52 -0700
From:   Zev Weiss <zev@...ilderbeest.net>
To:     Mark Brown <broonie@...nel.org>,
        Liam Girdwood <lgirdwood@...il.com>
Cc:     Zev Weiss <zev@...ilderbeest.net>, linux-kernel@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        openbmc@...ts.ozlabs.org
Subject: [PATCH 6/6] regulator: core: Add external-consumer driver

An external consumer is a dummy device representing a device external
to the system that is supplied by a regulator designated for external
output.  It is purely a virtual placeholder to instantiate a regulator
by calling regulator_get() on it from its probe function.

Signed-off-by: Zev Weiss <zev@...ilderbeest.net>
---
 drivers/regulator/Kconfig |  9 +++++++++
 drivers/regulator/core.c  | 28 ++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 5ef2306fce04..5ec390687a81 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -56,6 +56,15 @@ config REGULATOR_USERSPACE_CONSUMER
 
 	  If unsure, say no.
 
+config REGULATOR_EXTERNAL_CONSUMER
+	bool "External regulator consumer support"
+	help
+	  Some regulators supply devices that are entirely external to
+	  the system.  This driver provides a placeholder consumer
+	  representing such devices.
+
+	  If unsure, say no.
+
 config REGULATOR_88PG86X
 	tristate "Marvell 88PG86X voltage regulators"
 	depends on I2C
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d873606eb41f..4f348b3d5290 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/of_regulator.h>
 #include <linux/regulator/consumer.h>
@@ -6070,6 +6071,33 @@ static int regulator_summary_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(regulator_summary);
 #endif /* CONFIG_DEBUG_FS */
 
+#ifdef CONFIG_REGULATOR_EXTERNAL_CONSUMER
+static int regulator_external_output_probe(struct platform_device *pdev)
+{
+	struct regulator *reg;
+
+	reg = devm_regulator_get_external(&pdev->dev, "vout");
+	if (IS_ERR(reg))
+		return PTR_ERR(reg);
+
+	return 0;
+}
+
+static const struct of_device_id reg_external_consumer_of_match_table[] = {
+	{ .compatible = "regulator-external-output" },
+	{ },
+};
+
+static struct platform_driver reg_external_consumer_driver = {
+	.driver = {
+		.name = "reg-external-consumer",
+		.of_match_table = reg_external_consumer_of_match_table,
+	},
+	.probe = regulator_external_output_probe,
+};
+builtin_platform_driver(reg_external_consumer_driver);
+#endif /* CONFIG_REGULATOR_EXTERNAL_CONSUMER */
+
 static int __init regulator_init(void)
 {
 	int ret;
-- 
2.36.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ