* [PATCH v2 next] iio: proximity: vl53l0x-i2c: Fix error code in probe()
@ 2025-08-19 15:02 Dan Carpenter
2025-08-19 17:49 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-08-19 15:02 UTC (permalink / raw)
To: Waqar Hameed
Cc: Song Qiang, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, kernel-janitors
Commit 65e8202f0322 ("iio: Remove error prints for
devm_add_action_or_reset()") accidentally introduced a bug where we
returned "ret" but the error code was stored in "error" if
devm_add_action_or_reset() failed. Using two variables to store error
codes is unnecessary and confusing. Delete the "error" variable and use
"ret" everywhere instead.
Fixes: 65e8202f0322 ("iio: Remove error prints for devm_add_action_or_reset()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
---
v2: Fix typos. Add Andy's r-b tag.
drivers/iio/proximity/vl53l0x-i2c.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
index 696340ec027a..ad3e46d47fa8 100644
--- a/drivers/iio/proximity/vl53l0x-i2c.c
+++ b/drivers/iio/proximity/vl53l0x-i2c.c
@@ -311,7 +311,6 @@ static int vl53l0x_probe(struct i2c_client *client)
{
struct vl53l0x_data *data;
struct iio_dev *indio_dev;
- int error;
int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
@@ -344,13 +343,13 @@ static int vl53l0x_probe(struct i2c_client *client)
return dev_err_probe(&client->dev, PTR_ERR(data->reset_gpio),
"Cannot get reset GPIO\n");
- error = vl53l0x_power_on(data);
- if (error)
- return dev_err_probe(&client->dev, error,
+ ret = vl53l0x_power_on(data);
+ if (ret)
+ return dev_err_probe(&client->dev, ret,
"Failed to power on the chip\n");
- error = devm_add_action_or_reset(&client->dev, vl53l0x_power_off, data);
- if (error)
+ ret = devm_add_action_or_reset(&client->dev, vl53l0x_power_off, data);
+ if (ret)
return ret;
indio_dev->name = "vl53l0x";
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 next] iio: proximity: vl53l0x-i2c: Fix error code in probe()
2025-08-19 15:02 [PATCH v2 next] iio: proximity: vl53l0x-i2c: Fix error code in probe() Dan Carpenter
@ 2025-08-19 17:49 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2025-08-19 17:49 UTC (permalink / raw)
To: Dan Carpenter
Cc: Waqar Hameed, Song Qiang, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, kernel-janitors
On Tue, 19 Aug 2025 18:02:53 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> Commit 65e8202f0322 ("iio: Remove error prints for
> devm_add_action_or_reset()") accidentally introduced a bug where we
> returned "ret" but the error code was stored in "error" if
> devm_add_action_or_reset() failed. Using two variables to store error
> codes is unnecessary and confusing. Delete the "error" variable and use
> "ret" everywhere instead.
>
> Fixes: 65e8202f0322 ("iio: Remove error prints for devm_add_action_or_reset()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
Applied to the togreg branch of iio.git (where that patch is)
and very briefly pushed out as testing to get some build coverage for other
stuff I'm queuing this evening.
Thanks
Jonathan
> ---
> v2: Fix typos. Add Andy's r-b tag.
>
> drivers/iio/proximity/vl53l0x-i2c.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
> index 696340ec027a..ad3e46d47fa8 100644
> --- a/drivers/iio/proximity/vl53l0x-i2c.c
> +++ b/drivers/iio/proximity/vl53l0x-i2c.c
> @@ -311,7 +311,6 @@ static int vl53l0x_probe(struct i2c_client *client)
> {
> struct vl53l0x_data *data;
> struct iio_dev *indio_dev;
> - int error;
> int ret;
>
> indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> @@ -344,13 +343,13 @@ static int vl53l0x_probe(struct i2c_client *client)
> return dev_err_probe(&client->dev, PTR_ERR(data->reset_gpio),
> "Cannot get reset GPIO\n");
>
> - error = vl53l0x_power_on(data);
> - if (error)
> - return dev_err_probe(&client->dev, error,
> + ret = vl53l0x_power_on(data);
> + if (ret)
> + return dev_err_probe(&client->dev, ret,
> "Failed to power on the chip\n");
>
> - error = devm_add_action_or_reset(&client->dev, vl53l0x_power_off, data);
> - if (error)
> + ret = devm_add_action_or_reset(&client->dev, vl53l0x_power_off, data);
> + if (ret)
> return ret;
>
> indio_dev->name = "vl53l0x";
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-19 17:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-19 15:02 [PATCH v2 next] iio: proximity: vl53l0x-i2c: Fix error code in probe() Dan Carpenter
2025-08-19 17:49 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).