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 38 struct pbias_regulator_data { 39 39 struct regulator_desc desc; 40 40 void __iomem *pbias_addr; 41 - unsigned int pbias_reg; 42 41 struct regulator_dev *dev; 43 42 struct regmap *syscon; 44 43 const struct pbias_reg_info *info; 45 44 int voltage; 46 45 }; 47 46 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 - } 47 + static const unsigned int pbias_volt_table[] = { 48 + 1800000, 49 + 3000000 50 + }; 79 51 80 52 static int pbias_regulator_enable(struct regulator_dev *rdev) 81 53 { 82 54 struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 83 55 const struct pbias_reg_info *info = data->info; 84 - int ret; 85 56 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; 57 + return regmap_update_bits(data->syscon, rdev->desc->enable_reg, 58 + info->enable_mask, info->enable); 101 59 } 102 60 103 61 static int pbias_regulator_is_enable(struct regulator_dev *rdev) ··· 64 106 const struct pbias_reg_info *info = data->info; 65 107 int value; 66 108 67 - regmap_read(data->syscon, data->pbias_reg, &value); 109 + regmap_read(data->syscon, rdev->desc->enable_reg, &value); 68 110 69 - return (value & info->enable_mask) == info->enable_mask; 111 + return (value & info->enable_mask) == info->enable; 70 112 } 71 113 72 114 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, 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, 78 121 }; 79 122 80 123 static const struct pbias_reg_info pbias_mmc_omap2430 = { ··· 151 192 if (IS_ERR(syscon)) 152 193 return PTR_ERR(syscon); 153 194 195 + cfg.regmap = syscon; 154 196 cfg.dev = &pdev->dev; 155 197 156 198 for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { ··· 167 207 if (!res) 168 208 return -EINVAL; 169 209 170 - drvdata[data_idx].pbias_reg = res->start; 171 210 drvdata[data_idx].syscon = syscon; 172 211 drvdata[data_idx].info = info; 173 212 drvdata[data_idx].desc.name = info->name; 174 213 drvdata[data_idx].desc.owner = THIS_MODULE; 175 214 drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; 176 215 drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; 216 + drvdata[data_idx].desc.volt_table = pbias_volt_table; 177 217 drvdata[data_idx].desc.n_voltages = 2; 178 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; 179 223 180 224 cfg.init_data = pbias_matches[idx].init_data; 181 225 cfg.driver_data = &drvdata[data_idx];
+2 -2
include/linux/regulator/consumer.h
··· 258 258 static inline struct regulator *__must_check 259 259 regulator_get_optional(struct device *dev, const char *id) 260 260 { 261 - return NULL; 261 + return ERR_PTR(-ENODEV); 262 262 } 263 263 264 264 265 265 static inline struct regulator *__must_check 266 266 devm_regulator_get_optional(struct device *dev, const char *id) 267 267 { 268 - return NULL; 268 + return ERR_PTR(-ENODEV); 269 269 } 270 270 271 271 static inline void regulator_put(struct regulator *regulator)