Skip to content

Commit 994d5df

Browse files
committed
Merge tag 'iio-fixes-for-7.0a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-linus
Jonathan writes: IIO: 1st set of fixes for the 7.0 cycle Usual mixed bag of ancient bugs that have been discovered and more recent stuff. core - Cleanup a wait_queue if a driver is removed at exacty the wrong moment. adi,adf4377 - Check correct masks when waiting for reset to complete. adi,adis - Fix a NULL pointer dereference if ops not provided to adis_init() bosch,bme680 - Fix typo in value used to calculate measurement wait duration. infineon,tlv493d - Drop incorrect shifting of some bits for x-axis invensense,icm42600 - Fix corner case of output data rate being set to the value it already has which resulted in waiting for ever for a flag to say the update was completed. - Fix a case where the buffer is turned off whilst ODR switch is in progress. invensense,icm45600 - Interrupt 1 drive bit was inverted. - Fix a underflow for regulator put warning if probe fails invensense,mpu9150 - Work around a hardware quirk where reading from irq status is not sufficient to acknowledge an interrupt. maxim,ds4424 - Reject -128 as a possible raw value as it's out of range with the sign / magnitude encoding used by this chip. microchip,mcp4131 - Shift the wiper value only once. rohm,bh1780 - Fix a runtime reference count issue on an error path. sensiron,sps30 - Fix two buffer size issues due to sizeof() wrong thing. tyhx,hx9023s - Ensure count used by __counted_by is set before accessing the buffer. - Avoid a potential division by zero. * tag 'iio-fixes-for-7.0a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: imu: adis: Fix NULL pointer dereference in adis_init iio: imu: inv_icm45600: fix regulator put warning when probe fails iio: buffer: Fix wait_queue not being removed iio: gyro: mpu3050-core: fix pm_runtime error handling iio: gyro: mpu3050-i2c: fix pm_runtime error handling iio: adc: ad7768-1: Fix ERR_PTR dereference in ad7768_fill_scale_tbl iio: chemical: sps30_serial: fix buffer size in sps30_serial_read_meas() iio: chemical: sps30_i2c: fix buffer size in sps30_i2c_read_meas() iio: magnetometer: tlv493d: remove erroneous shift in X-axis data iio: proximity: hx9023s: Protect against division by zero in set_samp_freq iio: proximity: hx9023s: fix assignment order for __counted_by iio: chemical: bme680: Fix measurement wait duration calculation iio: dac: ds4424: reject -128 RAW value iio: imu: inv_icm45600: fix INT1 drive bit inverted iio: potentiometer: mcp4131: fix double application of wiper shift iio: imu: inv-mpu9150: fix irq ack preventing irq storms iio: frequency: adf4377: Fix duplicated soft reset mask iio: light: bh1780: fix PM runtime leak on error path iio: imu: inv_icm42600: fix odr switch when turning buffer off iio: imu: inv_icm42600: fix odr switch to the same value
2 parents dceddee + 9990cd4 commit 994d5df

22 files changed

Lines changed: 73 additions & 27 deletions

File tree

drivers/iio/adc/ad7768-1.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static int ad7768_reg_access(struct iio_dev *indio_dev,
531531
return ret;
532532
}
533533

534-
static void ad7768_fill_scale_tbl(struct iio_dev *dev)
534+
static int ad7768_fill_scale_tbl(struct iio_dev *dev)
535535
{
536536
struct ad7768_state *st = iio_priv(dev);
537537
const struct iio_scan_type *scan_type;
@@ -541,6 +541,11 @@ static void ad7768_fill_scale_tbl(struct iio_dev *dev)
541541
u64 tmp2;
542542

543543
scan_type = iio_get_current_scan_type(dev, &dev->channels[0]);
544+
if (IS_ERR(scan_type)) {
545+
dev_err(&st->spi->dev, "Failed to get scan type.\n");
546+
return PTR_ERR(scan_type);
547+
}
548+
544549
if (scan_type->sign == 's')
545550
val2 = scan_type->realbits - 1;
546551
else
@@ -565,6 +570,8 @@ static void ad7768_fill_scale_tbl(struct iio_dev *dev)
565570
st->scale_tbl[i][0] = tmp0; /* Integer part */
566571
st->scale_tbl[i][1] = abs(tmp1); /* Fractional part */
567572
}
573+
574+
return 0;
568575
}
569576

570577
static int ad7768_set_sinc3_dec_rate(struct ad7768_state *st,
@@ -669,7 +676,9 @@ static int ad7768_configure_dig_fil(struct iio_dev *dev,
669676
}
670677

671678
/* Update scale table: scale values vary according to the precision */
672-
ad7768_fill_scale_tbl(dev);
679+
ret = ad7768_fill_scale_tbl(dev);
680+
if (ret)
681+
return ret;
673682

674683
ad7768_fill_samp_freq_tbl(st);
675684

drivers/iio/chemical/bme680_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static int bme680_wait_for_eoc(struct bme680_data *data)
613613
* + heater duration
614614
*/
615615
int wait_eoc_us = ((data->oversampling_temp + data->oversampling_press +
616-
data->oversampling_humid) * 1936) + (477 * 4) +
616+
data->oversampling_humid) * 1963) + (477 * 4) +
617617
(477 * 5) + 1000 + (data->heater_dur * 1000);
618618

619619
fsleep(wait_eoc_us);

drivers/iio/chemical/sps30_i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int sps30_i2c_read_meas(struct sps30_state *state, __be32 *meas, size_t n
171171
if (!sps30_i2c_meas_ready(state))
172172
return -ETIMEDOUT;
173173

174-
return sps30_i2c_command(state, SPS30_I2C_READ_MEAS, NULL, 0, meas, sizeof(num) * num);
174+
return sps30_i2c_command(state, SPS30_I2C_READ_MEAS, NULL, 0, meas, sizeof(*meas) * num);
175175
}
176176

177177
static int sps30_i2c_clean_fan(struct sps30_state *state)

drivers/iio/chemical/sps30_serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int sps30_serial_read_meas(struct sps30_state *state, __be32 *meas, size_
303303
if (msleep_interruptible(1000))
304304
return -EINTR;
305305

306-
ret = sps30_serial_command(state, SPS30_SERIAL_READ_MEAS, NULL, 0, meas, num * sizeof(num));
306+
ret = sps30_serial_command(state, SPS30_SERIAL_READ_MEAS, NULL, 0, meas, num * sizeof(*meas));
307307
if (ret < 0)
308308
return ret;
309309
/* if measurements aren't ready sensor returns empty frame */

drivers/iio/dac/ds4424.c

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

141141
switch (mask) {
142142
case IIO_CHAN_INFO_RAW:
143-
if (val < S8_MIN || val > S8_MAX)
143+
if (val <= S8_MIN || val > S8_MAX)
144144
return -EINVAL;
145145

146146
if (val > 0) {

drivers/iio/frequency/adf4377.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ static int adf4377_soft_reset(struct adf4377_state *st)
508508
return ret;
509509

510510
return regmap_read_poll_timeout(st->regmap, 0x0, read_val,
511-
!(read_val & (ADF4377_0000_SOFT_RESET_R_MSK |
511+
!(read_val & (ADF4377_0000_SOFT_RESET_MSK |
512512
ADF4377_0000_SOFT_RESET_R_MSK)), 200, 200 * 100);
513513
}
514514

drivers/iio/gyro/mpu3050-core.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ static int mpu3050_read_raw(struct iio_dev *indio_dev,
322322
}
323323
case IIO_CHAN_INFO_RAW:
324324
/* Resume device */
325-
pm_runtime_get_sync(mpu3050->dev);
325+
ret = pm_runtime_resume_and_get(mpu3050->dev);
326+
if (ret)
327+
return ret;
326328
mutex_lock(&mpu3050->lock);
327329

328330
ret = mpu3050_set_8khz_samplerate(mpu3050);
@@ -647,14 +649,20 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p)
647649
static int mpu3050_buffer_preenable(struct iio_dev *indio_dev)
648650
{
649651
struct mpu3050 *mpu3050 = iio_priv(indio_dev);
652+
int ret;
650653

651-
pm_runtime_get_sync(mpu3050->dev);
654+
ret = pm_runtime_resume_and_get(mpu3050->dev);
655+
if (ret)
656+
return ret;
652657

653658
/* Unless we have OUR trigger active, run at full speed */
654-
if (!mpu3050->hw_irq_trigger)
655-
return mpu3050_set_8khz_samplerate(mpu3050);
659+
if (!mpu3050->hw_irq_trigger) {
660+
ret = mpu3050_set_8khz_samplerate(mpu3050);
661+
if (ret)
662+
pm_runtime_put_autosuspend(mpu3050->dev);
663+
}
656664

657-
return 0;
665+
return ret;
658666
}
659667

660668
static int mpu3050_buffer_postdisable(struct iio_dev *indio_dev)

drivers/iio/gyro/mpu3050-i2c.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ static int mpu3050_i2c_bypass_select(struct i2c_mux_core *mux, u32 chan_id)
1919
struct mpu3050 *mpu3050 = i2c_mux_priv(mux);
2020

2121
/* Just power up the device, that is all that is needed */
22-
pm_runtime_get_sync(mpu3050->dev);
23-
return 0;
22+
return pm_runtime_resume_and_get(mpu3050->dev);
2423
}
2524

2625
static int mpu3050_i2c_bypass_deselect(struct i2c_mux_core *mux, u32 chan_id)

drivers/iio/imu/adis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ int adis_init(struct adis *adis, struct iio_dev *indio_dev,
526526

527527
adis->spi = spi;
528528
adis->data = data;
529-
if (!adis->ops->write && !adis->ops->read && !adis->ops->reset)
529+
if (!adis->ops)
530530
adis->ops = &adis_default_ops;
531531
else if (!adis->ops->write || !adis->ops->read || !adis->ops->reset)
532532
return -EINVAL;

drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ static int inv_icm42600_accel_write_odr(struct iio_dev *indio_dev,
651651
return -EINVAL;
652652

653653
conf.odr = inv_icm42600_accel_odr_conv[idx / 2];
654+
if (conf.odr == st->conf.accel.odr)
655+
return 0;
654656

655657
pm_runtime_get_sync(dev);
656658
mutex_lock(&st->lock);

0 commit comments

Comments
 (0)