aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-03 19:50:22 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-09 07:37:09 -0400
commitc172708d38a401b2f3f841dfcd862b469fa0b670 (patch)
tree75e89c63fd0c76a2c69bb5ad6e45b3762bceb6b6 /drivers/regulator/core.c
parent1474e4dbcae04125ed6e503eadcef266846f4675 (diff)
regulator: core: Use a struct to pass in regulator runtime configuration
Rather than adding new arguments to regulator_register() every time we want to add a new bit of dynamic information at runtime change the function to take these via a struct. By doing this we avoid needing to do further changes like the recent addition of device tree support which required each regulator driver to be updated to take an additional parameter. The regulator_desc which should (mostly) be static data is still passed separately as most drivers are able to configure this statically at build time. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c4b626789f8e..8b9f8602d47b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2820,27 +2820,24 @@ static void rdev_init_debugfs(struct regulator_dev *rdev)
2820/** 2820/**
2821 * regulator_register - register regulator 2821 * regulator_register - register regulator
2822 * @regulator_desc: regulator to register 2822 * @regulator_desc: regulator to register
2823 * @dev: struct device for the regulator 2823 * @config: runtime configuration for regulator
2824 * @init_data: platform provided init data, passed through by driver
2825 * @driver_data: private regulator data
2826 * @of_node: OpenFirmware node to parse for device tree bindings (may be
2827 * NULL).
2828 * 2824 *
2829 * Called by regulator drivers to register a regulator. 2825 * Called by regulator drivers to register a regulator.
2830 * Returns 0 on success. 2826 * Returns 0 on success.
2831 */ 2827 */
2832struct regulator_dev * 2828struct regulator_dev *
2833regulator_register(const struct regulator_desc *regulator_desc, 2829regulator_register(const struct regulator_desc *regulator_desc,
2834 struct device *dev, const struct regulator_init_data *init_data, 2830 const struct regulator_config *config)
2835 void *driver_data, struct device_node *of_node)
2836{ 2831{
2837 const struct regulation_constraints *constraints = NULL; 2832 const struct regulation_constraints *constraints = NULL;
2833 const struct regulator_init_data *init_data;
2838 static atomic_t regulator_no = ATOMIC_INIT(0); 2834 static atomic_t regulator_no = ATOMIC_INIT(0);
2839 struct regulator_dev *rdev; 2835 struct regulator_dev *rdev;
2836 struct device *dev = config->dev;
2840 int ret, i; 2837 int ret, i;
2841 const char *supply = NULL; 2838 const char *supply = NULL;
2842 2839
2843 if (regulator_desc == NULL) 2840 if (regulator_desc == NULL || config == NULL)
2844 return ERR_PTR(-EINVAL); 2841 return ERR_PTR(-EINVAL);
2845 2842
2846 if (regulator_desc->name == NULL || regulator_desc->ops == NULL) 2843 if (regulator_desc->name == NULL || regulator_desc->ops == NULL)
@@ -2866,6 +2863,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
2866 return ERR_PTR(-EINVAL); 2863 return ERR_PTR(-EINVAL);
2867 } 2864 }
2868 2865
2866 init_data = config->init_data;
2867
2869 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL); 2868 rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL);
2870 if (rdev == NULL) 2869 if (rdev == NULL)
2871 return ERR_PTR(-ENOMEM); 2870 return ERR_PTR(-ENOMEM);
@@ -2873,7 +2872,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
2873 mutex_lock(&regulator_list_mutex); 2872 mutex_lock(&regulator_list_mutex);
2874 2873
2875 mutex_init(&rdev->mutex); 2874 mutex_init(&rdev->mutex);
2876 rdev->reg_data = driver_data; 2875 rdev->reg_data = config->driver_data;
2877 rdev->owner = regulator_desc->owner; 2876 rdev->owner = regulator_desc->owner;
2878 rdev->desc = regulator_desc; 2877 rdev->desc = regulator_desc;
2879 INIT_LIST_HEAD(&rdev->consumer_list); 2878 INIT_LIST_HEAD(&rdev->consumer_list);
@@ -2890,7 +2889,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
2890 2889
2891 /* register with sysfs */ 2890 /* register with sysfs */
2892 rdev->dev.class = &regulator_class; 2891 rdev->dev.class = &regulator_class;
2893 rdev->dev.of_node = of_node; 2892 rdev->dev.of_node = config->of_node;
2894 rdev->dev.parent = dev; 2893 rdev->dev.parent = dev;
2895 dev_set_name(&rdev->dev, "regulator.%d", 2894 dev_set_name(&rdev->dev, "regulator.%d",
2896 atomic_inc_return(&regulator_no) - 1); 2895 atomic_inc_return(&regulator_no) - 1);