regulator: Fixes for v3.15

A couple of things here:
 
  - Fixes for pbias that didn't make it in during the merge window due to
    the driver coming in via MMC.  The conversion to use helpers is a
    fix as it implements list_voltage() which the main user (MMC) relies
    on for correct functioning.
  - Change the !REGULATOR stub for optional regulators to return an
    error rather than a dummy; this is more in keeping with the intended
    use of optional regulators and fixes some issues seen MMC where it
    got confused by a dummy being provided.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJTWP4ZAAoJELSic+t+oim9D54P/1iF292i/GenPCAHJo/kIV/j
 uoiTcE5igqVoEeEtseqkSOy2Wsf9rukNZvQOyyioT6Pm6f+zOKW7pLPuJZmjqiHk
 9FOJYfQcoiYL7HpDMIAAANl5rSHlmDZPs4T40+pHh3LJB/NTnrig5MA0tfW7tcyi
 TF4PadYavvNwUYivE8NrMJs0qnuzqiXvEFIqZCxR7zm0AYqdVMkI27f4uKTRodcW
 8K8VkQ7F7gDyoCiD8ptviB6v9o2WofnZfLI+9qbxexKmb6TFRrvzTkQ8UdyV9LDs
 pLstzJsef7IGUDD6F/i3joKzB8Dp9Qp0+ykrffIbRfm+2Jo0xWXX+h9Ko10m1jji
 zhzi/dgWp+e7SkXNaWB4hX1mD+jO6KHEg7RRF0GG4Gv6Jql6shDqNwMLHS8TH/s3
 owKHdIaYHoyOx73xTJEePFbHgZTc+7YcC9NPtPe0bN2uheSMV9aHePiLoKuzx832
 ee6dPIqoMU/g8zvY5CPqLqdqx1Z64MNTg52QraGsYhQ7ik9cHf0cArp5QAbMjnKI
 XC7VY0Fulc0rlKkmCQ3KKxs3w+ahRgrdC+Ogne5SHQsB+5eHSGw+t3MIXWq/iiaE
 XwuAQKWIy/DbkG3LgcqQGCA5RgwNWO4lJ13mENtJ4CmYDqO0qDIEdKdZ0lqnLsz+
 5siSNt87fIcj5BpX2ZRm
 =t/Ad
 -----END PGP SIGNATURE-----

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

Pull regulator fixes from Mark Brown:
 "A couple of things here:

   - Fixes for pbias that didn't make it in during the merge window due
     to the driver coming in via MMC.  The conversion to use helpers is
     a fix as it implements list_voltage() which the main user (MMC)
     relies on for correct functioning.
   - Change the !REGULATOR stub for optional regulators to return an
     error rather than a dummy; this is more in keeping with the
     intended use of optional regulators and fixes some issues seen MMC
     where it got confused by a dummy being provided"

* tag 'regulator-v3.15-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
  regulator: core: Return error in get optional stub
  regulator: pbias: Convert to use regmap helper functions
  regulator: pbias: Fix is_enabled callback implementation
This commit is contained in:
Linus Torvalds 2014-04-24 12:01:58 -07:00
commit 76429f1ded
2 changed files with 22 additions and 58 deletions

View File

@ -38,66 +38,24 @@ struct pbias_reg_info {
struct pbias_regulator_data {
struct regulator_desc desc;
void __iomem *pbias_addr;
unsigned int pbias_reg;
struct regulator_dev *dev;
struct regmap *syscon;
const struct pbias_reg_info *info;
int voltage;
};
static int pbias_regulator_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV, unsigned *selector)
{
struct pbias_regulator_data *data = rdev_get_drvdata(dev);
const struct pbias_reg_info *info = data->info;
int ret, vmode;
if (min_uV <= 1800000)
vmode = 0;
else if (min_uV > 1800000)
vmode = info->vmode;
ret = regmap_update_bits(data->syscon, data->pbias_reg,
info->vmode, vmode);
return ret;
}
static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
{
struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
const struct pbias_reg_info *info = data->info;
int value, voltage;
regmap_read(data->syscon, data->pbias_reg, &value);
value &= info->vmode;
voltage = value ? 3000000 : 1800000;
return voltage;
}
static const unsigned int pbias_volt_table[] = {
1800000,
3000000
};
static int pbias_regulator_enable(struct regulator_dev *rdev)
{
struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
const struct pbias_reg_info *info = data->info;
int ret;
ret = regmap_update_bits(data->syscon, data->pbias_reg,
return regmap_update_bits(data->syscon, rdev->desc->enable_reg,
info->enable_mask, info->enable);
return ret;
}
static int pbias_regulator_disable(struct regulator_dev *rdev)
{
struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
const struct pbias_reg_info *info = data->info;
int ret;
ret = regmap_update_bits(data->syscon, data->pbias_reg,
info->enable_mask, 0);
return ret;
}
static int pbias_regulator_is_enable(struct regulator_dev *rdev)
@ -106,16 +64,17 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)
const struct pbias_reg_info *info = data->info;
int value;
regmap_read(data->syscon, data->pbias_reg, &value);
regmap_read(data->syscon, rdev->desc->enable_reg, &value);
return (value & info->enable_mask) == info->enable_mask;
return (value & info->enable_mask) == info->enable;
}
static struct regulator_ops pbias_regulator_voltage_ops = {
.set_voltage = pbias_regulator_set_voltage,
.get_voltage = pbias_regulator_get_voltage,
.list_voltage = regulator_list_voltage_table,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.enable = pbias_regulator_enable,
.disable = pbias_regulator_disable,
.disable = regulator_disable_regmap,
.is_enabled = pbias_regulator_is_enable,
};
@ -192,6 +151,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
if (IS_ERR(syscon))
return PTR_ERR(syscon);
cfg.regmap = syscon;
cfg.dev = &pdev->dev;
for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) {
@ -207,15 +167,19 @@ static int pbias_regulator_probe(struct platform_device *pdev)
if (!res)
return -EINVAL;
drvdata[data_idx].pbias_reg = res->start;
drvdata[data_idx].syscon = syscon;
drvdata[data_idx].info = info;
drvdata[data_idx].desc.name = info->name;
drvdata[data_idx].desc.owner = THIS_MODULE;
drvdata[data_idx].desc.type = REGULATOR_VOLTAGE;
drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops;
drvdata[data_idx].desc.volt_table = pbias_volt_table;
drvdata[data_idx].desc.n_voltages = 2;
drvdata[data_idx].desc.enable_time = info->enable_time;
drvdata[data_idx].desc.vsel_reg = res->start;
drvdata[data_idx].desc.vsel_mask = info->vmode;
drvdata[data_idx].desc.enable_reg = res->start;
drvdata[data_idx].desc.enable_mask = info->enable_mask;
cfg.init_data = pbias_matches[idx].init_data;
cfg.driver_data = &drvdata[data_idx];

View File

@ -258,14 +258,14 @@ regulator_get_exclusive(struct device *dev, const char *id)
static inline struct regulator *__must_check
regulator_get_optional(struct device *dev, const char *id)
{
return NULL;
return ERR_PTR(-ENODEV);
}
static inline struct regulator *__must_check
devm_regulator_get_optional(struct device *dev, const char *id)
{
return NULL;
return ERR_PTR(-ENODEV);
}
static inline void regulator_put(struct regulator *regulator)