From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Teodora Baluta <teodora.baluta@intel.com>
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
daniel.baluta@intel.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: magnetometer: add mmc34160 magnetometer driver
Date: Sun, 2 Aug 2015 17:32:30 +0100 [thread overview]
Message-ID: <55BE461E.9000200@kernel.org> (raw)
In-Reply-To: <20150720141424.GJ5422@mwanda>
On 20/07/15 15:14, Dan Carpenter wrote:
> On Mon, Jul 20, 2015 at 04:52:30PM +0300, Teodora Baluta wrote:
>> +static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
>> + int index, int *val)
>> +{
>> + switch (index) {
>> + case AXIS_X:
>> + *val = (raw[AXIS_X] - nfo) * 1000 / sens[AXIS_X];
>> + break;
>> + case AXIS_Y:
>> + *val = (raw[AXIS_Y] - nfo) * 1000 / sens[AXIS_Y];
>> + break;
>> + case AXIS_Z:
>> + *val = (raw[AXIS_Z] - nfo) * 1000 / sens[AXIS_Z];
>> + break;
>> + default:
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>
> We never pass invalid indexes here so this could be replaced with:
>
> static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo,
> int index, int *val)
> {
> *val = (raw[index] - nfo) * 1000 / sens[index];
> return 0;
Even better change the function signature and don't return anything at
all perhaps?
Anyhow, definitely worth making this change.
> }
>
> regards,
> dan carpenter
>
next prev parent reply other threads:[~2015-08-02 16:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-20 13:52 [PATCH v2 0/2] iio: magnetometer: minor style change and add support for new chip Teodora Baluta
2015-07-20 13:52 ` [PATCH v2 1/2] iio: mmc35240: minor change to improve code readability Teodora Baluta
2015-07-20 13:52 ` [PATCH v2 2/2] iio: magnetometer: add mmc34160 magnetometer driver Teodora Baluta
2015-07-20 14:14 ` Dan Carpenter
2015-08-02 16:32 ` Jonathan Cameron [this message]
2015-08-02 16:37 ` Dan Carpenter
2015-08-02 18:35 ` 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=55BE461E.9000200@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 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).