Skip to contentSkip to conversation

staging: iio/ad7291: fix error code in ad7291_probe()

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 20, 2014 – Jun 21, 2014

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: iio/ad7291: fix error code in ad7291_probe()

We should be returning a negative error code instead of success here.

This would have been detected by GCC, except that the "ret" variable was initialized with a bogus value to disable GCC's uninitialized variable warnings. I've cleaned that up, as well.

drivers/staging/iio/adc/ad7291.c +2 -2
index 357cef2..7194bd1 100644
@@ -465,7 +465,7 @@ static int ad7291_probe(struct i2c_client *client,
 	struct ad7291_platform_data *pdata = client->dev.platform_data;
 	struct ad7291_chip_info *chip;
 	struct iio_dev *indio_dev;
-	int ret = 0;
+	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
 	if (!indio_dev)
@@ -475,7 +475,7 @@ static int ad7291_probe(struct i2c_client *client,
 	if (pdata && pdata->use_external_ref) {
 		chip->reg = devm_regulator_get(&client->dev, "vref");
 		if (IS_ERR(chip->reg))
-			return ret;
+			return PTR_ERR(chip->reg);
 
 		ret = regulator_enable(chip->reg);
 		if (ret)
maintainer Applied
#1 lore raw
Quoted 7 lines · Dan Carpenter

We should be returning a negative error code instead of success here.

This would have been detected by GCC, except that the "ret" variable was initialized with a bogus value to disable GCC's uninitialized variable warnings. I've cleaned that up, as well.

Applied to the fixes-togreg branch of iio.git and cc'd to stable.

Thanks,

Jonathan

Quoted 28 lines
drivers/staging/iio/adc/ad7291.c +2 -3
index 357cef2..7194bd1 100644
@@ -465,7 +465,7 @@ static int ad7291_probe(struct i2c_client *client,
  	struct ad7291_platform_data *pdata = client->dev.platform_data;
  	struct ad7291_chip_info *chip;
  	struct iio_dev *indio_dev;
-	int ret = 0;
+	int ret;
 
  	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
  	if (!indio_dev)
@@ -475,7 +475,7 @@ static int ad7291_probe(struct i2c_client *client,
  	if (pdata && pdata->use_external_ref) {
  		chip->reg = devm_regulator_get(&client->dev, "vref");
  		if (IS_ERR(chip->reg))
-			return ret;
+			return PTR_ERR(chip->reg);
 
  		ret = regulator_enable(chip->reg);
  		if (ret)
--

To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html