aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8998.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/max8998.c')
-rw-r--r--drivers/regulator/max8998.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index ae3f0656feb0..961091b46557 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -40,7 +40,6 @@ struct max8998_data {
40 struct device *dev; 40 struct device *dev;
41 struct max8998_dev *iodev; 41 struct max8998_dev *iodev;
42 int num_regulators; 42 int num_regulators;
43 struct regulator_dev **rdev;
44 u8 buck1_vol[4]; /* voltages for selection */ 43 u8 buck1_vol[4]; /* voltages for selection */
45 u8 buck2_vol[2]; 44 u8 buck2_vol[2];
46 unsigned int buck1_idx; /* index to last changed voltage */ 45 unsigned int buck1_idx; /* index to last changed voltage */
@@ -674,8 +673,10 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
674 673
675 rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * 674 rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
676 pdata->num_regulators, GFP_KERNEL); 675 pdata->num_regulators, GFP_KERNEL);
677 if (!rdata) 676 if (!rdata) {
677 of_node_put(regulators_np);
678 return -ENOMEM; 678 return -ENOMEM;
679 }
679 680
680 pdata->regulators = rdata; 681 pdata->regulators = rdata;
681 for (i = 0; i < ARRAY_SIZE(regulators); ++i) { 682 for (i = 0; i < ARRAY_SIZE(regulators); ++i) {
@@ -692,6 +693,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
692 } 693 }
693 pdata->num_regulators = rdata - pdata->regulators; 694 pdata->num_regulators = rdata - pdata->regulators;
694 695
696 of_node_put(reg_np);
697 of_node_put(regulators_np);
698
695 ret = max8998_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); 699 ret = max8998_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np);
696 if (ret) 700 if (ret)
697 return -EINVAL; 701 return -EINVAL;
@@ -741,10 +745,10 @@ static int max8998_pmic_probe(struct platform_device *pdev)
741 struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); 745 struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);
742 struct max8998_platform_data *pdata = iodev->pdata; 746 struct max8998_platform_data *pdata = iodev->pdata;
743 struct regulator_config config = { }; 747 struct regulator_config config = { };
744 struct regulator_dev **rdev; 748 struct regulator_dev *rdev;
745 struct max8998_data *max8998; 749 struct max8998_data *max8998;
746 struct i2c_client *i2c; 750 struct i2c_client *i2c;
747 int i, ret, size; 751 int i, ret;
748 unsigned int v; 752 unsigned int v;
749 753
750 if (!pdata) { 754 if (!pdata) {
@@ -763,12 +767,6 @@ static int max8998_pmic_probe(struct platform_device *pdev)
763 if (!max8998) 767 if (!max8998)
764 return -ENOMEM; 768 return -ENOMEM;
765 769
766 size = sizeof(struct regulator_dev *) * pdata->num_regulators;
767 max8998->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
768 if (!max8998->rdev)
769 return -ENOMEM;
770
771 rdev = max8998->rdev;
772 max8998->dev = &pdev->dev; 770 max8998->dev = &pdev->dev;
773 max8998->iodev = iodev; 771 max8998->iodev = iodev;
774 max8998->num_regulators = pdata->num_regulators; 772 max8998->num_regulators = pdata->num_regulators;
@@ -872,13 +870,12 @@ static int max8998_pmic_probe(struct platform_device *pdev)
872 config.init_data = pdata->regulators[i].initdata; 870 config.init_data = pdata->regulators[i].initdata;
873 config.driver_data = max8998; 871 config.driver_data = max8998;
874 872
875 rdev[i] = devm_regulator_register(&pdev->dev, 873 rdev = devm_regulator_register(&pdev->dev, &regulators[index],
876 &regulators[index], &config); 874 &config);
877 if (IS_ERR(rdev[i])) { 875 if (IS_ERR(rdev)) {
878 ret = PTR_ERR(rdev[i]); 876 ret = PTR_ERR(rdev);
879 dev_err(max8998->dev, "regulator %s init failed (%d)\n", 877 dev_err(max8998->dev, "regulator %s init failed (%d)\n",
880 regulators[index].name, ret); 878 regulators[index].name, ret);
881 rdev[i] = NULL;
882 return ret; 879 return ret;
883 } 880 }
884 } 881 }