Skip to content

Commit a269b9a

Browse files
spandruvadajic23
authored andcommitted
iio: hid-sensors: Pressure: adjust scale and offset
Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent be8e48d commit a269b9a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎drivers/iio/pressure/hid-sensor-press.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ struct press_state {
3636
struct hid_sensor_common common_attributes;
3737
struct hid_sensor_hub_attribute_info press_attr;
3838
u32 press_data;
39+
int scale_pre_decml;
40+
int scale_post_decml;
41+
int scale_precision;
42+
int value_offset;
3943
};
4044

4145
/* Channel definitions */
@@ -102,12 +106,12 @@ static int press_read_raw(struct iio_dev *indio_dev,
102106
ret_type = IIO_VAL_INT;
103107
break;
104108
case IIO_CHAN_INFO_SCALE:
105-
*val = press_state->press_attr.units;
106-
ret_type = IIO_VAL_INT;
109+
*val = press_state->scale_pre_decml;
110+
*val2 = press_state->scale_post_decml;
111+
ret_type = press_state->scale_precision;
107112
break;
108113
case IIO_CHAN_INFO_OFFSET:
109-
*val = hid_sensor_convert_exponent(
110-
press_state->press_attr.unit_expo);
114+
*val = press_state->value_offset;
111115
ret_type = IIO_VAL_INT;
112116
break;
113117
case IIO_CHAN_INFO_SAMP_FREQ:
@@ -229,6 +233,11 @@ static int press_parse_report(struct platform_device *pdev,
229233
dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index,
230234
st->press_attr.report_id);
231235

236+
st->scale_precision = hid_sensor_format_scale(
237+
HID_USAGE_SENSOR_PRESSURE,
238+
&st->press_attr,
239+
&st->scale_pre_decml, &st->scale_post_decml);
240+
232241
/* Set Sensitivity field ids, when there is no individual modifier */
233242
if (st->common_attributes.sensitivity.index < 0) {
234243
sensor_hub_input_get_attribute_info(hsdev,

0 commit comments

Comments
 (0)