Skip to contentSkip to conversation

Input: twl6040-vibra - use devm_regulator_bulk_get()

PATCH In review Fabio Estevam 2 participants 2 messages Apr 25, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: twl6040-vibra - use devm_regulator_bulk_get()

From: Fabio Estevam <[email protected]>

Using devm_regulator_bulk_get() can make the code cleaner and smaller as we do not need to call regulator_bulk_free() in the error and remove paths.

---
 drivers/input/misc/twl6040-vibra.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/input/misc/twl6040-vibra.c +6 -9
index 77dc23b..bf0cb2d 100644
@@ -323,8 +323,9 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 	 * When booted with Device tree the regulators are attached to the
 	 * parent device (twl6040 MFD core)
 	 */
-	ret = regulator_bulk_get(twl6040_core_dev, ARRAY_SIZE(info->supplies),
-				 info->supplies);
+	ret = devm_regulator_bulk_get(twl6040_core_dev,
+				      ARRAY_SIZE(info->supplies),
+				      info->supplies);
 	if (ret) {
 		dev_err(info->dev, "couldn't get regulators %d\n", ret);
 		return ret;
@@ -336,7 +337,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(info->dev, "failed to set VDDVIBL volt %d\n",
 				ret);
-			goto err_regulator;
+			return ret;
 		}
 	}
 
@@ -346,7 +347,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(info->dev, "failed to set VDDVIBR volt %d\n",
 				ret);
-			goto err_regulator;
+			return ret;
 		}
 	}
 
@@ -355,8 +356,7 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 	info->input_dev = input_allocate_device();
 	if (info->input_dev == NULL) {
 		dev_err(info->dev, "couldn't allocate input device\n");
-		ret = -ENOMEM;
-		goto err_regulator;
+		return -ENOMEM;
 	}
 
 	input_set_drvdata(info->input_dev, info);
@@ -387,8 +387,6 @@ err_iff:
 	input_ff_destroy(info->input_dev);
 err_ialloc:
 	input_free_device(info->input_dev);
-err_regulator:
-	regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies);
 	return ret;
 }
 
@@ -397,7 +395,6 @@ static int twl6040_vibra_remove(struct platform_device *pdev)
 	struct vibra_info *info = platform_get_drvdata(pdev);
 
 	input_unregister_device(info->input_dev);
-	regulator_bulk_free(ARRAY_SIZE(info->supplies), info->supplies);
 
 	return 0;
 }
Signature · 1 line
1.8.3.2
maintainer
#1 lore raw
Quoted 4 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Using devm_regulator_bulk_get() can make the code cleaner and smaller as we do not need to call regulator_bulk_free() in the error and remove paths.

Can we complete the conversion and use devm_input_allocate_device() as well?

Thanks.

Signature · 1 line
Dmitry