aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-06-21 02:30:22 -0400
committerMark Brown <broonie@linaro.org>2013-06-21 06:00:54 -0400
commitdb892ff6c0f49708f13d9dff3957034f2f90e1c1 (patch)
tree2e3a95dd097cb177b296daa786a9d4fbbe9a09d1 /drivers/regulator
parent7d132055814ef17a6c7b69f342244c410a5e000f (diff)
regulators: max8973: fix multiple instance support
Currently the max8973 regulator driver uses a single static struct of regulator operations for all chip instances, but can overwrite some of its members depending on configuration. This will affect all other MAX8973 instances on the system. This patch fixes this bug by allocating a separate copy of the struct for each chip instance. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/max8973-regulator.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index adb1414e5e37..b2dbdd70cab1 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -100,6 +100,7 @@ struct max8973_chip {
100 int curr_vout_reg; 100 int curr_vout_reg;
101 int curr_gpio_val; 101 int curr_gpio_val;
102 bool valid_dvs_gpio; 102 bool valid_dvs_gpio;
103 struct regulator_ops ops;
103}; 104};
104 105
105/* 106/*
@@ -240,7 +241,7 @@ static unsigned int max8973_dcdc_get_mode(struct regulator_dev *rdev)
240 REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL; 241 REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
241} 242}
242 243
243static struct regulator_ops max8973_dcdc_ops = { 244static const struct regulator_ops max8973_dcdc_ops = {
244 .get_voltage_sel = max8973_dcdc_get_voltage_sel, 245 .get_voltage_sel = max8973_dcdc_get_voltage_sel,
245 .set_voltage_sel = max8973_dcdc_set_voltage_sel, 246 .set_voltage_sel = max8973_dcdc_set_voltage_sel,
246 .list_voltage = regulator_list_voltage_linear, 247 .list_voltage = regulator_list_voltage_linear,
@@ -388,10 +389,11 @@ static int max8973_probe(struct i2c_client *client,
388 } 389 }
389 390
390 i2c_set_clientdata(client, max); 391 i2c_set_clientdata(client, max);
392 max->ops = max8973_dcdc_ops;
391 max->dev = &client->dev; 393 max->dev = &client->dev;
392 max->desc.name = id->name; 394 max->desc.name = id->name;
393 max->desc.id = 0; 395 max->desc.id = 0;
394 max->desc.ops = &max8973_dcdc_ops; 396 max->desc.ops = &max->ops;
395 max->desc.type = REGULATOR_VOLTAGE; 397 max->desc.type = REGULATOR_VOLTAGE;
396 max->desc.owner = THIS_MODULE; 398 max->desc.owner = THIS_MODULE;
397 max->desc.min_uV = MAX8973_MIN_VOLATGE; 399 max->desc.min_uV = MAX8973_MIN_VOLATGE;
@@ -401,9 +403,9 @@ static int max8973_probe(struct i2c_client *client,
401 if (!pdata->enable_ext_control) { 403 if (!pdata->enable_ext_control) {
402 max->desc.enable_reg = MAX8973_VOUT; 404 max->desc.enable_reg = MAX8973_VOUT;
403 max->desc.enable_mask = MAX8973_VOUT_ENABLE; 405 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
404 max8973_dcdc_ops.enable = regulator_enable_regmap; 406 max->ops.enable = regulator_enable_regmap;
405 max8973_dcdc_ops.disable = regulator_disable_regmap; 407 max->ops.disable = regulator_disable_regmap;
406 max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap; 408 max->ops.is_enabled = regulator_is_enabled_regmap;
407 } 409 }
408 410
409 max->enable_external_control = pdata->enable_ext_control; 411 max->enable_external_control = pdata->enable_ext_control;