From: Daniel Baluta <daniel.baluta@intel.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Daniel Baluta <daniel.baluta@intel.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH v3] iio: imu: Add initial support for Bosch BMI160
Date: Fri, 15 Apr 2016 17:49:51 +0300 [thread overview]
Message-ID: <CAEnQRZAXufsHKLKNzv5DkuZJni=rMWXjKer6vw9Gey5tvrGFSw@mail.gmail.com> (raw)
In-Reply-To: <570A64B1.7080303@kernel.org>
On Sun, Apr 10, 2016 at 5:35 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> On 06/04/16 15:58, Daniel Baluta wrote:
>> BMI160 is an Inertial Measurement Unit (IMU) which provides acceleration
>> and angular rate measurement. It also offers a secondary I2C interface
>> for connecting a magnetometer sensor (usually BMM160).
>>
>> Current driver offers support for accelerometer and gyroscope readings
>> via sysfs or via buffer interface using an external trigger (e.g.
>> hrtimer). Data is retrieved from IMU via I2C or SPI interface.
>>
>> Datasheet is at:
>> http://www.mouser.com/ds/2/783/BST-BMI160-DS000-07-786474.pdf
>>
>> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> I'm still a little unconvinced abou the data handling in the trigger_handler.
> Sample should be __le16 I think which would make it all rather more
> obvious.
<snip>
>> +static irqreturn_t bmi160_trigger_handler(int irq, void *p)
>> +{
>> + struct iio_poll_func *pf = p;
>> + struct iio_dev *indio_dev = pf->indio_dev;
>> + struct bmi160_data *data = iio_priv(indio_dev);
>> + s16 buf[16]; /* 3 sens x 3 axis x s16 + 3 x s16 pad + 4 x s16 tstamp */
>> + int i, ret, sample, j = 0, base = BMI160_REG_DATA_MAGN_XOUT_L;
>> +
>> + for_each_set_bit(i, indio_dev->active_scan_mask,
>> + indio_dev->masklength) {
>> + ret = regmap_bulk_read(data->regmap, base + i * sizeof(__le16),
>> + &sample, sizeof(__le16));
> Shouldn't sample be an __le16 ideally? Then you could use sizeof(sample)
> as well which would be more obviously right...
But will keep sizeof(__le16) similar with bmi160_get_data
>
>> + if (ret < 0)
>> + goto done;
>> + buf[j++] = sample;
> Probably makes sense to make buf __le16 buf[16] as well though that one isn't
> as important (and perhaps missleading in some ways)
Agree, will make sample an __le16 and keep s16 buf[16].
Daniel.
prev parent reply other threads:[~2016-04-15 14:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 14:58 [PATCH v3] iio: imu: Add initial support for Bosch BMI160 Daniel Baluta
2016-04-10 14:35 ` Jonathan Cameron
2016-04-15 14:49 ` Daniel Baluta [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='CAEnQRZAXufsHKLKNzv5DkuZJni=rMWXjKer6vw9Gey5tvrGFSw@mail.gmail.com' \
--to=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=lucas.demarchi@intel.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 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).