Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: max77693: Let core parse DT and drop board files support

Simplify the driver by removing board file support and letting
regulator core to parse DT.

The max77693 regulator driver is used only on Exynos based boards which
are DT-only. Board files for Exynos are not supported.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
222d0f04 c517d838

+9 -84
+9 -84
drivers/regulator/max77693.c
··· 128 128 #define regulator_desc_esafeout(_num) { \ 129 129 .name = "ESAFEOUT"#_num, \ 130 130 .id = MAX77693_ESAFEOUT##_num, \ 131 + .of_match = of_match_ptr("ESAFEOUT"#_num), \ 132 + .regulators_node = of_match_ptr("regulators"), \ 131 133 .n_voltages = 4, \ 132 134 .ops = &max77693_safeout_ops, \ 133 135 .type = REGULATOR_VOLTAGE, \ ··· 147 145 { 148 146 .name = "CHARGER", 149 147 .id = MAX77693_CHARGER, 148 + .of_match = of_match_ptr("CHARGER"), 149 + .regulators_node = of_match_ptr("regulators"), 150 150 .ops = &max77693_charger_ops, 151 151 .type = REGULATOR_CURRENT, 152 152 .owner = THIS_MODULE, ··· 158 154 }, 159 155 }; 160 156 161 - #ifdef CONFIG_OF 162 - static int max77693_pmic_dt_parse_rdata(struct device *dev, 163 - struct max77693_regulator_data **rdata) 164 - { 165 - struct device_node *np; 166 - struct of_regulator_match *rmatch; 167 - struct max77693_regulator_data *tmp; 168 - int i, matched = 0; 169 - 170 - np = of_get_child_by_name(dev->parent->of_node, "regulators"); 171 - if (!np) 172 - return -EINVAL; 173 - 174 - rmatch = devm_kzalloc(dev, 175 - sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL); 176 - if (!rmatch) { 177 - of_node_put(np); 178 - return -ENOMEM; 179 - } 180 - 181 - for (i = 0; i < ARRAY_SIZE(regulators); i++) 182 - rmatch[i].name = regulators[i].name; 183 - 184 - matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators)); 185 - of_node_put(np); 186 - if (matched <= 0) 187 - return matched; 188 - *rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL); 189 - if (!(*rdata)) 190 - return -ENOMEM; 191 - 192 - tmp = *rdata; 193 - 194 - for (i = 0; i < matched; i++) { 195 - tmp->initdata = rmatch[i].init_data; 196 - tmp->of_node = rmatch[i].of_node; 197 - tmp->id = regulators[i].id; 198 - tmp++; 199 - } 200 - 201 - return matched; 202 - } 203 - #else 204 - static int max77693_pmic_dt_parse_rdata(struct device *dev, 205 - struct max77693_regulator_data **rdata) 206 - { 207 - return 0; 208 - } 209 - #endif /* CONFIG_OF */ 210 - 211 - static int max77693_pmic_init_rdata(struct device *dev, 212 - struct max77693_regulator_data **rdata) 213 - { 214 - struct max77693_platform_data *pdata; 215 - int num_regulators = 0; 216 - 217 - pdata = dev_get_platdata(dev->parent); 218 - if (pdata) { 219 - *rdata = pdata->regulators; 220 - num_regulators = pdata->num_regulators; 221 - } 222 - 223 - if (!(*rdata) && dev->parent->of_node) 224 - num_regulators = max77693_pmic_dt_parse_rdata(dev, rdata); 225 - 226 - return num_regulators; 227 - } 228 - 229 157 static int max77693_pmic_probe(struct platform_device *pdev) 230 158 { 231 159 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); 232 - struct max77693_regulator_data *rdata = NULL; 233 - int num_rdata, i; 160 + int i; 234 161 struct regulator_config config = { }; 235 162 236 - num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); 237 - if (!rdata || num_rdata <= 0) { 238 - dev_err(&pdev->dev, "No init data supplied.\n"); 239 - return -ENODEV; 240 - } 241 - 242 - config.dev = &pdev->dev; 163 + config.dev = iodev->dev; 243 164 config.regmap = iodev->regmap; 244 165 245 - for (i = 0; i < num_rdata; i++) { 246 - int id = rdata[i].id; 166 + for (i = 0; i < ARRAY_SIZE(regulators); i++) { 247 167 struct regulator_dev *rdev; 248 168 249 - config.init_data = rdata[i].initdata; 250 - config.of_node = rdata[i].of_node; 251 - 252 169 rdev = devm_regulator_register(&pdev->dev, 253 - &regulators[id], &config); 170 + &regulators[i], &config); 254 171 if (IS_ERR(rdev)) { 255 172 dev_err(&pdev->dev, 256 - "Failed to initialize regulator-%d\n", id); 173 + "Failed to initialize regulator-%d\n", i); 257 174 return PTR_ERR(rdev); 258 175 } 259 176 }