From: Jonathan Cameron <jic23@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, Denis CIOCCA <denis.ciocca@st.com>
Cc: Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
Date: Sat, 23 May 2015 12:33:42 +0100 [thread overview]
Message-ID: <55606596.5050804@kernel.org> (raw)
In-Reply-To: <1432042622-26703-1-git-send-email-linus.walleij@linaro.org>
On 19/05/15 14:37, Linus Walleij wrote:
> Some sensors like the LIS331DL only support 8bit data by a single
> register per axis. These utilize the MSB byte. Make it possible
> to register these apropriately.
>
> A oneliner change is needed in the ST sensors core to handle 8bit
> reads as this is the first supported 8bit sensor.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Looks good to me. I'll let these sit for a few days though to
give Denis and others a chance to check them out before I apply them.
Thanks
Jonathan
> ---
> ChangeLog v1->v2:
> - Change the .storage type to 8 bits.
> - Alter the st_sensors_core to cast the byte properly to a signed
> int.
> ---
> drivers/iio/accel/st_accel_core.c | 16 ++++++++++++++++
> drivers/iio/common/st_sensors/st_sensors_core.c | 4 +++-
> 2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 58d1d13d552a..ad19fb4304df 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -153,6 +153,22 @@
> #define ST_ACCEL_4_IG1_EN_MASK 0x08
> #define ST_ACCEL_4_MULTIREAD_BIT true
>
> +static const struct iio_chan_spec st_accel_8bit_channels[] = {
> + ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 8,
> + ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),
> + ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 8, 8,
> + ST_ACCEL_DEFAULT_OUT_Y_L_ADDR+1),
> + ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 8, 8,
> + ST_ACCEL_DEFAULT_OUT_Z_L_ADDR+1),
> + IIO_CHAN_SOFT_TIMESTAMP(3)
> +};
> +
> static const struct iio_chan_spec st_accel_12bit_channels[] = {
> ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 7973c0457042..9007b618d434 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -434,7 +434,9 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
> if (err < 0)
> goto st_sensors_free_memory;
>
> - if (byte_for_channel == 2)
> + if (byte_for_channel == 1)
> + *data = (s8)*outdata;
> + else if (byte_for_channel == 2)
> *data = (s16)get_unaligned_le16(outdata);
> else if (byte_for_channel == 3)
> *data = (s32)st_sensors_get_unaligned_le24(outdata);
>
next prev parent reply other threads:[~2015-05-23 11:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 13:37 [PATCH 1/2 v2] iio: st_accel: support 8bit channel data Linus Walleij
2015-05-23 11:33 ` Jonathan Cameron [this message]
2015-06-04 7:13 ` Linus Walleij
2015-06-04 7:14 ` Denis CIOCCA
2015-06-04 7:24 ` Daniel Baluta
2015-06-04 7:27 ` Denis CIOCCA
2015-06-07 16:59 ` 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=55606596.5050804@kernel.org \
--to=jic23@kernel.org \
--cc=denis.ciocca@st.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--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 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.