From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Teodora Baluta <teodora.baluta@intel.com>,
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 19:37:27 +0300 [thread overview]
Message-ID: <20150802163727.GR5096@mwanda> (raw)
In-Reply-To: <55BE461E.9000200@kernel.org>
On Sun, Aug 02, 2015 at 05:32:30PM +0100, Jonathan Cameron wrote:
> 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?
>
Yeah. Or this:
static int mmc34160_raw_to_mgauss(int raw[3], int sens[3], int nfo, int index)
{
return (raw[index] - nfo) * 1000 / sens[index];
}
regards,
dan carpenter
next prev parent reply other threads:[~2015-08-02 16:37 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
2015-08-02 16:37 ` Dan Carpenter [this message]
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=20150802163727.GR5096@mwanda \
--to=dan.carpenter@oracle.com \
--cc=daniel.baluta@intel.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=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.