* [PATCH v2] hwmon: chipcap2: drop cc2_disable() in the probe and return dev_err_probe()
@ 2024-08-12 22:59 Javier Carrasco
2024-08-13 15:53 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Javier Carrasco @ 2024-08-12 22:59 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Javier Carrasco
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(-)
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)
---
base-commit: 9e6869691724b12e1f43655eeedc35fade38120c
change-id: 20240812-chipcap2-probe-improvements-c94d1431f1ef
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] hwmon: chipcap2: drop cc2_disable() in the probe and return dev_err_probe()
2024-08-12 22:59 [PATCH v2] hwmon: chipcap2: drop cc2_disable() in the probe and return dev_err_probe() Javier Carrasco
@ 2024-08-13 15:53 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2024-08-13 15:53 UTC (permalink / raw)
To: Javier Carrasco; +Cc: Jean Delvare, linux-hwmon, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-13 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 22:59 [PATCH v2] hwmon: chipcap2: drop cc2_disable() in the probe and return dev_err_probe() Javier Carrasco
2024-08-13 15:53 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox