[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.1206181755370.23884@axis700.grange>
Date: Mon, 18 Jun 2012 17:57:24 +0200 (CEST)
From: Guennadi Liakhovetski <g.liakhovetski@....de>
To: Mark Brown <broonie@...nsource.wolfsonmicro.com>
cc: linux-kernel@...r.kernel.org, Liam Girdwood <lrg@...com>
Subject: [PATCH 1/2 v2] regulator: support multiple dummy fixed regulators
Currently regulator_register_fixed() uses a constant name to register a
fixed dummy regulator. This is sufficient in principle, since there is no
reason to register multiple such regulators. The user can simply supply all
consumers in one array and use it to initialise such a regulator. However,
in some cases it can be convenient to register multiple such regulators.
This is also easy to achieve by appending the device ID to the name. It is
also consistent with the current behaviour of the code, that fixes a name
itself without giving the user a possibility to provide a custom one.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@....de>
---
drivers/regulator/fixed-helper.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/regulator/fixed-helper.c b/drivers/regulator/fixed-helper.c
index cacd33c..f66d9e8 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)
@@ -31,7 +36,12 @@ struct platform_device *regulator_register_fixed(int id,
if (!data)
return NULL;
- data->cfg.supply_name = "fixed-dummy";
+ 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 = 0;
data->cfg.gpio = -EINVAL;
data->cfg.enabled_at_boot = 1;
--
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists