From 640c24a77b5691b5fe802b6f51fb4e2ae1bee846 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 10 Mar 2014 09:32:46 +0100 Subject: [PATCH] regulator: max77693: Remove state container as it is not needed Don't store pointers to regulator_dev returned by devm_regulator_register() in allocated memory in state container. They aren't used anywhere outside of max77693_pmic_probe() function. This change allows removing completely the 'struct max77693_pmic_dev' state container as none of its fields are used outside of probe. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/max77693.c | 37 ++++++------------------------------ 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index d6807fd7eadc..653a58b49cdf 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c @@ -34,13 +34,6 @@ #define CHGIN_ILIM_STEP_20mA 20000 -struct max77693_pmic_dev { - struct device *dev; - struct max77693_dev *iodev; - int num_regulators; - struct regulator_dev **rdev; -}; - /* CHARGER regulator ops */ /* CHARGER regulator uses two bits for enabling */ static int max77693_chg_is_enabled(struct regulator_dev *rdev) @@ -232,7 +225,6 @@ static int max77693_pmic_init_rdata(struct device *dev, static int max77693_pmic_probe(struct platform_device *pdev) { struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct max77693_pmic_dev *max77693_pmic; struct max77693_regulator_data *rdata = NULL; int num_rdata, i; struct regulator_config config; @@ -243,39 +235,22 @@ static int max77693_pmic_probe(struct platform_device *pdev) return -ENODEV; } - max77693_pmic = devm_kzalloc(&pdev->dev, - sizeof(struct max77693_pmic_dev), - GFP_KERNEL); - if (!max77693_pmic) - return -ENOMEM; - - max77693_pmic->rdev = devm_kzalloc(&pdev->dev, - sizeof(struct regulator_dev *) * num_rdata, - GFP_KERNEL); - if (!max77693_pmic->rdev) - return -ENOMEM; - - max77693_pmic->dev = &pdev->dev; - max77693_pmic->iodev = iodev; - max77693_pmic->num_regulators = num_rdata; - config.dev = &pdev->dev; config.regmap = iodev->regmap; - config.driver_data = max77693_pmic; - platform_set_drvdata(pdev, max77693_pmic); - for (i = 0; i < max77693_pmic->num_regulators; i++) { + for (i = 0; i < num_rdata; i++) { int id = rdata[i].id; + struct regulator_dev *rdev; config.init_data = rdata[i].initdata; config.of_node = rdata[i].of_node; - max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev, + rdev = devm_regulator_register(&pdev->dev, ®ulators[id], &config); - if (IS_ERR(max77693_pmic->rdev[i])) { - dev_err(max77693_pmic->dev, + if (IS_ERR(rdev)) { + dev_err(&pdev->dev, "Failed to initialize regulator-%d\n", id); - return PTR_ERR(max77693_pmic->rdev[i]); + return PTR_ERR(rdev); } }