Skip to contentSkip to conversation

io: proximity: vl53l0x-i2c: Fix error code in probe()

PATCH Superseded Dan Carpenter 2 participants 3 messages Aug 19, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io: proximity: vl53l0x-i2c: Fix error code in probe()

Commit 65e8202f0322 ("iio: Remove error prints for devm_add_action_or_reset()") accidentally introduce 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()")
---
 drivers/iio/proximity/vl53l0x-i2c.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/proximity/vl53l0x-i2c.c +5 -6
index 696340ec027a..ad3e46d47fa8 100644
@@ -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";
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dan Carpenter

Commit 65e8202f0322 ("iio: Remove error prints for devm_add_action_or_reset()") accidentally introduce a bug where we

introduced

Quoted 4 lines

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.

Agree, this is a good catch!
But please, fix the Subject to start with "iio:".

With the above comments being addressed

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 12 lines · Andy Shevchenko
Quoted 3 lines · Dan Carpenter

Commit 65e8202f0322 ("iio: Remove error prints for devm_add_action_or_reset()") accidentally introduce a bug where we

introduced

Quoted 4 lines

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.

Quoted 5 lines

Agree, this is a good catch!
But please, fix the Subject to start with "iio:".

With the above comments being addressed

Yeah. :( Thanks. Will do.

regards,
dan carpenter