* [PATCH] iio: imu: st_lsm6dsx: configure full scale on slave device if supported
@ 2020-03-19 21:02 Lorenzo Bianconi
2020-04-04 14:24 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2020-03-19 21:02 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, lorenzo.bianconi, jimmyassarsson
Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure
the i2c slave device sensitivity
Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 33 ++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
index 64ef07a30726..fec1dbd5f00d 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
@@ -518,6 +518,36 @@ st_lsm6dsx_shub_read_raw(struct iio_dev *iio_dev,
return ret;
}
+static int
+st_lsm6dsx_shub_set_full_scale(struct st_lsm6dsx_sensor *sensor,
+ u32 gain)
+{
+ const struct st_lsm6dsx_fs_table_entry *fs_table;
+ int i, err;
+
+ fs_table = &sensor->ext_info.settings->fs_table;
+ if (!fs_table->reg.addr)
+ return -ENOTSUPP;
+
+ for (i = 0; i < fs_table->fs_len; i++) {
+ if (fs_table->fs_avl[i].gain == gain)
+ break;
+ }
+
+ if (i == fs_table->fs_len)
+ return -EINVAL;
+
+ err = st_lsm6dsx_shub_write_with_mask(sensor, fs_table->reg.addr,
+ fs_table->reg.mask,
+ fs_table->fs_avl[i].val);
+ if (err < 0)
+ return err;
+
+ sensor->gain = gain;
+
+ return 0;
+}
+
static int
st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
struct iio_chan_spec const *chan,
@@ -552,6 +582,9 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
}
break;
}
+ case IIO_CHAN_INFO_SCALE:
+ err = st_lsm6dsx_shub_set_full_scale(sensor, val2);
+ break;
default:
err = -EINVAL;
break;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] iio: imu: st_lsm6dsx: configure full scale on slave device if supported
2020-03-19 21:02 [PATCH] iio: imu: st_lsm6dsx: configure full scale on slave device if supported Lorenzo Bianconi
@ 2020-04-04 14:24 ` Jonathan Cameron
2020-04-04 14:31 ` Lorenzo Bianconi
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2020-04-04 14:24 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi, jimmyassarsson
On Thu, 19 Mar 2020 22:02:45 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure
> the i2c slave device sensitivity
>
> Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
I've lost track of what is going on around this driver.
One thing is clear though, this doesn't currently apply to my togreg
tree. I'll assume that's because I'm missing something (maybe a fix,
or maybe another series).
Give me a poke if I seem to have lost this in a few weeks once all the
trees catch up properly after the merge window.
Thanks,
Jonathan
> ---
> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 33 ++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> index 64ef07a30726..fec1dbd5f00d 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> @@ -518,6 +518,36 @@ st_lsm6dsx_shub_read_raw(struct iio_dev *iio_dev,
> return ret;
> }
>
> +static int
> +st_lsm6dsx_shub_set_full_scale(struct st_lsm6dsx_sensor *sensor,
> + u32 gain)
> +{
> + const struct st_lsm6dsx_fs_table_entry *fs_table;
> + int i, err;
> +
> + fs_table = &sensor->ext_info.settings->fs_table;
> + if (!fs_table->reg.addr)
> + return -ENOTSUPP;
> +
> + for (i = 0; i < fs_table->fs_len; i++) {
> + if (fs_table->fs_avl[i].gain == gain)
> + break;
> + }
> +
> + if (i == fs_table->fs_len)
> + return -EINVAL;
> +
> + err = st_lsm6dsx_shub_write_with_mask(sensor, fs_table->reg.addr,
> + fs_table->reg.mask,
> + fs_table->fs_avl[i].val);
> + if (err < 0)
> + return err;
> +
> + sensor->gain = gain;
> +
> + return 0;
> +}
> +
> static int
> st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
> struct iio_chan_spec const *chan,
> @@ -552,6 +582,9 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
> }
> break;
> }
> + case IIO_CHAN_INFO_SCALE:
> + err = st_lsm6dsx_shub_set_full_scale(sensor, val2);
> + break;
> default:
> err = -EINVAL;
> break;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iio: imu: st_lsm6dsx: configure full scale on slave device if supported
2020-04-04 14:24 ` Jonathan Cameron
@ 2020-04-04 14:31 ` Lorenzo Bianconi
2020-04-04 14:51 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2020-04-04 14:31 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, lorenzo.bianconi, jimmyassarsson
[-- Attachment #1: Type: text/plain, Size: 2672 bytes --]
> On Thu, 19 Mar 2020 22:02:45 +0100
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure
> > the i2c slave device sensitivity
> >
> > Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> I've lost track of what is going on around this driver.
> One thing is clear though, this doesn't currently apply to my togreg
> tree. I'll assume that's because I'm missing something (maybe a fix,
> or maybe another series).
>
> Give me a poke if I seem to have lost this in a few weeks once all the
> trees catch up properly after the merge window.
>
> Thanks,
>
> Jonathan
Hi Jonathan,
since this is not a fix but a new feature, does it apply to your testing tree?
Anyway I guess this patch is important when you apply LIS3MDL support to sensor
hub driver.
https://patchwork.kernel.org/patch/11463761/
Regards,
Lorenzo
>
> > ---
> > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 33 ++++++++++++++++++++
> > 1 file changed, 33 insertions(+)
> >
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > index 64ef07a30726..fec1dbd5f00d 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > @@ -518,6 +518,36 @@ st_lsm6dsx_shub_read_raw(struct iio_dev *iio_dev,
> > return ret;
> > }
> >
> > +static int
> > +st_lsm6dsx_shub_set_full_scale(struct st_lsm6dsx_sensor *sensor,
> > + u32 gain)
> > +{
> > + const struct st_lsm6dsx_fs_table_entry *fs_table;
> > + int i, err;
> > +
> > + fs_table = &sensor->ext_info.settings->fs_table;
> > + if (!fs_table->reg.addr)
> > + return -ENOTSUPP;
> > +
> > + for (i = 0; i < fs_table->fs_len; i++) {
> > + if (fs_table->fs_avl[i].gain == gain)
> > + break;
> > + }
> > +
> > + if (i == fs_table->fs_len)
> > + return -EINVAL;
> > +
> > + err = st_lsm6dsx_shub_write_with_mask(sensor, fs_table->reg.addr,
> > + fs_table->reg.mask,
> > + fs_table->fs_avl[i].val);
> > + if (err < 0)
> > + return err;
> > +
> > + sensor->gain = gain;
> > +
> > + return 0;
> > +}
> > +
> > static int
> > st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
> > struct iio_chan_spec const *chan,
> > @@ -552,6 +582,9 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
> > }
> > break;
> > }
> > + case IIO_CHAN_INFO_SCALE:
> > + err = st_lsm6dsx_shub_set_full_scale(sensor, val2);
> > + break;
> > default:
> > err = -EINVAL;
> > break;
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iio: imu: st_lsm6dsx: configure full scale on slave device if supported
2020-04-04 14:31 ` Lorenzo Bianconi
@ 2020-04-04 14:51 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-04-04 14:51 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi, jimmyassarsson
On Sat, 4 Apr 2020 16:31:18 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> > On Thu, 19 Mar 2020 22:02:45 +0100
> > Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> >
> > > Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure
> > > the i2c slave device sensitivity
> > >
> > > Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > I've lost track of what is going on around this driver.
> > One thing is clear though, this doesn't currently apply to my togreg
> > tree. I'll assume that's because I'm missing something (maybe a fix,
> > or maybe another series).
> >
> > Give me a poke if I seem to have lost this in a few weeks once all the
> > trees catch up properly after the merge window.
> >
> > Thanks,
> >
> > Jonathan
>
> Hi Jonathan,
>
> since this is not a fix but a new feature, does it apply to your testing tree?
> Anyway I guess this patch is important when you apply LIS3MDL support to sensor
> hub driver.
> https://patchwork.kernel.org/patch/11463761/
I poked at it a bit more. Seems something introduced a bit of fuzz but
otherwise it's fine. Applied to the togreg branch of iio.git and pushed out
as testing.
Thanks,
Jonathan
>
> Regards,
> Lorenzo
>
> >
> > > ---
> > > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 33 ++++++++++++++++++++
> > > 1 file changed, 33 insertions(+)
> > >
> > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > > index 64ef07a30726..fec1dbd5f00d 100644
> > > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c
> > > @@ -518,6 +518,36 @@ st_lsm6dsx_shub_read_raw(struct iio_dev *iio_dev,
> > > return ret;
> > > }
> > >
> > > +static int
> > > +st_lsm6dsx_shub_set_full_scale(struct st_lsm6dsx_sensor *sensor,
> > > + u32 gain)
> > > +{
> > > + const struct st_lsm6dsx_fs_table_entry *fs_table;
> > > + int i, err;
> > > +
> > > + fs_table = &sensor->ext_info.settings->fs_table;
> > > + if (!fs_table->reg.addr)
> > > + return -ENOTSUPP;
> > > +
> > > + for (i = 0; i < fs_table->fs_len; i++) {
> > > + if (fs_table->fs_avl[i].gain == gain)
> > > + break;
> > > + }
> > > +
> > > + if (i == fs_table->fs_len)
> > > + return -EINVAL;
> > > +
> > > + err = st_lsm6dsx_shub_write_with_mask(sensor, fs_table->reg.addr,
> > > + fs_table->reg.mask,
> > > + fs_table->fs_avl[i].val);
> > > + if (err < 0)
> > > + return err;
> > > +
> > > + sensor->gain = gain;
> > > +
> > > + return 0;
> > > +}
> > > +
> > > static int
> > > st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
> > > struct iio_chan_spec const *chan,
> > > @@ -552,6 +582,9 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev,
> > > }
> > > break;
> > > }
> > > + case IIO_CHAN_INFO_SCALE:
> > > + err = st_lsm6dsx_shub_set_full_scale(sensor, val2);
> > > + break;
> > > default:
> > > err = -EINVAL;
> > > break;
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-04 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-19 21:02 [PATCH] iio: imu: st_lsm6dsx: configure full scale on slave device if supported Lorenzo Bianconi
2020-04-04 14:24 ` Jonathan Cameron
2020-04-04 14:31 ` Lorenzo Bianconi
2020-04-04 14:51 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox