patch "iio: st_sensors: fix scale configuration for h3lis331dl" added to staging-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: st_sensors: fix scale configuration for h3lis331dl
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
Quoted 1 line
From
d304286abbbe7ed6228a553a56ba054e900907ebMon Sep 17 00:00:00 2001
From: Lorenzo Bianconi <[email protected]>
Date: Tue, 25 Oct 2016 23:07:38 +0200
Subject: iio: st_sensors: fix scale configuration for h3lis331dl
fix scale configuration/parsing for h3lis331dl accel driver when sensitivity is higher than 1(m/s^2)/digit
--- drivers/iio/accel/st_accel_core.c | 12 ++++++++---- drivers/iio/common/st_sensors/st_sensors_core.c | 8 +++++--- 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/iio/accel/st_accel_core.c +8 -4
@@ -743,8 +743,8 @@ static int st_accel_read_raw(struct iio_dev *indio_dev,return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : - *val =0 ; - *val2 = adata->current_fullscale->gain; + *val = adata->current_fullscale->gain /1000000 ; + *val2 = adata->current_fullscale->gain %1000000 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_SAMP_FREQ : *val = adata->odr;
@@ -763,9 +763,13 @@ static int st_accel_write_raw(struct iio_dev *indio_dev,int err;switch (mask) { -case IIO_CHAN_INFO_SCALE : - err =st_sensors_set_fullscale_by_gain (indio_dev, val2); +case IIO_CHAN_INFO_SCALE : { +int gain; + + gain = val *1000000 + val2; + err =st_sensors_set_fullscale_by_gain (indio_dev, gain);break ; + }case IIO_CHAN_INFO_SAMP_FREQ :if (val2)return -EINVAL ;
drivers/iio/common/st_sensors/st_sensors_core.c +5 -3
@@ -612,7 +612,7 @@ EXPORT_SYMBOL(st_sensors_sysfs_sampling_frequency_avail);ssize_t st_sensors_sysfs_scale_avail (struct device *dev,struct device_attribute *attr,char *buf) { -int i, len =0 ; +int i, len =0 , q, r;struct iio_dev *indio_dev =dev_get_drvdata (dev);struct st_sensor_data *sdata =iio_priv (indio_dev);
@@ -621,8 +621,10 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,if (sdata->sensor_settings->fs.fs_avl[i].num ==0 )break ; - len +=scnprintf (buf + len,PAGE_SIZE - len,"0.%06u " , - sdata->sensor_settings->fs.fs_avl[i].gain); + q = sdata->sensor_settings->fs.fs_avl[i].gain /1000000 ; + r = sdata->sensor_settings->fs.fs_avl[i].gain %1000000 ; + + len +=scnprintf (buf + len,PAGE_SIZE - len,"%u.%06u " , q, r); }mutex_unlock (&indio_dev->mlock); buf[len -1 ] ='\n' ;
Signature · 1 line
2.10.2