linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Hans de Goede <hdegoede@redhat.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH v2] iio: accel: Add driver for the MiraMEMS DA311 3-axis 12-bit digital accelerometer
Date: Sun, 25 Sep 2016 17:11:02 +0200	[thread overview]
Message-ID: <cb187395-d50d-ff10-c58e-7e68f5fab4f8@metafoo.de> (raw)
In-Reply-To: <20160922134229.773-1-hdegoede@redhat.com>

On 09/22/2016 03:42 PM, Hans de Goede wrote:
[...]
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW:
> +		ret = i2c_smbus_read_word_data(data->client, chan->address);
> +		if (ret < 0)
> +			return ret;
> +		/*
> +		 * Values are 12 bits, stored as 16 bits with the 4
> +		 * least significant bits always 0.
> +		 */
> +		*val = ((short)le16_to_cpu(ret)) >> 4;

I think the le16_to_cpu() is a leftover from the switch away from
i2c_smbus_read_i2c_block_data(). i2c_smbus_read_word_data() already returns
CPU endianess data. On a BE system le16_to_cpu() swaps the lower and upper
bytes on a BE system. So you'd get the wrong value in that case.

> +		return IIO_VAL_INT;


  parent reply	other threads:[~2016-09-25 15:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-22 13:42 [PATCH v2] iio: accel: Add driver for the MiraMEMS DA311 3-axis 12-bit digital accelerometer Hans de Goede
2016-09-22 17:10 ` Jonathan Cameron
2016-09-23 13:51   ` Hans de Goede
2016-09-24 16:46     ` Jonathan Cameron
2016-09-25 15:11 ` Lars-Peter Clausen [this message]
2016-09-25 16:44   ` 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=cb187395-d50d-ff10-c58e-7e68f5fab4f8@metafoo.de \
    --to=lars@metafoo.de \
    --cc=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=linux-iio@vger.kernel.org \
    --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).