aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps6507x-regulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/tps6507x-regulator.c')
-rw-r--r--drivers/regulator/tps6507x-regulator.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index 162a0fae20b3..98e66ce26723 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -359,7 +359,6 @@ static struct regulator_ops tps6507x_pmic_ops = {
359 .map_voltage = regulator_map_voltage_ascend, 359 .map_voltage = regulator_map_voltage_ascend,
360}; 360};
361 361
362#ifdef CONFIG_OF
363static struct of_regulator_match tps6507x_matches[] = { 362static struct of_regulator_match tps6507x_matches[] = {
364 { .name = "VDCDC1"}, 363 { .name = "VDCDC1"},
365 { .name = "VDCDC2"}, 364 { .name = "VDCDC2"},
@@ -381,12 +380,10 @@ static struct tps6507x_board *tps6507x_parse_dt_reg_data(
381 380
382 tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board), 381 tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board),
383 GFP_KERNEL); 382 GFP_KERNEL);
384 if (!tps_board) { 383 if (!tps_board)
385 dev_err(&pdev->dev, "Failure to alloc pdata for regulators.\n");
386 return NULL; 384 return NULL;
387 }
388 385
389 regulators = of_find_node_by_name(np, "regulators"); 386 regulators = of_get_child_by_name(np, "regulators");
390 if (!regulators) { 387 if (!regulators) {
391 dev_err(&pdev->dev, "regulator node not found\n"); 388 dev_err(&pdev->dev, "regulator node not found\n");
392 return NULL; 389 return NULL;
@@ -396,6 +393,7 @@ static struct tps6507x_board *tps6507x_parse_dt_reg_data(
396 matches = tps6507x_matches; 393 matches = tps6507x_matches;
397 394
398 ret = of_regulator_match(&pdev->dev, regulators, matches, count); 395 ret = of_regulator_match(&pdev->dev, regulators, matches, count);
396 of_node_put(regulators);
399 if (ret < 0) { 397 if (ret < 0) {
400 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", 398 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
401 ret); 399 ret);
@@ -406,10 +404,8 @@ static struct tps6507x_board *tps6507x_parse_dt_reg_data(
406 404
407 reg_data = devm_kzalloc(&pdev->dev, (sizeof(struct regulator_init_data) 405 reg_data = devm_kzalloc(&pdev->dev, (sizeof(struct regulator_init_data)
408 * TPS6507X_NUM_REGULATOR), GFP_KERNEL); 406 * TPS6507X_NUM_REGULATOR), GFP_KERNEL);
409 if (!reg_data) { 407 if (!reg_data)
410 dev_err(&pdev->dev, "Failure to alloc init data for regulators.\n");
411 return NULL; 408 return NULL;
412 }
413 409
414 tps_board->tps6507x_pmic_init_data = reg_data; 410 tps_board->tps6507x_pmic_init_data = reg_data;
415 411
@@ -424,15 +420,7 @@ static struct tps6507x_board *tps6507x_parse_dt_reg_data(
424 420
425 return tps_board; 421 return tps_board;
426} 422}
427#else 423
428static inline struct tps6507x_board *tps6507x_parse_dt_reg_data(
429 struct platform_device *pdev,
430 struct of_regulator_match **tps6507x_reg_matches)
431{
432 *tps6507x_reg_matches = NULL;
433 return NULL;
434}
435#endif
436static int tps6507x_pmic_probe(struct platform_device *pdev) 424static int tps6507x_pmic_probe(struct platform_device *pdev)
437{ 425{
438 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); 426 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
@@ -453,9 +441,10 @@ static int tps6507x_pmic_probe(struct platform_device *pdev)
453 */ 441 */
454 442
455 tps_board = dev_get_platdata(tps6507x_dev->dev); 443 tps_board = dev_get_platdata(tps6507x_dev->dev);
456 if (!tps_board && tps6507x_dev->dev->of_node) 444 if (IS_ENABLED(CONFIG_OF) && !tps_board &&
445 tps6507x_dev->dev->of_node)
457 tps_board = tps6507x_parse_dt_reg_data(pdev, 446 tps_board = tps6507x_parse_dt_reg_data(pdev,
458 &tps6507x_reg_matches); 447 &tps6507x_reg_matches);
459 if (!tps_board) 448 if (!tps_board)
460 return -EINVAL; 449 return -EINVAL;
461 450
@@ -481,7 +470,7 @@ static int tps6507x_pmic_probe(struct platform_device *pdev)
481 tps->info[i] = info; 470 tps->info[i] = info;
482 if (init_data->driver_data) { 471 if (init_data->driver_data) {
483 struct tps6507x_reg_platform_data *data = 472 struct tps6507x_reg_platform_data *data =
484 init_data->driver_data; 473 init_data->driver_data;
485 tps->info[i]->defdcdc_default = data->defdcdc_default; 474 tps->info[i]->defdcdc_default = data->defdcdc_default;
486 } 475 }
487 476