From: Hartmut Knaack <knaack.h@gmx.de>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Aida Mynzhasova <ai.c.c0der@gmail.com>,
Masanari Iida <standby24x7@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch v2] [patch] staging: iio: ad799x: remove some unneeded IS_ERR() checks
Date: Wed, 30 Apr 2014 21:52:57 +0000 [thread overview]
Message-ID: <536170B9.8030708@gmx.de> (raw)
In-Reply-To: <20140430210529.GA6008@mwanda>
Dan Carpenter schrieb:
> My static checker is upset that we check IS_ERR(t->reg) when we know it
> is not an ERR_PTR.
>
> Checking for IS_ERR() twice is often a sign of confusion and buggy code.
> In this case, if the call to "ret = regulator_enable(st->vref);" fails,
> then we call "regulator_disable(st->vref);" and that's a mistake because
> "st->vref" is not enabled.
>
> I fixed these problems and Hartmut Knaack pointed out a couple unneeded
> IS_ERR() checks in ad799x_remove() so I have removed those as well.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
> v2: remove the unneeded checks in ad799x_remove() as well. Updated the
> commit message to say that it's actually a small bug fix.
>
> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
> index 16a8b14..39b4cb4 100644
> --- a/drivers/iio/adc/ad799x.c
> +++ b/drivers/iio/adc/ad799x.c
> @@ -717,7 +717,7 @@ static int ad799x_probe(struct i2c_client *client,
> ret = iio_triggered_buffer_setup(indio_dev, NULL,
> &ad799x_trigger_handler, NULL);
> if (ret)
> - goto error_disable_reg;
> + goto error_disable_vref;
>
> if (client->irq > 0) {
> ret = devm_request_threaded_irq(&client->dev,
> @@ -739,11 +739,10 @@ static int ad799x_probe(struct i2c_client *client,
>
> error_cleanup_ring:
> iio_triggered_buffer_cleanup(indio_dev);
> +error_disable_vref:
> + regulator_disable(st->vref);
> error_disable_reg:
> - if (!IS_ERR(st->vref))
> - regulator_disable(st->vref);
> - if (!IS_ERR(st->reg))
> - regulator_disable(st->reg);
> + regulator_disable(st->reg);
>
> return ret;
> }
> @@ -756,10 +755,8 @@ static int ad799x_remove(struct i2c_client *client)
> iio_device_unregister(indio_dev);
>
> iio_triggered_buffer_cleanup(indio_dev);
> - if (!IS_ERR(st->vref))
> - regulator_disable(st->vref);
> - if (!IS_ERR(st->reg))
> - regulator_disable(st->reg);
> + regulator_disable(st->vref);
> + regulator_disable(st->reg);
> kfree(st->rx_buf);
>
> return 0;
> --
> 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
>
WARNING: multiple messages have this Message-ID (diff)
From: Hartmut Knaack <knaack.h@gmx.de>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Aida Mynzhasova <ai.c.c0der@gmail.com>,
Masanari Iida <standby24x7@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch v2] [patch] staging: iio: ad799x: remove some unneeded IS_ERR() checks
Date: Wed, 30 Apr 2014 23:52:57 +0200 [thread overview]
Message-ID: <536170B9.8030708@gmx.de> (raw)
In-Reply-To: <20140430210529.GA6008@mwanda>
Dan Carpenter schrieb:
> My static checker is upset that we check IS_ERR(t->reg) when we know it
> is not an ERR_PTR.
>
> Checking for IS_ERR() twice is often a sign of confusion and buggy code.
> In this case, if the call to "ret = regulator_enable(st->vref);" fails,
> then we call "regulator_disable(st->vref);" and that's a mistake because
> "st->vref" is not enabled.
>
> I fixed these problems and Hartmut Knaack pointed out a couple unneeded
> IS_ERR() checks in ad799x_remove() so I have removed those as well.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
> v2: remove the unneeded checks in ad799x_remove() as well. Updated the
> commit message to say that it's actually a small bug fix.
>
> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
> index 16a8b14..39b4cb4 100644
> --- a/drivers/iio/adc/ad799x.c
> +++ b/drivers/iio/adc/ad799x.c
> @@ -717,7 +717,7 @@ static int ad799x_probe(struct i2c_client *client,
> ret = iio_triggered_buffer_setup(indio_dev, NULL,
> &ad799x_trigger_handler, NULL);
> if (ret)
> - goto error_disable_reg;
> + goto error_disable_vref;
>
> if (client->irq > 0) {
> ret = devm_request_threaded_irq(&client->dev,
> @@ -739,11 +739,10 @@ static int ad799x_probe(struct i2c_client *client,
>
> error_cleanup_ring:
> iio_triggered_buffer_cleanup(indio_dev);
> +error_disable_vref:
> + regulator_disable(st->vref);
> error_disable_reg:
> - if (!IS_ERR(st->vref))
> - regulator_disable(st->vref);
> - if (!IS_ERR(st->reg))
> - regulator_disable(st->reg);
> + regulator_disable(st->reg);
>
> return ret;
> }
> @@ -756,10 +755,8 @@ static int ad799x_remove(struct i2c_client *client)
> iio_device_unregister(indio_dev);
>
> iio_triggered_buffer_cleanup(indio_dev);
> - if (!IS_ERR(st->vref))
> - regulator_disable(st->vref);
> - if (!IS_ERR(st->reg))
> - regulator_disable(st->reg);
> + regulator_disable(st->vref);
> + regulator_disable(st->reg);
> kfree(st->rx_buf);
>
> return 0;
> --
> 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
>
next prev parent reply other threads:[~2014-04-30 21:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 10:08 [patch] staging: iio: ad799x: cleanup probe error handling Dan Carpenter
2014-04-30 10:08 ` Dan Carpenter
2014-04-30 12:00 ` Lars-Peter Clausen
2014-04-30 12:00 ` Lars-Peter Clausen
2014-04-30 20:37 ` Hartmut Knaack
2014-04-30 20:37 ` Hartmut Knaack
2014-04-30 21:05 ` [patch v2] [patch] staging: iio: ad799x: remove some unneeded IS_ERR() checks Dan Carpenter
2014-04-30 21:05 ` Dan Carpenter
2014-04-30 21:52 ` Hartmut Knaack [this message]
2014-04-30 21:52 ` Hartmut Knaack
2014-05-03 10:17 ` Jonathan Cameron
2014-05-03 10:17 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=536170B9.8030708@gmx.de \
--to=knaack.h@gmx.de \
--cc=ai.c.c0der@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=standby24x7@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.