From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Lorenzo Bianconi
<lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lorenzo.bianconi-qxv4g6HH51o@public.gmane.org
Subject: Re: [PATCH 1/5] iio: imu: st_lsm6dsx: add support to multiple devices with the same settings
Date: Sat, 4 Feb 2017 12:23:24 +0000 [thread overview]
Message-ID: <2a6ad76c-399d-bb2e-1ad5-54a1fb91aa00@kernel.org> (raw)
In-Reply-To: <20170129104928.15533-2-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
On 29/01/17 10:49, Lorenzo Bianconi wrote:
> Add capability to support multiple devices with the same
> st_lsm6dsx_settings like LSM6DSM/LSM6DSL
>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders
to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 ++-
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 30 +++++++++++++++-------------
> 2 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 69deafe..2c1bb9e 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -20,6 +20,7 @@
> enum st_lsm6dsx_hw_id {
> ST_LSM6DS3_ID,
> ST_LSM6DSM_ID,
> + ST_LSM6DSX_MAX_ID,
> };
>
> #define ST_LSM6DSX_CHAN_SIZE 2
> @@ -50,7 +51,7 @@ struct st_lsm6dsx_reg {
> struct st_lsm6dsx_settings {
> u8 wai;
> u16 max_fifo_size;
> - enum st_lsm6dsx_hw_id id;
> + enum st_lsm6dsx_hw_id id[ST_LSM6DSX_MAX_ID];
> };
>
> enum st_lsm6dsx_sensor_id {
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index c92ddcc..499e60a 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -74,12 +74,6 @@
> #define ST_LSM6DSX_REG_GYRO_OUT_Y_L_ADDR 0x24
> #define ST_LSM6DSX_REG_GYRO_OUT_Z_L_ADDR 0x26
>
> -#define ST_LSM6DS3_WHOAMI 0x69
> -#define ST_LSM6DSM_WHOAMI 0x6a
> -
> -#define ST_LSM6DS3_MAX_FIFO_SIZE 8192
> -#define ST_LSM6DSM_MAX_FIFO_SIZE 4096
> -
> #define ST_LSM6DSX_ACC_FS_2G_GAIN IIO_G_TO_M_S_2(61)
> #define ST_LSM6DSX_ACC_FS_4G_GAIN IIO_G_TO_M_S_2(122)
> #define ST_LSM6DSX_ACC_FS_8G_GAIN IIO_G_TO_M_S_2(244)
> @@ -164,14 +158,18 @@ static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = {
>
> static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = {
> {
> - .wai = ST_LSM6DS3_WHOAMI,
> - .max_fifo_size = ST_LSM6DS3_MAX_FIFO_SIZE,
> - .id = ST_LSM6DS3_ID,
> + .wai = 0x69,
> + .max_fifo_size = 8192,
> + .id = {
> + [0] = ST_LSM6DS3_ID,
> + },
> },
> {
> - .wai = ST_LSM6DSM_WHOAMI,
> - .max_fifo_size = ST_LSM6DSM_MAX_FIFO_SIZE,
> - .id = ST_LSM6DSM_ID,
> + .wai = 0x6a,
> + .max_fifo_size = 4096,
> + .id = {
> + [0] = ST_LSM6DSM_ID,
> + },
> },
> };
>
> @@ -241,11 +239,15 @@ int st_lsm6dsx_write_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, u8 mask,
>
> static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id)
> {
> - int err, i;
> + int err, i, j;
> u8 data;
>
> for (i = 0; i < ARRAY_SIZE(st_lsm6dsx_sensor_settings); i++) {
> - if (id == st_lsm6dsx_sensor_settings[i].id)
> + for (j = 0; j < ST_LSM6DSX_MAX_ID; j++) {
> + if (id == st_lsm6dsx_sensor_settings[i].id[j])
> + break;
> + }
> + if (j < ST_LSM6DSX_MAX_ID)
> break;
> }
>
>
next prev parent reply other threads:[~2017-02-04 12:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-29 10:49 [PATCH 0/5] add support to LSM6DS3H and LSM6DSL Lorenzo Bianconi
[not found] ` <20170129104928.15533-1-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-01-29 10:49 ` [PATCH 1/5] iio: imu: st_lsm6dsx: add support to multiple devices with the same settings Lorenzo Bianconi
[not found] ` <20170129104928.15533-2-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-02-04 12:23 ` Jonathan Cameron [this message]
2017-01-29 10:49 ` [PATCH 2/5] iio: imu: st_lsm6dsx: add support to lsm6dsl Lorenzo Bianconi
[not found] ` <20170129104928.15533-3-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-02-04 12:24 ` Jonathan Cameron
2017-01-29 10:49 ` [PATCH 3/5] Documentation: dt: iio: imu: st_lsm6dsx: add lsm6dsl sensor device binding Lorenzo Bianconi
[not found] ` <20170129104928.15533-4-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-02-01 16:04 ` Rob Herring
2017-02-04 12:24 ` Jonathan Cameron
2017-01-29 10:49 ` [PATCH 4/5] iio: imu: st_lsm6dsx: add support to lsm6ds3h Lorenzo Bianconi
[not found] ` <20170129104928.15533-5-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-02-04 12:25 ` Jonathan Cameron
2017-01-29 10:49 ` [PATCH 5/5] Documentation: dt: iio: imu: st_lsm6dsx: add lsm6ds3h sensor device binding Lorenzo Bianconi
[not found] ` <20170129104928.15533-6-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-02-01 16:06 ` Rob Herring
2017-02-04 12:27 ` 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=2a6ad76c-399d-bb2e-1ad5-54a1fb91aa00@kernel.org \
--to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lorenzo.bianconi-qxv4g6HH51o@public.gmane.org \
--cc=lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/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).