* [PATCH 0/2] iio: inv-mpu: small scale fixes @ 2015-06-12 15:10 Adriana Reus 2015-06-12 15:10 ` [PATCH 1/2] iio: inv-mpu: Export scale_available attributes Adriana Reus 2015-06-12 15:10 ` [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels Adriana Reus 0 siblings, 2 replies; 6+ messages in thread From: Adriana Reus @ 2015-06-12 15:10 UTC (permalink / raw) To: ggao, jic23; +Cc: linux-iio, linux-kernel, Adriana Reus This series exports available scales for inv-mpu6050 and also fixes the format for write channels. Adriana Reus (2): iio: inv-mpu: Export scale_available attributes iio: inv-mpu: Specify the expected format/precision for write channels drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) -- 1.9.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] iio: inv-mpu: Export scale_available attributes 2015-06-12 15:10 [PATCH 0/2] iio: inv-mpu: small scale fixes Adriana Reus @ 2015-06-12 15:10 ` Adriana Reus 2015-06-13 18:01 ` Jonathan Cameron 2015-06-12 15:10 ` [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels Adriana Reus 1 sibling, 1 reply; 6+ messages in thread From: Adriana Reus @ 2015-06-12 15:10 UTC (permalink / raw) To: ggao, jic23; +Cc: linux-iio, linux-kernel, Adriana Reus Export the available scales for accel and gyro in order to hint the user-space as to what are the available valid values. Signed-off-by: Adriana Reus <adriana.reus@intel.com> --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 17d4bb1..096e545 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -673,6 +673,10 @@ static const struct iio_chan_spec inv_mpu_channels[] = { /* constant IIO attribute */ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 20 50 100 200 500"); +static IIO_CONST_ATTR(in_anglvel_scale_available, + "0.000133090 0.000266181 0.000532362 0.001064724"); +static IIO_CONST_ATTR(in_accel_scale_available, + "0.000598 0.001196 0.002392 0.004785"); static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, inv_fifo_rate_show, inv_mpu6050_fifo_rate_store); static IIO_DEVICE_ATTR(in_gyro_matrix, S_IRUGO, inv_attr_show, NULL, @@ -685,6 +689,8 @@ static struct attribute *inv_attributes[] = { &iio_dev_attr_in_accel_matrix.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + &iio_const_attr_in_anglvel_scale_available.dev_attr.attr, NULL, }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] iio: inv-mpu: Export scale_available attributes 2015-06-12 15:10 ` [PATCH 1/2] iio: inv-mpu: Export scale_available attributes Adriana Reus @ 2015-06-13 18:01 ` Jonathan Cameron 0 siblings, 0 replies; 6+ messages in thread From: Jonathan Cameron @ 2015-06-13 18:01 UTC (permalink / raw) To: Adriana Reus, ggao; +Cc: linux-iio, linux-kernel On 12/06/15 16:10, Adriana Reus wrote: > Export the available scales for accel and gyro in order > to hint the user-space as to what are the available valid values. > > Signed-off-by: Adriana Reus <adriana.reus@intel.com> Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > index 17d4bb1..096e545 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > @@ -673,6 +673,10 @@ static const struct iio_chan_spec inv_mpu_channels[] = { > > /* constant IIO attribute */ > static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 20 50 100 200 500"); > +static IIO_CONST_ATTR(in_anglvel_scale_available, > + "0.000133090 0.000266181 0.000532362 0.001064724"); > +static IIO_CONST_ATTR(in_accel_scale_available, > + "0.000598 0.001196 0.002392 0.004785"); > static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, inv_fifo_rate_show, > inv_mpu6050_fifo_rate_store); > static IIO_DEVICE_ATTR(in_gyro_matrix, S_IRUGO, inv_attr_show, NULL, > @@ -685,6 +689,8 @@ static struct attribute *inv_attributes[] = { > &iio_dev_attr_in_accel_matrix.dev_attr.attr, > &iio_dev_attr_sampling_frequency.dev_attr.attr, > &iio_const_attr_sampling_frequency_available.dev_attr.attr, > + &iio_const_attr_in_accel_scale_available.dev_attr.attr, > + &iio_const_attr_in_anglvel_scale_available.dev_attr.attr, > NULL, > }; > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels 2015-06-12 15:10 [PATCH 0/2] iio: inv-mpu: small scale fixes Adriana Reus 2015-06-12 15:10 ` [PATCH 1/2] iio: inv-mpu: Export scale_available attributes Adriana Reus @ 2015-06-12 15:10 ` Adriana Reus 2015-06-11 17:31 ` Ge Gao 1 sibling, 1 reply; 6+ messages in thread From: Adriana Reus @ 2015-06-12 15:10 UTC (permalink / raw) To: ggao, jic23; +Cc: linux-iio, linux-kernel, Adriana Reus The gyroscope needs IIO_VAL_INT_PLUS_NANO for the scale channel and unless specified write returns MICRO by default. This needs to be properly specified so that write operations into scale have the expected behaviour. Signed-off-by: Adriana Reus <adriana.reus@intel.com> --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 096e545..4de5374 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -431,6 +431,23 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val) return -EINVAL; } +static int inv_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_ANGL_VEL: + return IIO_VAL_INT_PLUS_NANO; + default: + return IIO_VAL_INT_PLUS_MICRO; + } + default: + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val) { int result, i; @@ -702,6 +719,7 @@ static const struct iio_info mpu_info = { .driver_module = THIS_MODULE, .read_raw = &inv_mpu6050_read_raw, .write_raw = &inv_mpu6050_write_raw, + .write_raw_get_fmt = &inv_write_raw_get_fmt, .attrs = &inv_attribute_group, .validate_trigger = inv_mpu6050_validate_trigger, }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels 2015-06-12 15:10 ` [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels Adriana Reus @ 2015-06-11 17:31 ` Ge Gao 2015-06-13 18:00 ` Jonathan Cameron 0 siblings, 1 reply; 6+ messages in thread From: Ge Gao @ 2015-06-11 17:31 UTC (permalink / raw) To: Adriana Reus, jic23@kernel.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org These code looks good to me. Thanks. Best Regards, Ge GAO -----Original Message----- From: Adriana Reus [mailto:adriana.reus@intel.com] Sent: Friday, June 12, 2015 8:10 AM To: Ge Gao; jic23@kernel.org Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Adriana Reus Subject: [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels The gyroscope needs IIO_VAL_INT_PLUS_NANO for the scale channel and unless specified write returns MICRO by default. This needs to be properly specified so that write operations into scale have the expected behaviour. Signed-off-by: Adriana Reus <adriana.reus@intel.com> --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 096e545..4de5374 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -431,6 +431,23 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val) return -EINVAL; } +static int inv_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, long mask) { + switch (mask) { + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_ANGL_VEL: + return IIO_VAL_INT_PLUS_NANO; + default: + return IIO_VAL_INT_PLUS_MICRO; + } + default: + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val) { int result, i; @@ -702,6 +719,7 @@ static const struct iio_info mpu_info = { .driver_module = THIS_MODULE, .read_raw = &inv_mpu6050_read_raw, .write_raw = &inv_mpu6050_write_raw, + .write_raw_get_fmt = &inv_write_raw_get_fmt, .attrs = &inv_attribute_group, .validate_trigger = inv_mpu6050_validate_trigger, }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels 2015-06-11 17:31 ` Ge Gao @ 2015-06-13 18:00 ` Jonathan Cameron 0 siblings, 0 replies; 6+ messages in thread From: Jonathan Cameron @ 2015-06-13 18:00 UTC (permalink / raw) To: Ge Gao, Adriana Reus Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org On 11/06/15 18:31, Ge Gao wrote: > These code looks good to me. > Thanks. > > Best Regards, > > Ge GAO Ge, formal Ack definitely preferred, but thanks for taking a look. Adriana, please put fixes at the start of such a series. It didn't matter here as the two changes were non overlapping but they take different paths so if there is overlap I need to get the fix out ASAP and then the improvements such as patch 1 can follow slower. Anyhow, applied to the fixes-togreg branch of iio.git (probably to go upstream post the merge window now). Marked for stable. > > > -----Original Message----- > From: Adriana Reus [mailto:adriana.reus@intel.com] > Sent: Friday, June 12, 2015 8:10 AM > To: Ge Gao; jic23@kernel.org > Cc: linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; Adriana Reus > Subject: [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels > > The gyroscope needs IIO_VAL_INT_PLUS_NANO for the scale channel and unless specified write returns MICRO by default. > This needs to be properly specified so that write operations into scale have the expected behaviour. > > Signed-off-by: Adriana Reus <adriana.reus@intel.com> > --- > drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > index 096e545..4de5374 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c > @@ -431,6 +431,23 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val) > return -EINVAL; > } > > +static int inv_write_raw_get_fmt(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, long mask) { > + switch (mask) { > + case IIO_CHAN_INFO_SCALE: > + switch (chan->type) { > + case IIO_ANGL_VEL: > + return IIO_VAL_INT_PLUS_NANO; > + default: > + return IIO_VAL_INT_PLUS_MICRO; > + } > + default: > + return IIO_VAL_INT_PLUS_MICRO; > + } > + > + return -EINVAL; > +} > static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val) { > int result, i; > @@ -702,6 +719,7 @@ static const struct iio_info mpu_info = { > .driver_module = THIS_MODULE, > .read_raw = &inv_mpu6050_read_raw, > .write_raw = &inv_mpu6050_write_raw, > + .write_raw_get_fmt = &inv_write_raw_get_fmt, > .attrs = &inv_attribute_group, > .validate_trigger = inv_mpu6050_validate_trigger, }; > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-06-13 18:01 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-06-12 15:10 [PATCH 0/2] iio: inv-mpu: small scale fixes Adriana Reus 2015-06-12 15:10 ` [PATCH 1/2] iio: inv-mpu: Export scale_available attributes Adriana Reus 2015-06-13 18:01 ` Jonathan Cameron 2015-06-12 15:10 ` [PATCH 2/2] iio: inv-mpu: Specify the expected format/precision for write channels Adriana Reus 2015-06-11 17:31 ` Ge Gao 2015-06-13 18:00 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox