* [PATCH v1] hwmon: (sht15) Simplify with dev_err_probe()
@ 2024-08-30 6:54 Shen Lichuan
2024-08-31 5:53 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Shen Lichuan @ 2024-08-30 6:54 UTC (permalink / raw)
To: jdelvare, linux
Cc: linux-hwmon, linux-kernel, opensource.kernel, Shen Lichuan
Use dev_err_probe() to simplify the error path and unify a message
template.
Using this helper is totally fine even if err is known to never
be -EPROBE_DEFER.
The benefit compared to a normal dev_err() is the standardized format
of the error code, it being emitted symbolically and the fact that
the error code is returned which allows more compact error paths.
Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
drivers/hwmon/sht15.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 494f9655f44f..cc3a46a9c68e 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -942,11 +942,9 @@ static int sht15_probe(struct platform_device *pdev)
data->supply_uv = voltage;
ret = regulator_enable(data->reg);
- if (ret != 0) {
- dev_err(&pdev->dev,
- "failed to enable regulator: %d\n", ret);
- return ret;
- }
+ if (ret != 0)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to enable regulator\n");
/*
* Setup a notifier block to update this if another device
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] hwmon: (sht15) Simplify with dev_err_probe()
2024-08-30 6:54 [PATCH v1] hwmon: (sht15) Simplify with dev_err_probe() Shen Lichuan
@ 2024-08-31 5:53 ` Krzysztof Kozlowski
2024-08-31 19:35 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-31 5:53 UTC (permalink / raw)
To: Shen Lichuan, jdelvare, linux
Cc: linux-hwmon, linux-kernel, opensource.kernel
On 30/08/2024 08:54, Shen Lichuan wrote:
> Use dev_err_probe() to simplify the error path and unify a message
> template.
>
> Using this helper is totally fine even if err is known to never
> be -EPROBE_DEFER.
>
> The benefit compared to a normal dev_err() is the standardized format
> of the error code, it being emitted symbolically and the fact that
> the error code is returned which allows more compact error paths.
>
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> ---
> drivers/hwmon/sht15.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
> index 494f9655f44f..cc3a46a9c68e 100644
> --- a/drivers/hwmon/sht15.c
> +++ b/drivers/hwmon/sht15.c
> @@ -942,11 +942,9 @@ static int sht15_probe(struct platform_device *pdev)
> data->supply_uv = voltage;
>
> ret = regulator_enable(data->reg);
> - if (ret != 0) {
> - dev_err(&pdev->dev,
> - "failed to enable regulator: %d\n", ret);
> - return ret;
> - }
> + if (ret != 0)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to enable regulator\n");
This is ridiculous patch created by some low quality automation without
any review and thoughts from vivo.com side.
You change something which cannot defer, while leaving out unchanged
other places which actually can defer and could benefit.
Stop spamming with such low quality patches.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] hwmon: (sht15) Simplify with dev_err_probe()
2024-08-31 5:53 ` Krzysztof Kozlowski
@ 2024-08-31 19:35 ` Guenter Roeck
0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2024-08-31 19:35 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Shen Lichuan, jdelvare, linux-hwmon, linux-kernel,
opensource.kernel
On Sat, Aug 31, 2024 at 07:53:14AM +0200, Krzysztof Kozlowski wrote:
> On 30/08/2024 08:54, Shen Lichuan wrote:
> > Use dev_err_probe() to simplify the error path and unify a message
> > template.
> >
> > Using this helper is totally fine even if err is known to never
> > be -EPROBE_DEFER.
> >
> > The benefit compared to a normal dev_err() is the standardized format
> > of the error code, it being emitted symbolically and the fact that
> > the error code is returned which allows more compact error paths.
> >
> > Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> > ---
> > drivers/hwmon/sht15.c | 8 +++-----
> > 1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
> > index 494f9655f44f..cc3a46a9c68e 100644
> > --- a/drivers/hwmon/sht15.c
> > +++ b/drivers/hwmon/sht15.c
> > @@ -942,11 +942,9 @@ static int sht15_probe(struct platform_device *pdev)
> > data->supply_uv = voltage;
> >
> > ret = regulator_enable(data->reg);
> > - if (ret != 0) {
> > - dev_err(&pdev->dev,
> > - "failed to enable regulator: %d\n", ret);
> > - return ret;
> > - }
> > + if (ret != 0)
> > + return dev_err_probe(&pdev->dev, ret,
> > + "failed to enable regulator\n");
>
> This is ridiculous patch created by some low quality automation without
> any review and thoughts from vivo.com side.
>
> You change something which cannot defer, while leaving out unchanged
> other places which actually can defer and could benefit.
>
> Stop spamming with such low quality patches.
>
Agreed. Not only would the driver benefit from using
devm_regulator_get_enable_optional(), the driver should be reworked to use
the with_info hardware monitoring API instead of the old deprecated API.
But that would have to be done by someone actually _using_ that chip.
If that isn't done, cosmeting driver changes like this really don't add
any value.
But then the whole driver, or rather its use or non-use of the supply
voltage, does not really make sense. If the regulator and with it the
voltage isn't available, the temperature sensor values don't make sense.
And if the temperature isn't valid, humidity values are also wrong.
That means using the optional regulator API doesn't make sense to start
with. Really, that driver needs a complete overhaul if anyone is still
using it, not just cosmetic changes.
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-31 19:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 6:54 [PATCH v1] hwmon: (sht15) Simplify with dev_err_probe() Shen Lichuan
2024-08-31 5:53 ` Krzysztof Kozlowski
2024-08-31 19:35 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox