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

+22 -58
+20 -56
drivers/regulator/pbias-regulator.c
··· 38 struct pbias_regulator_data { 39 struct regulator_desc desc; 40 void __iomem *pbias_addr; 41 - unsigned int pbias_reg; 42 struct regulator_dev *dev; 43 struct regmap *syscon; 44 const struct pbias_reg_info *info; 45 int voltage; 46 }; 47 48 - static int pbias_regulator_set_voltage(struct regulator_dev *dev, 49 - int min_uV, int max_uV, unsigned *selector) 50 - { 51 - struct pbias_regulator_data *data = rdev_get_drvdata(dev); 52 - const struct pbias_reg_info *info = data->info; 53 - int ret, vmode; 54 - 55 - if (min_uV <= 1800000) 56 - vmode = 0; 57 - else if (min_uV > 1800000) 58 - vmode = info->vmode; 59 - 60 - ret = regmap_update_bits(data->syscon, data->pbias_reg, 61 - info->vmode, vmode); 62 - 63 - return ret; 64 - } 65 - 66 - static int pbias_regulator_get_voltage(struct regulator_dev *rdev) 67 - { 68 - struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 69 - const struct pbias_reg_info *info = data->info; 70 - int value, voltage; 71 - 72 - regmap_read(data->syscon, data->pbias_reg, &value); 73 - value &= info->vmode; 74 - 75 - voltage = value ? 3000000 : 1800000; 76 - 77 - return voltage; 78 - } 79 80 static int pbias_regulator_enable(struct regulator_dev *rdev) 81 { 82 struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 83 const struct pbias_reg_info *info = data->info; 84 - int ret; 85 86 - ret = regmap_update_bits(data->syscon, data->pbias_reg, 87 - info->enable_mask, info->enable); 88 - 89 - return ret; 90 - } 91 - 92 - static int pbias_regulator_disable(struct regulator_dev *rdev) 93 - { 94 - struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 95 - const struct pbias_reg_info *info = data->info; 96 - int ret; 97 - 98 - ret = regmap_update_bits(data->syscon, data->pbias_reg, 99 - info->enable_mask, 0); 100 - return ret; 101 } 102 103 static int pbias_regulator_is_enable(struct regulator_dev *rdev) ··· 64 const struct pbias_reg_info *info = data->info; 65 int value; 66 67 - regmap_read(data->syscon, data->pbias_reg, &value); 68 69 - return (value & info->enable_mask) == info->enable_mask; 70 } 71 72 static struct regulator_ops pbias_regulator_voltage_ops = { 73 - .set_voltage = pbias_regulator_set_voltage, 74 - .get_voltage = pbias_regulator_get_voltage, 75 - .enable = pbias_regulator_enable, 76 - .disable = pbias_regulator_disable, 77 - .is_enabled = pbias_regulator_is_enable, 78 }; 79 80 static const struct pbias_reg_info pbias_mmc_omap2430 = { ··· 151 if (IS_ERR(syscon)) 152 return PTR_ERR(syscon); 153 154 cfg.dev = &pdev->dev; 155 156 for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { ··· 167 if (!res) 168 return -EINVAL; 169 170 - drvdata[data_idx].pbias_reg = res->start; 171 drvdata[data_idx].syscon = syscon; 172 drvdata[data_idx].info = info; 173 drvdata[data_idx].desc.name = info->name; 174 drvdata[data_idx].desc.owner = THIS_MODULE; 175 drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; 176 drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; 177 drvdata[data_idx].desc.n_voltages = 2; 178 drvdata[data_idx].desc.enable_time = info->enable_time; 179 180 cfg.init_data = pbias_matches[idx].init_data; 181 cfg.driver_data = &drvdata[data_idx];
··· 38 struct pbias_regulator_data { 39 struct regulator_desc desc; 40 void __iomem *pbias_addr; 41 struct regulator_dev *dev; 42 struct regmap *syscon; 43 const struct pbias_reg_info *info; 44 int voltage; 45 }; 46 47 + static const unsigned int pbias_volt_table[] = { 48 + 1800000, 49 + 3000000 50 + }; 51 52 static int pbias_regulator_enable(struct regulator_dev *rdev) 53 { 54 struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 55 const struct pbias_reg_info *info = data->info; 56 57 + return regmap_update_bits(data->syscon, rdev->desc->enable_reg, 58 + info->enable_mask, info->enable); 59 } 60 61 static int pbias_regulator_is_enable(struct regulator_dev *rdev) ··· 106 const struct pbias_reg_info *info = data->info; 107 int value; 108 109 + regmap_read(data->syscon, rdev->desc->enable_reg, &value); 110 111 + return (value & info->enable_mask) == info->enable; 112 } 113 114 static struct regulator_ops pbias_regulator_voltage_ops = { 115 + .list_voltage = regulator_list_voltage_table, 116 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 117 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 118 + .enable = pbias_regulator_enable, 119 + .disable = regulator_disable_regmap, 120 + .is_enabled = pbias_regulator_is_enable, 121 }; 122 123 static const struct pbias_reg_info pbias_mmc_omap2430 = { ··· 192 if (IS_ERR(syscon)) 193 return PTR_ERR(syscon); 194 195 + cfg.regmap = syscon; 196 cfg.dev = &pdev->dev; 197 198 for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { ··· 207 if (!res) 208 return -EINVAL; 209 210 drvdata[data_idx].syscon = syscon; 211 drvdata[data_idx].info = info; 212 drvdata[data_idx].desc.name = info->name; 213 drvdata[data_idx].desc.owner = THIS_MODULE; 214 drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; 215 drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; 216 + drvdata[data_idx].desc.volt_table = pbias_volt_table; 217 drvdata[data_idx].desc.n_voltages = 2; 218 drvdata[data_idx].desc.enable_time = info->enable_time; 219 + drvdata[data_idx].desc.vsel_reg = res->start; 220 + drvdata[data_idx].desc.vsel_mask = info->vmode; 221 + drvdata[data_idx].desc.enable_reg = res->start; 222 + drvdata[data_idx].desc.enable_mask = info->enable_mask; 223 224 cfg.init_data = pbias_matches[idx].init_data; 225 cfg.driver_data = &drvdata[data_idx];
+2 -2
include/linux/regulator/consumer.h
··· 258 static inline struct regulator *__must_check 259 regulator_get_optional(struct device *dev, const char *id) 260 { 261 - return NULL; 262 } 263 264 265 static inline struct regulator *__must_check 266 devm_regulator_get_optional(struct device *dev, const char *id) 267 { 268 - return NULL; 269 } 270 271 static inline void regulator_put(struct regulator *regulator)
··· 258 static inline struct regulator *__must_check 259 regulator_get_optional(struct device *dev, const char *id) 260 { 261 + return ERR_PTR(-ENODEV); 262 } 263 264 265 static inline struct regulator *__must_check 266 devm_regulator_get_optional(struct device *dev, const char *id) 267 { 268 + return ERR_PTR(-ENODEV); 269 } 270 271 static inline void regulator_put(struct regulator *regulator)