diff mbox series

[v2] hwmon: chipcap2: drop cc2_disable() in the probe and return dev_err_probe()

Message ID 20240813-chipcap2-probe-improvements-v2-1-e9a2932a8a00@gmail.com (mailing list archive)
State Accepted
Headers show
Series [v2] hwmon: chipcap2: drop cc2_disable() in the probe and return dev_err_probe() | expand

Commit Message

Javier Carrasco Aug. 12, 2024, 10:59 p.m. UTC
There is no need to actively disable a regulator that has not been
enabled by the driver, which makes the call to cc2_disable() in the
probe function meaningless, because the probe function never enables
the device's dedicated regulator.

Once the call to cc2_disable() is dropped, the error paths can directly
return dev_err_probe() in all cases.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Changes in v2:
- Drop cc2_disable() in the probe function.
- Return dev_err_probe() in the error paths.
- Link to v1: https://lore.kernel.org/r/20240812-chipcap2-probe-improvements-v1-0-3cdff6d16897@gmail.com
---
 drivers/hwmon/chipcap2.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)


---
base-commit: 9e6869691724b12e1f43655eeedc35fade38120c
change-id: 20240812-chipcap2-probe-improvements-c94d1431f1ef

Best regards,

Comments

Guenter Roeck Aug. 13, 2024, 3:53 p.m. UTC | #1
On Tue, Aug 13, 2024 at 12:59:53AM +0200, Javier Carrasco wrote:
> There is no need to actively disable a regulator that has not been
> enabled by the driver, which makes the call to cc2_disable() in the
> probe function meaningless, because the probe function never enables
> the device's dedicated regulator.
> 
> Once the call to cc2_disable() is dropped, the error paths can directly
> return dev_err_probe() in all cases.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>

Applied.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c
index 6ccceae21f70..edf454474f11 100644
--- a/drivers/hwmon/chipcap2.c
+++ b/drivers/hwmon/chipcap2.c
@@ -740,37 +740,26 @@  static int cc2_probe(struct i2c_client *client)
 	data->client = client;
 
 	data->regulator = devm_regulator_get_exclusive(dev, "vdd");
-	if (IS_ERR(data->regulator)) {
-		dev_err_probe(dev, PTR_ERR(data->regulator),
-			      "Failed to get regulator\n");
-		return PTR_ERR(data->regulator);
-	}
+	if (IS_ERR(data->regulator))
+		return dev_err_probe(dev, PTR_ERR(data->regulator),
+				     "Failed to get regulator\n");
 
 	ret = cc2_request_ready_irq(data, dev);
-	if (ret) {
-		dev_err_probe(dev, ret, "Failed to request ready irq\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to request ready irq\n");
 
 	ret = cc2_request_alarm_irqs(data, dev);
-	if (ret) {
-		dev_err_probe(dev, ret, "Failed to request alarm irqs\n");
-		goto disable;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to request alarm irqs\n");
 
 	data->hwmon = devm_hwmon_device_register_with_info(dev, client->name,
 							   data, &cc2_chip_info,
 							   NULL);
-	if (IS_ERR(data->hwmon)) {
-		dev_err_probe(dev, PTR_ERR(data->hwmon),
-			      "Failed to register hwmon device\n");
-		ret = PTR_ERR(data->hwmon);
-	}
-
-disable:
-	cc2_disable(data);
+	if (IS_ERR(data->hwmon))
+		return dev_err_probe(dev, PTR_ERR(data->hwmon),
+				     "Failed to register hwmon device\n");
 
-	return ret;
+	return 0;
 }
 
 static void cc2_remove(struct i2c_client *client)