regulator: Fixes for 3.5

A couple of small fixes, plus larger fixes for the gpio-regulator driver
 the most recent changes for which had apparently not been tested at all
 in -next (or elsewhere from the looks of it).
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJP0TY3AAoJEBus8iNuMP3deYwP/Rmx6ZpoNVyLN5Ys24yujyG9
 dfS6+uDTWwaA3UsxhB8uFh0FOICnUQvpA/69XZFCoqyjS1ag4Zcn7PWz9jOm52N1
 NZDDAM0S5XfqgnVTW2ZMafIm3erkmmN6ElHNTQoI15c2M+hFCV+YsDXH50YXM3Qy
 gSzLR9HD5NJhnluvWnGySGjjo9qWH9eIyloLfBBXDf5KvwAdA1MR5z/QpJlePsij
 BcXmenuWk9FnRAo63xRMEzy3OHutOngq4dEgasolYb2uFjmW+dxspl+7Z6aaix7Y
 afYSJ2SNVIaLew1gtlP4GnXwCfS4nJy34RfP8X8QKtlMENDhHBnLbrThr3CDTdnL
 92UVFRoM7a2ufJDJ35xvT7AYJlHDhHpzNaBX07YWf8QiPBbQrZP7dbH47pQLMasz
 4TokGriICyKFgL9bVit8KilEisfRBJ7fsL0lr6kJZsVJTQZzK/TBnp0+BAVlkeOx
 tnIkk2KpCrZlUJLly+Ow3D7k8wBD/gCIZr5JD86rc4T29yXw98ohvw4WOmryRs3q
 U4AbYtyr2p1Ft78uw5wv2xB7T+Rqfp+CygvggapSSFV8/6ckn+9I7rJNPkoUDlfR
 doHR1ZrFCZgxyU66ZKJwQoaoBl2jmWQFi7/DVe1K8IB3oomL7KszeFKGZ44C0+cI
 OcPBmHTRBi3aM1cfJaGq
 =8FA4
 -----END PGP SIGNATURE-----

Merge tag 'regulator-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator fixes from Mark Brown:
 "A couple of small fixes, plus larger fixes for the gpio-regulator
  driver the most recent changes for which had apparently not been
  tested at all in -next (or elsewhere from the looks of it)."

* tag 'regulator-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: core: Properly handle the case min_uV < rdev->desc->min_uV in map_voltage_linear
  regulator: max8649: fix missing regmap in rdev
  regulator: gpio-regulator: populate selector from set_voltage
  regulator: gpio-regulator: Fix finding of smallest value
  regulator: gpio-regulator: do not pass drvdata pointer as reference
  regulator: anatop: Use correct __devexit_p annotation
  regulator: palmas: Fix wrong kfree calls
This commit is contained in:
Linus Torvalds 2012-06-11 06:53:48 +03:00
commit 68d7d768c6
5 changed files with 15 additions and 14 deletions

View File

@ -224,7 +224,7 @@ static struct platform_driver anatop_regulator_driver = {
.of_match_table = of_anatop_regulator_match_tbl,
},
.probe = anatop_regulator_probe,
.remove = anatop_regulator_remove,
.remove = __devexit_p(anatop_regulator_remove),
};
static int __init anatop_regulator_init(void)

View File

@ -2050,6 +2050,9 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
return -EINVAL;
}
if (min_uV < rdev->desc->min_uV)
min_uV = rdev->desc->min_uV;
ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
if (ret < 0)
return ret;

View File

@ -101,16 +101,20 @@ static int gpio_regulator_get_value(struct regulator_dev *dev)
}
static int gpio_regulator_set_value(struct regulator_dev *dev,
int min, int max)
int min, int max, unsigned *selector)
{
struct gpio_regulator_data *data = rdev_get_drvdata(dev);
int ptr, target, state, best_val = INT_MAX;
int ptr, target = 0, state, best_val = INT_MAX;
for (ptr = 0; ptr < data->nr_states; ptr++)
if (data->states[ptr].value < best_val &&
data->states[ptr].value >= min &&
data->states[ptr].value <= max)
data->states[ptr].value <= max) {
target = data->states[ptr].gpios;
best_val = data->states[ptr].value;
if (selector)
*selector = ptr;
}
if (best_val == INT_MAX)
return -EINVAL;
@ -128,7 +132,7 @@ static int gpio_regulator_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV,
unsigned *selector)
{
return gpio_regulator_set_value(dev, min_uV, max_uV);
return gpio_regulator_set_value(dev, min_uV, max_uV, selector);
}
static int gpio_regulator_list_voltage(struct regulator_dev *dev,
@ -145,7 +149,7 @@ static int gpio_regulator_list_voltage(struct regulator_dev *dev,
static int gpio_regulator_set_current_limit(struct regulator_dev *dev,
int min_uA, int max_uA)
{
return gpio_regulator_set_value(dev, min_uA, max_uA);
return gpio_regulator_set_value(dev, min_uA, max_uA, NULL);
}
static struct regulator_ops gpio_regulator_voltage_ops = {
@ -286,7 +290,7 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev)
cfg.dev = &pdev->dev;
cfg.init_data = config->init_data;
cfg.driver_data = &drvdata;
cfg.driver_data = drvdata;
drvdata->dev = regulator_register(&drvdata->desc, &cfg);
if (IS_ERR(drvdata->dev)) {

View File

@ -259,6 +259,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
config.dev = &client->dev;
config.init_data = pdata->regulator;
config.driver_data = info;
config.regmap = info->regmap;
info->regulator = regulator_register(&dcdc_desc, &config);
if (IS_ERR(info->regulator)) {

View File

@ -775,9 +775,6 @@ static __devinit int palmas_probe(struct platform_device *pdev)
err_unregister_regulator:
while (--id >= 0)
regulator_unregister(pmic->rdev[id]);
kfree(pmic->rdev);
kfree(pmic->desc);
kfree(pmic);
return ret;
}
@ -788,10 +785,6 @@ static int __devexit palmas_remove(struct platform_device *pdev)
for (id = 0; id < PALMAS_NUM_REGS; id++)
regulator_unregister(pmic->rdev[id]);
kfree(pmic->rdev);
kfree(pmic->desc);
kfree(pmic);
return 0;
}