Skip to contentSkip to conversation

regulator: max77693: Remove unnecessary **rdev from struct max77693_pmic_dev

PATCH Applied Axel Lin 2 participants 6 messages Mar 9, 2014 – Mar 10, 2014

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/3 regulator: max77693: Remove unnecessary **rdev from struct max77693_pmic_dev

Now we are using devm_regulator_register(), so we don't need to allocate *rdev[] array to store return value of devm_regulator_register. Use a *rdev variable is enough for checking return status.

---
 drivers/regulator/max77693.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/regulator/max77693.c +5 -11
index d6807fd..f5f85c2 100644
@@ -38,7 +38,6 @@ struct max77693_pmic_dev {
 	struct device *dev;
 	struct max77693_dev *iodev;
 	int num_regulators;
-	struct regulator_dev **rdev;
 };
 
 /* CHARGER regulator ops */
@@ -249,12 +248,6 @@ static int max77693_pmic_probe(struct platform_device *pdev)
 	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;
@@ -265,17 +258,18 @@ static int max77693_pmic_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, max77693_pmic);
 
 	for (i = 0; i < max77693_pmic->num_regulators; i++) {
+		struct regulator_dev *rdev;
 		int id = rdata[i].id;
 
 		config.init_data = rdata[i].initdata;
 		config.of_node = rdata[i].of_node;
 
-		max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev,
-						&regulators[id], &config);
-		if (IS_ERR(max77693_pmic->rdev[i])) {
+		rdev = devm_regulator_register(&pdev->dev, &regulators[id],
+					       &config);
+		if (IS_ERR(rdev)) {
 			dev_err(max77693_pmic->dev,
 				"Failed to initialize regulator-%d\n", id);
-			return PTR_ERR(max77693_pmic->rdev[i]);
+			return PTR_ERR(rdev);
 		}
 	}
 
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH 2/3 regulator: max8997: Remove unnecessary **rdev from struct max8997_data

Now we are using devm_regulator_register(), so we don't need to allocate *rdev[] array to store return value of devm_regulator_register. Use a *rdev variable is enough for checking return status.

---
 drivers/regulator/max8997.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/regulator/max8997.c +6 -13
index f657d8d..90b4c53 100644
@@ -38,7 +38,6 @@ struct max8997_data {
 	struct device *dev;
 	struct max8997_dev *iodev;
 	int num_regulators;
-	struct regulator_dev **rdev;
 	int ramp_delay; /* in mV/us */
 
 	bool buck1_gpiodvs;
@@ -1029,10 +1028,10 @@ static int max8997_pmic_probe(struct platform_device *pdev)
 	struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	struct max8997_platform_data *pdata = iodev->pdata;
 	struct regulator_config config = { };
-	struct regulator_dev **rdev;
+	struct regulator_dev *rdev;
 	struct max8997_data *max8997;
 	struct i2c_client *i2c;
-	int i, ret, size, nr_dvs;
+	int i, ret, nr_dvs;
 	u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0;
 
 	if (!pdata) {
@@ -1051,12 +1050,6 @@ static int max8997_pmic_probe(struct platform_device *pdev)
 	if (!max8997)
 		return -ENOMEM;
 
-	size = sizeof(struct regulator_dev *) * pdata->num_regulators;
-	max8997->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
-	if (!max8997->rdev)
-		return -ENOMEM;
-
-	rdev = max8997->rdev;
 	max8997->dev = &pdev->dev;
 	max8997->iodev = iodev;
 	max8997->num_regulators = pdata->num_regulators;
@@ -1204,12 +1197,12 @@ static int max8997_pmic_probe(struct platform_device *pdev)
 		config.driver_data = max8997;
 		config.of_node = pdata->regulators[i].reg_node;
 
-		rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id],
-						  &config);
-		if (IS_ERR(rdev[i])) {
+		rdev = devm_regulator_register(&pdev->dev, &regulators[id],
+					       &config);
+		if (IS_ERR(rdev)) {
 			dev_err(max8997->dev, "regulator init failed for %d\n",
 					id);
-			return PTR_ERR(rdev[i]);
+			return PTR_ERR(rdev);
 		}
 	}
 
Signature · 1 line
1.8.1.2
author
#3 lore raw

PATCH 3/3 regulator: max8998: Remove unnecessary **rdev from struct max8998_data

In reply to Axel Lin

Now we are using devm_regulator_register(), so we don't need to allocate *rdev[] array to store return value of devm_regulator_register. Use a *rdev variable is enough for checking return status.

---
 drivers/regulator/max8998.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/regulator/max8998.c +6 -14
index ce22d4f..961091b 100644
@@ -40,7 +40,6 @@ struct max8998_data {
 	struct device		*dev;
 	struct max8998_dev	*iodev;
 	int			num_regulators;
-	struct regulator_dev	**rdev;
 	u8                      buck1_vol[4]; /* voltages for selection */
 	u8                      buck2_vol[2];
 	unsigned int		buck1_idx; /* index to last changed voltage */
@@ -746,10 +745,10 @@ static int max8998_pmic_probe(struct platform_device *pdev)
 	struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);
 	struct max8998_platform_data *pdata = iodev->pdata;
 	struct regulator_config config = { };
-	struct regulator_dev **rdev;
+	struct regulator_dev *rdev;
 	struct max8998_data *max8998;
 	struct i2c_client *i2c;
-	int i, ret, size;
+	int i, ret;
 	unsigned int v;
 
 	if (!pdata) {
@@ -768,12 +767,6 @@ static int max8998_pmic_probe(struct platform_device *pdev)
 	if (!max8998)
 		return -ENOMEM;
 
-	size = sizeof(struct regulator_dev *) * pdata->num_regulators;
-	max8998->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
-	if (!max8998->rdev)
-		return -ENOMEM;
-
-	rdev = max8998->rdev;
 	max8998->dev = &pdev->dev;
 	max8998->iodev = iodev;
 	max8998->num_regulators = pdata->num_regulators;
@@ -877,13 +870,12 @@ static int max8998_pmic_probe(struct platform_device *pdev)
 		config.init_data = pdata->regulators[i].initdata;
 		config.driver_data = max8998;
 
-		rdev[i] = devm_regulator_register(&pdev->dev,
-						  &regulators[index], &config);
-		if (IS_ERR(rdev[i])) {
-			ret = PTR_ERR(rdev[i]);
+		rdev = devm_regulator_register(&pdev->dev, &regulators[index],
+					       &config);
+		if (IS_ERR(rdev)) {
+			ret = PTR_ERR(rdev);
 			dev_err(max8998->dev, "regulator %s init failed (%d)\n",
 						regulators[index].name, ret);
-			rdev[i] = NULL;
 			return ret;
 		}
 	}
Signature · 1 line
1.8.1.2
maintainer Applied
#2 lore raw

Re: [PATCH 2/3] regulator: max8997: Remove unnecessary **rdev from struct max8997_data

In reply to Axel Lin
Quoted 3 lines · Axel Lin

Now we are using devm_regulator_register(), so we don't need to allocate *rdev[] array to store return value of devm_regulator_register. Use a *rdev variable is enough for checking return status.

Applied, thanks.

maintainer Applied
#4 lore raw

Re: [PATCH 3/3] regulator: max8998: Remove unnecessary **rdev from struct max8998_data

In reply to Axel Lin
Quoted 3 lines · Axel Lin

Now we are using devm_regulator_register(), so we don't need to allocate *rdev[] array to store return value of devm_regulator_register. Use a *rdev variable is enough for checking return status.

Applied, thanks.

maintainer
#5 lore raw
In reply to Axel Lin
Quoted 3 lines · Axel Lin

Now we are using devm_regulator_register(), so we don't need to allocate *rdev[] array to store return value of devm_regulator_register. Use a *rdev variable is enough for checking return status.

This doesn't apply with Krzysztof's recent (and more comprehensive) patch - I think it's now redundant though? If not can you please resubmit against current code.