* [PATCH] iio: hid-sensor-prox: Fix scale not correct issue
@ 2021-01-20 7:49 Ye Xiang
2021-01-23 16:04 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Ye Xiang @ 2021-01-20 7:49 UTC (permalink / raw)
To: jikos, jic23, srinivas.pandruvada
Cc: linux-input, linux-iio, linux-kernel, Ye Xiang
Currently, the proxy sensor scale is zero because it just return the
exponent directly. To fix this issue, this patch use
hid_sensor_format_scale to process the scale first then return the
output.
Signed-off-by: Ye Xiang <xiang.ye@intel.com>
---
drivers/iio/light/hid-sensor-prox.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index 4ab285a418d5..4abcfe48f1d4 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -23,6 +23,9 @@ struct prox_state {
struct hid_sensor_common common_attributes;
struct hid_sensor_hub_attribute_info prox_attr;
u32 human_presence;
+ int scale_pre_decml;
+ int scale_post_decml;
+ int scale_precision;
};
static const u32 prox_sensitivity_addresses[] = {
@@ -98,8 +101,9 @@ static int prox_read_raw(struct iio_dev *indio_dev,
ret_type = IIO_VAL_INT;
break;
case IIO_CHAN_INFO_SCALE:
- *val = prox_state->prox_attr.units;
- ret_type = IIO_VAL_INT;
+ *val = prox_state->scale_pre_decml;
+ *val2 = prox_state->scale_post_decml;
+ ret_type = prox_state->scale_precision;
break;
case IIO_CHAN_INFO_OFFSET:
*val = hid_sensor_convert_exponent(
@@ -221,6 +225,11 @@ static int prox_parse_report(struct platform_device *pdev,
dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
st->prox_attr.report_id);
+ st->scale_precision = hid_sensor_format_scale(
+ hsdev->usage,
+ &st->prox_attr,
+ &st->scale_pre_decml, &st->scale_post_decml);
+
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: hid-sensor-prox: Fix scale not correct issue
2021-01-20 7:49 [PATCH] iio: hid-sensor-prox: Fix scale not correct issue Ye Xiang
@ 2021-01-23 16:04 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-01-23 16:04 UTC (permalink / raw)
To: Ye Xiang; +Cc: jikos, srinivas.pandruvada, linux-input, linux-iio, linux-kernel
On Wed, 20 Jan 2021 15:49:35 +0800
Ye Xiang <xiang.ye@intel.com> wrote:
> Currently, the proxy sensor scale is zero because it just return the
> exponent directly. To fix this issue, this patch use
> hid_sensor_format_scale to process the scale first then return the
> output.
>
> Signed-off-by: Ye Xiang <xiang.ye@intel.com>
Fixes tag please. Otherwise, looks correct to me.
Thanks
Jonathan
> ---
> drivers/iio/light/hid-sensor-prox.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
> index 4ab285a418d5..4abcfe48f1d4 100644
> --- a/drivers/iio/light/hid-sensor-prox.c
> +++ b/drivers/iio/light/hid-sensor-prox.c
> @@ -23,6 +23,9 @@ struct prox_state {
> struct hid_sensor_common common_attributes;
> struct hid_sensor_hub_attribute_info prox_attr;
> u32 human_presence;
> + int scale_pre_decml;
> + int scale_post_decml;
> + int scale_precision;
> };
>
> static const u32 prox_sensitivity_addresses[] = {
> @@ -98,8 +101,9 @@ static int prox_read_raw(struct iio_dev *indio_dev,
> ret_type = IIO_VAL_INT;
> break;
> case IIO_CHAN_INFO_SCALE:
> - *val = prox_state->prox_attr.units;
> - ret_type = IIO_VAL_INT;
> + *val = prox_state->scale_pre_decml;
> + *val2 = prox_state->scale_post_decml;
> + ret_type = prox_state->scale_precision;
> break;
> case IIO_CHAN_INFO_OFFSET:
> *val = hid_sensor_convert_exponent(
> @@ -221,6 +225,11 @@ static int prox_parse_report(struct platform_device *pdev,
> dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr.index,
> st->prox_attr.report_id);
>
> + st->scale_precision = hid_sensor_format_scale(
> + hsdev->usage,
> + &st->prox_attr,
> + &st->scale_pre_decml, &st->scale_post_decml);
> +
> return ret;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-23 16:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 7:49 [PATCH] iio: hid-sensor-prox: Fix scale not correct issue Ye Xiang
2021-01-23 16:04 ` Jonathan Cameron
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.