Skip to content

Commit a76e3c4

Browse files
committed
backports: iio: from: linux.git
Reference: v5.4.123 Signed-off-by: Robert Nelson <[email protected]>
1 parent eb92b55 commit a76e3c4

File tree

11 files changed

+53
-20
lines changed

11 files changed

+53
-20
lines changed

drivers/iio/accel/adis16201.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static const struct iio_chan_spec adis16201_channels[] = {
215215
ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC_REG, ADIS16201_SCAN_AUX_ADC, 0, 12),
216216
ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT_REG, ADIS16201_SCAN_INCLI_X,
217217
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
218-
ADIS_INCLI_CHAN(X, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y,
218+
ADIS_INCLI_CHAN(Y, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y,
219219
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
220220
IIO_CHAN_SOFT_TIMESTAMP(7)
221221
};

drivers/iio/adc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ config STM32_ADC_CORE
784784
depends on ARCH_STM32 || COMPILE_TEST
785785
depends on OF
786786
depends on REGULATOR
787+
depends on HAS_IOMEM
787788
select IIO_BUFFER
788789
select MFD_STM32_TIMERS
789790
select IIO_STM32_TIMER_TRIGGER

drivers/iio/adc/ad7949.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
9191
int ret;
9292
int i;
9393
int bits_per_word = ad7949_adc->resolution;
94-
int mask = GENMASK(ad7949_adc->resolution, 0);
94+
int mask = GENMASK(ad7949_adc->resolution - 1, 0);
9595
struct spi_message msg;
9696
struct spi_transfer tx[] = {
9797
{

drivers/iio/adc/qcom-spmi-vadc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_chans[] = {
598598
VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1)
599599

600600
VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0)
601-
VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0)
601+
VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT)
602602
VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0)
603603
VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0)
604604
VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0)

drivers/iio/gyro/mpu3050-core.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,16 @@ static int mpu3050_read_raw(struct iio_dev *indio_dev,
271271
case IIO_CHAN_INFO_OFFSET:
272272
switch (chan->type) {
273273
case IIO_TEMP:
274-
/* The temperature scaling is (x+23000)/280 Celsius */
274+
/*
275+
* The temperature scaling is (x+23000)/280 Celsius
276+
* for the "best fit straight line" temperature range
277+
* of -30C..85C. The 23000 includes room temperature
278+
* offset of +35C, 280 is the precision scale and x is
279+
* the 16-bit signed integer reported by hardware.
280+
*
281+
* Temperature value itself represents temperature of
282+
* the sensor die.
283+
*/
275284
*val = 23000;
276285
return IIO_VAL_INT;
277286
default:
@@ -328,7 +337,7 @@ static int mpu3050_read_raw(struct iio_dev *indio_dev,
328337
goto out_read_raw_unlock;
329338
}
330339

331-
*val = be16_to_cpu(raw_val);
340+
*val = (s16)be16_to_cpu(raw_val);
332341
ret = IIO_VAL_INT;
333342

334343
goto out_read_raw_unlock;
@@ -550,6 +559,8 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
550559
MPU3050_FIFO_R,
551560
&fifo_values[offset],
552561
toread);
562+
if (ret)
563+
goto out_trigger_unlock;
553564

554565
dev_dbg(mpu3050->dev,
555566
"%04x %04x %04x %04x %04x\n",

drivers/iio/humidity/hid-sensor-humidity.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
struct hid_humidity_state {
1818
struct hid_sensor_common common_attributes;
1919
struct hid_sensor_hub_attribute_info humidity_attr;
20-
s32 humidity_data;
20+
struct {
21+
s32 humidity_data;
22+
u64 timestamp __aligned(8);
23+
} scan;
2124
int scale_pre_decml;
2225
int scale_post_decml;
2326
int scale_precision;
@@ -127,9 +130,8 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev,
127130
struct hid_humidity_state *humid_st = iio_priv(indio_dev);
128131

129132
if (atomic_read(&humid_st->common_attributes.data_ready))
130-
iio_push_to_buffers_with_timestamp(indio_dev,
131-
&humid_st->humidity_data,
132-
iio_get_time_ns(indio_dev));
133+
iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan,
134+
iio_get_time_ns(indio_dev));
133135

134136
return 0;
135137
}
@@ -144,7 +146,7 @@ static int humidity_capture_sample(struct hid_sensor_hub_device *hsdev,
144146

145147
switch (usage_id) {
146148
case HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY:
147-
humid_st->humidity_data = *(s32 *)raw_data;
149+
humid_st->scan.humidity_data = *(s32 *)raw_data;
148150

149151
return 0;
150152
default:

drivers/iio/imu/adis16400.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,7 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
464464
if (ret)
465465
goto err_ret;
466466

467-
ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
468-
if (ret != 1) {
467+
if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) {
469468
ret = -EINVAL;
470469
goto err_ret;
471470
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ struct prox_state {
2525
struct hid_sensor_common common_attributes;
2626
struct hid_sensor_hub_attribute_info prox_attr;
2727
u32 human_presence;
28+
int scale_pre_decml;
29+
int scale_post_decml;
30+
int scale_precision;
2831
};
2932

3033
/* Channel definitions */
@@ -95,8 +98,9 @@ static int prox_read_raw(struct iio_dev *indio_dev,
9598
ret_type = IIO_VAL_INT;
9699
break;
97100
case IIO_CHAN_INFO_SCALE:
98-
*val = prox_state->prox_attr.units;
99-
ret_type = IIO_VAL_INT;
101+
*val = prox_state->scale_pre_decml;
102+
*val2 = prox_state->scale_post_decml;
103+
ret_type = prox_state->scale_precision;
100104
break;
101105
case IIO_CHAN_INFO_OFFSET:
102106
*val = hid_sensor_convert_exponent(
@@ -236,6 +240,11 @@ static int prox_parse_report(struct platform_device *pdev,
236240
HID_USAGE_SENSOR_HUMAN_PRESENCE,
237241
&st->common_attributes.sensitivity);
238242

243+
st->scale_precision = hid_sensor_format_scale(
244+
hsdev->usage,
245+
&st->prox_attr,
246+
&st->scale_pre_decml, &st->scale_post_decml);
247+
239248
return ret;
240249
}
241250

drivers/iio/light/tsl2583.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,14 @@ static int tsl2583_als_calibrate(struct iio_dev *indio_dev)
341341
return lux_val;
342342
}
343343

344+
/* Avoid division by zero of lux_value later on */
345+
if (lux_val == 0) {
346+
dev_err(&chip->client->dev,
347+
"%s: lux_val of 0 will produce out of range trim_value\n",
348+
__func__);
349+
return -ENODATA;
350+
}
351+
344352
gain_trim_val = (unsigned int)(((chip->als_settings.als_cal_target)
345353
* chip->als_settings.als_gain_trim) / lux_val);
346354
if ((gain_trim_val < 250) || (gain_trim_val > 4000)) {

drivers/iio/proximity/pulsedlight-lidar-lite-v2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
158158
ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
159159
if (ret < 0) {
160160
dev_err(&client->dev, "cannot send start measurement command");
161+
pm_runtime_put_noidle(&client->dev);
161162
return ret;
162163
}
163164

0 commit comments

Comments
 (0)