Skip to content

Commit f55aaec

Browse files
committed
Merge tag 'iio-fixes-for-6.15a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus
Jonathan writes: IIO: 1st set of fixes for the 6.15 cycle. A mixed bunch of fixes for new and ancient issues found. multiple driver sets: - Stop leaking wakeup sources on device unbind. - Various timestamp alignment fixes that came up as part of work to add runtime checks on buffer sizing. Similarly a DMA buffer safety fix. hid-sensor-prox - Fix a bad merge conflict resolution that lost some variable assignments. - Fix handling of scale when multiple channels present. - Fix wrong application of exponent in offset calculation. adi,ad7380 - Disable offload before using the SPI bus. - Fix a wrong shift on the event threshold. adi,ad7606 - Check there is a sw_mode_config callback before using it as not all busses define one. - Fix missing hold of chip select on in multi word accesses. adi,ad7861 - Fix wrong logic on storing of mode. adi,adis16201 - Wrong resolution for inclinometer channel. adi,adxl367 - Use fresh ODR when setting activity time, not previous value. bosch,bmi270 - Fix initial sampling frequency configuration which was using the wrong register mask. rockchip,saradc - Fix clock initialization sequence to get frequency after get + enable, not before. st,lsm6dsx - Avoid 2 potential infinite loops if we see empty FIFOs ti,opt3001 - Fix a deadlock that can occur due to concurrent access to a flag. * tag 'iio-fixes-for-6.15a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (28 commits) iio: adis16201: Correct inclinometer channel resolution iio: adc: ad7606: fix serial register access iio: pressure: mprls0025pa: use aligned_s64 for timestamp iio: imu: adis16550: align buffers for timestamp staging: iio: adc: ad7816: Correct conditional logic for store mode iio: adc: ad7266: Fix potential timestamp alignment issue. iio: adc: ad7768-1: Fix insufficient alignment of timestamp. iio: adc: dln2: Use aligned_s64 for timestamp iio: accel: adxl355: Make timestamp 64-bit aligned using aligned_s64 iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer. iio: chemical: pms7003: use aligned_s64 for timestamp iio: chemical: sps30: use aligned_s64 for timestamp iio: imu: inv_mpu6050: align buffer for timestamp iio: imu: st_lsm6dsx: Fix wakeup source leaks on device unbind iio: adc: qcom-spmi-iadc: Fix wakeup source leaks on device unbind iio: accel: fxls8962af: Fix wakeup source leaks on device unbind iio: adc: ad7380: fix event threshold shift iio: hid-sensor-prox: Fix incorrect OFFSET calculation iio: hid-sensor-prox: support multi-channel SCALE calculation iio: hid-sensor-prox: Restore lost scale assignments ...
2 parents b443265 + 609bc31 commit f55aaec

25 files changed

+104
-73
lines changed

drivers/iio/accel/adis16201.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ static const struct iio_chan_spec adis16201_channels[] = {
211211
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
212212
ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC_REG, ADIS16201_SCAN_AUX_ADC, 0, 12),
213213
ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT_REG, ADIS16201_SCAN_INCLI_X,
214-
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
214+
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 12),
215215
ADIS_INCLI_CHAN(Y, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y,
216-
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
216+
BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 12),
217217
IIO_CHAN_SOFT_TIMESTAMP(7)
218218
};
219219

drivers/iio/accel/adxl355_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ struct adxl355_data {
231231
u8 transf_buf[3];
232232
struct {
233233
u8 buf[14];
234-
s64 ts;
234+
aligned_s64 ts;
235235
} buffer;
236236
} __aligned(IIO_DMA_MINALIGN);
237237
};

drivers/iio/accel/adxl367.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,18 +601,14 @@ static int _adxl367_set_odr(struct adxl367_state *st, enum adxl367_odr odr)
601601
if (ret)
602602
return ret;
603603

604+
st->odr = odr;
605+
604606
/* Activity timers depend on ODR */
605607
ret = _adxl367_set_act_time_ms(st, st->act_time_ms);
606608
if (ret)
607609
return ret;
608610

609-
ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms);
610-
if (ret)
611-
return ret;
612-
613-
st->odr = odr;
614-
615-
return 0;
611+
return _adxl367_set_inact_time_ms(st, st->inact_time_ms);
616612
}
617613

618614
static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)

drivers/iio/accel/fxls8962af-core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,8 +1226,11 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
12261226
if (ret)
12271227
return ret;
12281228

1229-
if (device_property_read_bool(dev, "wakeup-source"))
1230-
device_init_wakeup(dev, true);
1229+
if (device_property_read_bool(dev, "wakeup-source")) {
1230+
ret = devm_device_init_wakeup(dev);
1231+
if (ret)
1232+
return dev_err_probe(dev, ret, "Failed to init wakeup\n");
1233+
}
12311234

12321235
return devm_iio_device_register(dev, indio_dev);
12331236
}

drivers/iio/adc/ad7266.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct ad7266_state {
4545
*/
4646
struct {
4747
__be16 sample[2];
48-
s64 timestamp;
48+
aligned_s64 timestamp;
4949
} data __aligned(IIO_DMA_MINALIGN);
5050
};
5151

drivers/iio/adc/ad7380.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,9 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
12111211
struct ad7380_state *st = iio_priv(indio_dev);
12121212
int ret;
12131213

1214+
spi_offload_trigger_disable(st->offload, st->offload_trigger);
1215+
spi_unoptimize_message(&st->offload_msg);
1216+
12141217
if (st->seq) {
12151218
ret = regmap_update_bits(st->regmap,
12161219
AD7380_REG_ADDR_CONFIG1,
@@ -1222,10 +1225,6 @@ static int ad7380_offload_buffer_predisable(struct iio_dev *indio_dev)
12221225
st->seq = false;
12231226
}
12241227

1225-
spi_offload_trigger_disable(st->offload, st->offload_trigger);
1226-
1227-
spi_unoptimize_message(&st->offload_msg);
1228-
12291228
return 0;
12301229
}
12311230

@@ -1611,11 +1610,25 @@ static int ad7380_write_event_config(struct iio_dev *indio_dev,
16111610
return ret;
16121611
}
16131612

1614-
static int ad7380_get_alert_th(struct ad7380_state *st,
1613+
static int ad7380_get_alert_th(struct iio_dev *indio_dev,
1614+
const struct iio_chan_spec *chan,
16151615
enum iio_event_direction dir,
16161616
int *val)
16171617
{
1618-
int ret, tmp;
1618+
struct ad7380_state *st = iio_priv(indio_dev);
1619+
const struct iio_scan_type *scan_type;
1620+
int ret, tmp, shift;
1621+
1622+
scan_type = iio_get_current_scan_type(indio_dev, chan);
1623+
if (IS_ERR(scan_type))
1624+
return PTR_ERR(scan_type);
1625+
1626+
/*
1627+
* The register value is 12-bits and is compared to the most significant
1628+
* bits of raw value, therefore a shift is required to convert this to
1629+
* the same scale as the raw value.
1630+
*/
1631+
shift = scan_type->realbits - 12;
16191632

16201633
switch (dir) {
16211634
case IIO_EV_DIR_RISING:
@@ -1625,7 +1638,7 @@ static int ad7380_get_alert_th(struct ad7380_state *st,
16251638
if (ret)
16261639
return ret;
16271640

1628-
*val = FIELD_GET(AD7380_ALERT_HIGH_TH, tmp);
1641+
*val = FIELD_GET(AD7380_ALERT_HIGH_TH, tmp) << shift;
16291642
return IIO_VAL_INT;
16301643
case IIO_EV_DIR_FALLING:
16311644
ret = regmap_read(st->regmap,
@@ -1634,7 +1647,7 @@ static int ad7380_get_alert_th(struct ad7380_state *st,
16341647
if (ret)
16351648
return ret;
16361649

1637-
*val = FIELD_GET(AD7380_ALERT_LOW_TH, tmp);
1650+
*val = FIELD_GET(AD7380_ALERT_LOW_TH, tmp) << shift;
16381651
return IIO_VAL_INT;
16391652
default:
16401653
return -EINVAL;
@@ -1648,15 +1661,14 @@ static int ad7380_read_event_value(struct iio_dev *indio_dev,
16481661
enum iio_event_info info,
16491662
int *val, int *val2)
16501663
{
1651-
struct ad7380_state *st = iio_priv(indio_dev);
16521664
int ret;
16531665

16541666
switch (info) {
16551667
case IIO_EV_INFO_VALUE:
16561668
if (!iio_device_claim_direct(indio_dev))
16571669
return -EBUSY;
16581670

1659-
ret = ad7380_get_alert_th(st, dir, val);
1671+
ret = ad7380_get_alert_th(indio_dev, chan, dir, val);
16601672

16611673
iio_device_release_direct(indio_dev);
16621674
return ret;

drivers/iio/adc/ad7606.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,11 @@ static int ad7616_sw_mode_setup(struct iio_dev *indio_dev)
12361236
st->write_scale = ad7616_write_scale_sw;
12371237
st->write_os = &ad7616_write_os_sw;
12381238

1239-
ret = st->bops->sw_mode_config(indio_dev);
1240-
if (ret)
1241-
return ret;
1239+
if (st->bops->sw_mode_config) {
1240+
ret = st->bops->sw_mode_config(indio_dev);
1241+
if (ret)
1242+
return ret;
1243+
}
12421244

12431245
/* Activate Burst mode and SEQEN MODE */
12441246
return ad7606_write_mask(st, AD7616_CONFIGURATION_REGISTER,
@@ -1268,6 +1270,9 @@ static int ad7606b_sw_mode_setup(struct iio_dev *indio_dev)
12681270
st->write_scale = ad7606_write_scale_sw;
12691271
st->write_os = &ad7606_write_os_sw;
12701272

1273+
if (!st->bops->sw_mode_config)
1274+
return 0;
1275+
12711276
return st->bops->sw_mode_config(indio_dev);
12721277
}
12731278

drivers/iio/adc/ad7606_spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static int ad7606_spi_reg_read(struct ad7606_state *st, unsigned int addr)
131131
{
132132
.tx_buf = &st->d16[0],
133133
.len = 2,
134-
.cs_change = 0,
134+
.cs_change = 1,
135135
}, {
136136
.rx_buf = &st->d16[1],
137137
.len = 2,

drivers/iio/adc/ad7768-1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct ad7768_state {
168168
union {
169169
struct {
170170
__be32 chan;
171-
s64 timestamp;
171+
aligned_s64 timestamp;
172172
} scan;
173173
__be32 d32;
174174
u8 d8[2];

drivers/iio/adc/dln2-adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p)
466466
struct iio_dev *indio_dev = pf->indio_dev;
467467
struct {
468468
__le16 values[DLN2_ADC_MAX_CHANNELS];
469-
int64_t timestamp_space;
469+
aligned_s64 timestamp_space;
470470
} data;
471471
struct dln2_adc_get_all_vals dev_data;
472472
struct dln2_adc *dln2 = iio_priv(indio_dev);

0 commit comments

Comments
 (0)