linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] staging: iio/ad7291: fix error code in ad7291_probe()
@ 2014-06-20 19:22 Dan Carpenter
  2014-06-21 10:37 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2014-06-20 19:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Greg Kroah-Hartman, Lars-Peter Clausen, Wei Yongjun, Sachin Kamat,
	linux-iio, devel, kernel-janitors

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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
index 357cef2..7194bd1 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] staging: iio/ad7291: fix error code in ad7291_probe()
  2014-06-20 19:22 [patch] staging: iio/ad7291: fix error code in ad7291_probe() Dan Carpenter
@ 2014-06-21 10:37 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2014-06-21 10:37 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, Lars-Peter Clausen, Wei Yongjun, Sachin Kamat,
	linux-iio, devel, kernel-janitors

On 20/06/14 20:22, Dan Carpenter wrote:
> 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.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied to the fixes-togreg branch of iio.git and cc'd to stable.

Thanks,

Jonathan
>
> diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
> index 357cef2..7194bd1 100644
> --- a/drivers/staging/iio/adc/ad7291.c
> +++ b/drivers/staging/iio/adc/ad7291.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-21 10:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-20 19:22 [patch] staging: iio/ad7291: fix error code in ad7291_probe() Dan Carpenter
2014-06-21 10:37 ` 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).