Skip to content

Commit d68c592

Browse files
yeapajic23
authored andcommitted
iio: hid-sensor-prox: Fix scale not correct issue
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. Fixes: 39a3a01 ("iio: hid-sensors: Added Proximity Sensor Driver") Signed-off-by: Ye Xiang <xiang.ye@intel.com> Link: https://lore.kernel.org/r/20210130102530.31064-1-xiang.ye@intel.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 7d200b2 commit d68c592

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

drivers/iio/light/hid-sensor-prox.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ struct prox_state {
2323
struct hid_sensor_common common_attributes;
2424
struct hid_sensor_hub_attribute_info prox_attr;
2525
u32 human_presence;
26+
int scale_pre_decml;
27+
int scale_post_decml;
28+
int scale_precision;
2629
};
2730

2831
/* Channel definitions */
@@ -93,8 +96,9 @@ static int prox_read_raw(struct iio_dev *indio_dev,
9396
ret_type = IIO_VAL_INT;
9497
break;
9598
case IIO_CHAN_INFO_SCALE:
96-
*val = prox_state->prox_attr.units;
97-
ret_type = IIO_VAL_INT;
99+
*val = prox_state->scale_pre_decml;
100+
*val2 = prox_state->scale_post_decml;
101+
ret_type = prox_state->scale_precision;
98102
break;
99103
case IIO_CHAN_INFO_OFFSET:
100104
*val = hid_sensor_convert_exponent(
@@ -234,6 +238,11 @@ static int prox_parse_report(struct platform_device *pdev,
234238
HID_USAGE_SENSOR_HUMAN_PRESENCE,
235239
&st->common_attributes.sensitivity);
236240

241+
st->scale_precision = hid_sensor_format_scale(
242+
hsdev->usage,
243+
&st->prox_attr,
244+
&st->scale_pre_decml, &st->scale_post_decml);
245+
237246
return ret;
238247
}
239248

0 commit comments

Comments
 (0)