linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: extend the fixed voltage regulator to accept voltage
@ 2012-06-18  8:19 Guennadi Liakhovetski
  2012-06-18  9:41 ` Mark Brown
  0 siblings, 1 reply; 16+ messages in thread
From: Guennadi Liakhovetski @ 2012-06-18  8:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood

Trivially extend the regulator_register_fixed() helper function to be even
more useful by letting it accept a voltage parameter. The original function
is provided as a wrapper macro.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/regulator/fixed-helper.c |   21 ++++++++++++++++-----
 include/linux/regulator/fixed.h  |   10 ++++++----
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c
index cacd33c..d979ff0 100644
--- a/drivers/regulator/fixed-helper.c
+++ b/drivers/regulator/fixed-helper.c
@@ -1,12 +1,17 @@
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
 
+#define FIXED_BASE "fixed-dummy"
+#define FIXED_NAME FIXED_BASE "-00"
+
 struct fixed_regulator_data {
 	struct fixed_voltage_config cfg;
 	struct regulator_init_data init_data;
 	struct platform_device pdev;
+	char name[sizeof(FIXED_NAME)];
 };
 
 static void regulator_fixed_release(struct device *dev)
@@ -17,13 +22,14 @@ static void regulator_fixed_release(struct device *dev)
 }
 
 /**
- * regulator_register_fixed - register a no-op fixed regulator
+ * regulator_register_fixed_volt - register a no-op fixed regulator
  * @id: platform device id
  * @supplies: consumers for this regulator
  * @num_supplies: number of consumers
+ * @uv: voltage in microvolts
  */
-struct platform_device *regulator_register_fixed(int id,
-		struct regulator_consumer_supply *supplies, int num_supplies)
+struct platform_device *regulator_register_fixed_volt(int id,
+	struct regulator_consumer_supply *supplies, int num_supplies, int uv)
 {
 	struct fixed_regulator_data *data;
 
@@ -31,8 +37,13 @@ struct platform_device *regulator_register_fixed(int id,
 	if (!data)
 		return NULL;
 
-	data->cfg.supply_name = "fixed-dummy";
-	data->cfg.microvolts = 0;
+	if (id < 0)
+		strcpy(data->name, FIXED_BASE);
+	else
+		snprintf(data->name, sizeof(FIXED_NAME), FIXED_BASE "-%d", id);
+
+	data->cfg.supply_name = data->name;
+	data->cfg.microvolts = uv;
 	data->cfg.gpio = -EINVAL;
 	data->cfg.enabled_at_boot = 1;
 	data->cfg.init_data = &data->init_data;
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
index f83f744..1735f0a 100644
--- a/include/linux/regulator/fixed.h
+++ b/include/linux/regulator/fixed.h
@@ -58,14 +58,16 @@ struct fixed_voltage_config {
 struct regulator_consumer_supply;
 
 #if IS_ENABLED(CONFIG_REGULATOR)
-struct platform_device *regulator_register_fixed(int id,
-		struct regulator_consumer_supply *supplies, int num_supplies);
+struct platform_device *regulator_register_fixed_volt(int id,
+	struct regulator_consumer_supply *supplies, int num_supplies, int uv);
 #else
-static inline struct platform_device *regulator_register_fixed(int id,
-		struct regulator_consumer_supply *supplies, int num_supplies)
+static inline struct platform_device *regulator_register_fixed_volt(int id,
+	struct regulator_consumer_supply *supplies, int num_supplies, int uv)
 {
 	return NULL;
 }
 #endif
 
+#define regulator_register_fixed(id, s, ns) regulator_register_fixed_volt(id, s, ns, 0)
+
 #endif
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-06-19 22:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-18  8:19 [PATCH] regulator: extend the fixed voltage regulator to accept voltage Guennadi Liakhovetski
2012-06-18  9:41 ` Mark Brown
2012-06-18  9:52   ` Guennadi Liakhovetski
2012-06-18 10:06     ` Mark Brown
2012-06-18 10:13       ` Guennadi Liakhovetski
2012-06-18 11:57         ` Mark Brown
2012-06-18 15:57           ` [PATCH 1/2 v2] regulator: support multiple dummy fixed regulators Guennadi Liakhovetski
2012-06-18 15:57             ` [PATCH 2/2 v2] regulator: extend the fixed dummy voltage regulator to accept voltage Guennadi Liakhovetski
2012-06-18 16:20             ` [PATCH 1/2 v2] regulator: support multiple dummy fixed regulators Mark Brown
2012-06-18 16:30               ` Guennadi Liakhovetski
2012-06-18 16:37                 ` Mark Brown
2012-06-18 17:13                   ` Guennadi Liakhovetski
2012-06-18 17:28                     ` Mark Brown
2012-06-19 15:43                       ` [PATCH 1/2 v3] " Guennadi Liakhovetski
2012-06-19 15:44                         ` [PATCH 2/2 v3] regulator: extend the fixed dummy voltage regulator to accept voltage Guennadi Liakhovetski
2012-06-19 22:28                         ` [PATCH 1/2 v3] regulator: support multiple dummy fixed regulators Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).