Skip to content

Commit 389c424

Browse files
committed
Merge tag 'iio-fixes-for-6.12c' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
Jonathan writes: IIO: 3rd set of fixes for the 6.12 cycle Usual mixed bag of new issues from this cycle and ancient bugs recently noticed. core - Fix wrong fwnode handle if __fwnode_iio_channel_get_by_name() looks at parents of the provider node. core,backend - Fix a wrong pointer error check. gts library - Fix plausible corner case where the value returned was not set. - Avoid near infinite loop if the size of the table is 0. (neither are an issue for current drivers). adi,ad4000 - Fix reading of unsigned channels that were returning garbage. adi,ad7780 - Prevent a division by zero. adi,ad7923 - Fix buffer overflows in arrays that were not resized when devices with more channels were added to the driver. adi,adxl380 - Check only for negative error codes rather than including the positive channel read values in an error check. invense,common - Fix an issue where changing the sampling rate to another value and back again whilst the FIFO was off would not update things correctly. kionix,kx022a - Fix failure to sign extend value read from device. * tag 'iio-fixes-for-6.12c' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: Fix fwnode_handle in __fwnode_iio_channel_get_by_name() iio: accel: adxl380: fix raw sample read iio: accel: kx022a: Fix raw read format iio: gts: fix infinite loop for gain_to_scaletables() iio: gts: Fix uninitialized symbol 'ret' iio: adc: ad4000: fix reading unsigned data ad7780: fix division by zero in ad7780_write_raw() iio: adc: ad7923: Fix buffer overflow for tx_buf and ring_xfer iio: backend: fix wrong pointer passed to IS_ERR() iio: invensense: fix multiple odr switch when FIFO is off
2 parents 65294be + 3993ca4 commit 389c424

File tree

12 files changed

+16
-16
lines changed

12 files changed

+16
-16
lines changed

drivers/iio/accel/adxl380.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ static int adxl380_read_raw(struct iio_dev *indio_dev,
11811181

11821182
ret = adxl380_read_chn(st, chan->address);
11831183
iio_device_release_direct_mode(indio_dev);
1184-
if (ret)
1184+
if (ret < 0)
11851185
return ret;
11861186

11871187
*val = sign_extend32(ret >> chan->scan_type.shift,

drivers/iio/accel/kionix-kx022a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static int kx022a_get_axis(struct kx022a_data *data,
594594
if (ret)
595595
return ret;
596596

597-
*val = le16_to_cpu(data->buffer[0]);
597+
*val = (s16)le16_to_cpu(data->buffer[0]);
598598

599599
return IIO_VAL_INT;
600600
}

drivers/iio/adc/ad4000.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ static int ad4000_single_conversion(struct iio_dev *indio_dev,
344344

345345
if (chan->scan_type.sign == 's')
346346
*val = sign_extend32(sample, chan->scan_type.realbits - 1);
347+
else
348+
*val = sample;
347349

348350
return IIO_VAL_INT;
349351
}

drivers/iio/adc/ad7780.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int ad7780_write_raw(struct iio_dev *indio_dev,
152152

153153
switch (m) {
154154
case IIO_CHAN_INFO_SCALE:
155-
if (val != 0)
155+
if (val != 0 || val2 == 0)
156156
return -EINVAL;
157157

158158
vref = st->int_vref_mv * 1000000LL;

drivers/iio/adc/ad7923.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
struct ad7923_state {
5050
struct spi_device *spi;
51-
struct spi_transfer ring_xfer[5];
51+
struct spi_transfer ring_xfer[9];
5252
struct spi_transfer scan_single_xfer[2];
5353
struct spi_message ring_msg;
5454
struct spi_message scan_single_msg;
@@ -64,7 +64,7 @@ struct ad7923_state {
6464
* Length = 8 channels + 4 extra for 8 byte timestamp
6565
*/
6666
__be16 rx_buf[12] __aligned(IIO_DMA_MINALIGN);
67-
__be16 tx_buf[4];
67+
__be16 tx_buf[8];
6868
};
6969

7070
struct ad7923_chip_info {

drivers/iio/common/inv_sensors/inv_sensors_timestamp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
7070
if (mult != ts->mult)
7171
ts->new_mult = mult;
7272

73+
/* When FIFO is off, directly apply the new ODR */
74+
if (!fifo)
75+
inv_sensors_timestamp_apply_odr(ts, 0, 0, 0);
76+
7377
return 0;
7478
}
7579
EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_update_odr, IIO_INV_SENSORS_TIMESTAMP);

drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
200200
{
201201
struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev);
202202
struct inv_icm42600_sensor_state *accel_st = iio_priv(indio_dev);
203-
struct inv_sensors_timestamp *ts = &accel_st->ts;
204203
struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT;
205204
unsigned int fifo_en = 0;
206205
unsigned int sleep_temp = 0;
@@ -229,7 +228,6 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
229228
}
230229

231230
/* update data FIFO write */
232-
inv_sensors_timestamp_apply_odr(ts, 0, 0, 0);
233231
ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
234232

235233
out_unlock:

drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
9999
const unsigned long *scan_mask)
100100
{
101101
struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev);
102-
struct inv_icm42600_sensor_state *gyro_st = iio_priv(indio_dev);
103-
struct inv_sensors_timestamp *ts = &gyro_st->ts;
104102
struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT;
105103
unsigned int fifo_en = 0;
106104
unsigned int sleep_gyro = 0;
@@ -128,7 +126,6 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
128126
}
129127

130128
/* update data FIFO write */
131-
inv_sensors_timestamp_apply_odr(ts, 0, 0, 0);
132129
ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
133130

134131
out_unlock:

drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ int inv_mpu6050_prepare_fifo(struct inv_mpu6050_state *st, bool enable)
112112
if (enable) {
113113
/* reset timestamping */
114114
inv_sensors_timestamp_reset(&st->timestamp);
115-
inv_sensors_timestamp_apply_odr(&st->timestamp, 0, 0, 0);
116115
/* reset FIFO */
117116
d = st->chip_config.user_ctrl | INV_MPU6050_BIT_FIFO_RST;
118117
ret = regmap_write(st->map, st->reg->user_ctrl, d);

drivers/iio/industrialio-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,8 @@ static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, con
737737
}
738738

739739
fwnode_back = fwnode_find_reference(fwnode, "io-backends", index);
740-
if (IS_ERR(fwnode))
741-
return dev_err_cast_probe(dev, fwnode,
740+
if (IS_ERR(fwnode_back))
741+
return dev_err_cast_probe(dev, fwnode_back,
742742
"Cannot get Firmware reference\n");
743743

744744
guard(mutex)(&iio_back_lock);

0 commit comments

Comments
 (0)