From: Jonathan Cameron <jic23@kernel.org>
To: Teodora Baluta <teodora.baluta@intel.com>
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
daniel.baluta@intel.com, dan.carpenter@oracle.com,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/2] iio: mmc35240: minor change to improve code readibility
Date: Sun, 2 Aug 2015 17:35:47 +0100 [thread overview]
Message-ID: <55BE46E3.8010006@kernel.org> (raw)
In-Reply-To: <1438352845-11540-2-git-send-email-teodora.baluta@intel.com>
On 31/07/15 15:27, Teodora Baluta wrote:
> This patch changes two variables to arrays to improve code readibility.
>
> Signed-off-by: Teodora Baluta <teodora.baluta@intel.com>
After a brief argument with myself (see inline).
Applied to the togreg branch of iio.git
Thanks,
Jonathan
> ---
> drivers/iio/magnetometer/mmc35240.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
> index 66d8364..a4259bf 100644
> --- a/drivers/iio/magnetometer/mmc35240.c
> +++ b/drivers/iio/magnetometer/mmc35240.c
> @@ -315,31 +315,31 @@ static int mmc35240_read_measurement(struct mmc35240_data *data, __le16 buf[3])
> static int mmc35240_raw_to_mgauss(struct mmc35240_data *data, int index,
> __le16 buf[], int *val)
> {
> - int raw_x, raw_y, raw_z;
> - int sens_x, sens_y, sens_z;
> + int raw[3];
> + int sens[3];
> int nfo;
>
> - raw_x = le16_to_cpu(buf[AXIS_X]);
> - raw_y = le16_to_cpu(buf[AXIS_Y]);
> - raw_z = le16_to_cpu(buf[AXIS_Z]);
A loop perhaps would make it even cleaner? Maybe not given it would obscure the
enum entries... Hmm. Perhaps best as is.
> + raw[AXIS_X] = le16_to_cpu(buf[AXIS_X]);
> + raw[AXIS_Y] = le16_to_cpu(buf[AXIS_Y]);
> + raw[AXIS_Z] = le16_to_cpu(buf[AXIS_Z]);
>
> - sens_x = mmc35240_props_table[data->res].sens[AXIS_X];
> - sens_y = mmc35240_props_table[data->res].sens[AXIS_Y];
> - sens_z = mmc35240_props_table[data->res].sens[AXIS_Z];
> + sens[AXIS_X] = mmc35240_props_table[data->res].sens[AXIS_X];
> + sens[AXIS_Y] = mmc35240_props_table[data->res].sens[AXIS_Y];
> + sens[AXIS_Z] = mmc35240_props_table[data->res].sens[AXIS_Z];
>
> nfo = mmc35240_props_table[data->res].nfo;
>
> switch (index) {
> case AXIS_X:
> - *val = (raw_x - nfo) * 1000 / sens_x;
> + *val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X];
> break;
> case AXIS_Y:
> - *val = (raw_y - nfo) * 1000 / sens_y -
> - (raw_z - nfo) * 1000 / sens_z;
> + *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y] -
> + (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
> break;
> case AXIS_Z:
> - *val = (raw_y - nfo) * 1000 / sens_y +
> - (raw_z - nfo) * 1000 / sens_z;
> + *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y] +
> + (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
> break;
> default:
> return -EINVAL;
>
next prev parent reply other threads:[~2015-08-02 16:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 14:27 [PATCH v3 0/2] iio: magnetometer: minor style change and add support for new chip Teodora Baluta
2015-07-31 14:27 ` [PATCH v3 1/2] iio: mmc35240: minor change to improve code readibility Teodora Baluta
2015-08-02 16:35 ` Jonathan Cameron [this message]
2015-07-31 14:27 ` [PATCH v3 2/2] iio: magnetometer: add mmc34160 magnetometer driver Teodora Baluta
2015-08-02 16:40 ` Jonathan Cameron
2015-08-02 16:43 ` Jonathan Cameron
2015-08-15 20:47 ` Jonathan Cameron
2015-08-15 20:54 ` Jonathan Cameron
2015-08-17 13:42 ` Teodora Baluta
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=55BE46E3.8010006@kernel.org \
--to=jic23@kernel.org \
--cc=dan.carpenter@oracle.com \
--cc=daniel.baluta@intel.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=teodora.baluta@intel.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.