From: Jonathan Cameron <jic23@kernel.org>
To: Luis Henriques <luis.henriques@canonical.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: inv-mpu: make inv_write_raw_get_fmt() more readable
Date: Sun, 2 Aug 2015 18:51:38 +0100 [thread overview]
Message-ID: <55BE58AA.4090701@kernel.org> (raw)
In-Reply-To: <1438033697-22772-1-git-send-email-luis.henriques@canonical.com>
On 27/07/15 22:48, Luis Henriques wrote:
> Replace nested switch statements by a single if statement, making function
> inv_write_raw_get_fmt() more readable.
>
> Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Hi Luis,
I can see where you are coming from here, but my gut feeling
is to leave it be as the chances are more stuff will get added
to this function in the future. The mpu6050 are complex parts
for which we currently only support a very limited subset of
functionality. An example of this is we have no filter
control at the moment. The double case statement is ugly
but it easy to verify.
So I'm not going to take this one.
Sorry,
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 65ce86837177..afbc2d2b8608 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -434,19 +434,9 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val)
> static int inv_write_raw_get_fmt(struct iio_dev *indio_dev,
> struct iio_chan_spec const *chan, long mask)
> {
> - switch (mask) {
> - case IIO_CHAN_INFO_SCALE:
> - switch (chan->type) {
> - case IIO_ANGL_VEL:
> - return IIO_VAL_INT_PLUS_NANO;
> - default:
> - return IIO_VAL_INT_PLUS_MICRO;
> - }
> - default:
> - return IIO_VAL_INT_PLUS_MICRO;
> - }
> -
> - return -EINVAL;
> + if ((mask == IIO_CHAN_INFO_SCALE) && (chan->type == IIO_ANGL_VEL))
> + return IIO_VAL_INT_PLUS_NANO;
> + return IIO_VAL_INT_PLUS_MICRO;
> }
> static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val)
> {
> --
> 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
>
prev parent reply other threads:[~2015-08-02 17:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 21:48 [PATCH] iio: inv-mpu: make inv_write_raw_get_fmt() more readable Luis Henriques
2015-08-02 17:51 ` Jonathan Cameron [this message]
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=55BE58AA.4090701@kernel.org \
--to=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=luis.henriques@canonical.com \
--cc=pmeerw@pmeerw.net \
/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.