From: "Andrew F. Davis" <afd@ti.com>
To: Luis de Bethencourt <luisbg@osg.samsung.com>,
<linux-kernel@vger.kernel.org>
Cc: <gregkh@linuxfoundation.org>, <knaack.h@gmx.de>,
<lars@metafoo.de>, <jic23@kernel.org>, <ciorneiioana@gmail.com>,
<janani.rvchndrn@gmail.com>, <linux-iio@vger.kernel.org>,
<devel@driverdev.osuosl.org>
Subject: Re: [PATCH] staging: iio: accel: remove impossible condition
Date: Tue, 31 May 2016 15:13:51 -0500 [thread overview]
Message-ID: <574DF07F.2040203@ti.com> (raw)
In-Reply-To: <1464724070-20123-1-git-send-email-luisbg@osg.samsung.com>
On 05/31/2016 02:47 PM, Luis de Bethencourt wrote:
> val is set to the value of ret right after ret is checked. If ret is not
> zero it goes to error_ret. So only value ret can have is zero, which makes
> the switch (val & 0x03) only match the case 0x00. Removing the switch and
> since val is only used for this, removing val as well.
>
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
> drivers/staging/iio/accel/sca3000_core.c | 16 ++--------------
> 1 file changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
> index a8f533a..94656f6 100644
> --- a/drivers/staging/iio/accel/sca3000_core.c
> +++ b/drivers/staging/iio/accel/sca3000_core.c
> @@ -586,7 +586,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
> {
> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> struct sca3000_state *st = iio_priv(indio_dev);
> - int ret, len = 0, base_freq = 0, val;
> + int ret, len = 0, base_freq = 0;
>
> mutex_lock(&st->lock);
> ret = __sca3000_get_base_freq(st, st->info, &base_freq);
> @@ -596,20 +596,8 @@ static ssize_t sca3000_read_frequency(struct device *dev,
> mutex_unlock(&st->lock);
> if (ret)
I'm not sure, but I'm guessing this switch serves some purpose and this
was meant to be (ret < 0).
> goto error_ret;
> - val = ret;
> if (base_freq > 0)
> - switch (val & 0x03) {
> - case 0x00:
> - case 0x03:
> - len = sprintf(buf, "%d\n", base_freq);
> - break;
> - case 0x01:
> - len = sprintf(buf, "%d\n", base_freq / 2);
> - break;
> - case 0x02:
> - len = sprintf(buf, "%d\n", base_freq / 4);
> - break;
> - }
> + len = sprintf(buf, "%d\n", base_freq);
>
> return len;
> error_ret_mut:
>
next prev parent reply other threads:[~2016-05-31 20:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 19:47 [PATCH] staging: iio: accel: remove impossible condition Luis de Bethencourt
2016-05-31 20:13 ` Andrew F. Davis [this message]
2016-05-31 20:23 ` Jonathan Cameron
2016-05-31 20:53 ` Luis de Bethencourt
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=574DF07F.2040203@ti.com \
--to=afd@ti.com \
--cc=ciorneiioana@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=janani.rvchndrn@gmail.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luisbg@osg.samsung.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.