Skip to content

Commit 5f59638

Browse files
committed
Merge tag 'iio-fixes-for-6.16a' 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.16 cycle The usual mixed back of the recent and ancient issues that have surfaced so far this cycle. iio-core - Fix a possible out of bounds write on writing string terminator. iio-backend: - Fix a possible out of bounds write on writing string terminator. adi,ad3530r - Fix wrong masking for channels 4-7 in powerdown mode as they are in a second register and mask assumed all in one larger register. adi,ad7380 - Fix parsing of adi,gain-milli property by reading it as u16 as specified in the binding. adi,ad7606 - Tweak dt-binding to allow both interrupts and backend to be wired up resolving some dt_schema warnings. - Mask value before returning it in register read as for parallel busses both the value and (unwanted) address are read back. adi,ad7949 - Use spi_is_bpw_supported() to correctly handle bits_per_word_mask == 0 which means default value of 8. invensense,mpu3050 - Fix wrong number of interrupts in the binding as minItems should have been maxItems. maxim,max1363 - Two related fixes for a long running mismatch between array indexes that now results in warnings after the core gained a sanity check. Resulted in unnecessary channels being sampled. nxp,fxls8962 - Fix a use after free in fxls8962af_fifo_flush() if it races with buffer mode tear down. st,sensors - Stop using indio_dev->dev before it was initialized as the parent device should be used anyway for error messages and similar. st,stm32-adc - Fix a race when installing chained IRQ handler. x-powers,axp20x_adc - Add missing sentinel in ADC channel map (avoid out of bounds read). * tag 'iio-fixes-for-6.16a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: dac: ad3530r: Fix incorrect masking for channels 4-7 in powerdown mode iio: adc: ad7380: fix adi,gain-milli property parsing iio: adc: ad7949: use spi_is_bpw_supported() iio: accel: fxls8962af: Fix use after free in fxls8962af_fifo_flush iio: adc: axp20x_adc: Add missing sentinel to AXP717 ADC channel maps dt-bindings: iio: gyro: invensense,mpu3050: change irq maxItems iio: common: st_sensors: Fix use of uninitialize device structs iio: adc: adi-axi-adc: fix ad7606_bus_reg_read() dt-bindings: iio: adc: adi,ad7606: fix dt_schema validation warning iio: adc: max1363: Reorder mode_list[] entries iio: adc: max1363: Fix MAX1363_4X_CHANS/MAX1363_8X_CHANS[] iio: adc: stm32-adc: Fix race in installing chained IRQ handler iio: fix potential out-of-bound write iio: backend: fix out-of-bound write
2 parents 9fe58ec + 1131e70 commit 5f59638

15 files changed

Lines changed: 80 additions & 79 deletions

File tree

Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ allOf:
223223
- required:
224224
- pwms
225225

226-
- oneOf:
227-
- required:
228-
- interrupts
229-
- required:
230-
- io-backends
231-
232226
- if:
233227
properties:
234228
compatible:

Documentation/devicetree/bindings/iio/gyroscope/invensense,mpu3050.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ properties:
2121
vlogic-supply: true
2222

2323
interrupts:
24-
minItems: 1
24+
maxItems: 1
2525
description:
2626
Interrupt mapping for the trigger interrupt from the internal oscillator.
2727

drivers/iio/accel/fxls8962af-core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,8 @@ static int fxls8962af_buffer_predisable(struct iio_dev *indio_dev)
877877
if (ret)
878878
return ret;
879879

880+
synchronize_irq(data->irq);
881+
880882
ret = __fxls8962af_fifo_set_mode(data, false);
881883

882884
if (data->enable_event)

drivers/iio/accel/st_accel_core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
13531353
union acpi_object *ont;
13541354
union acpi_object *elements;
13551355
acpi_status status;
1356+
struct device *parent = indio_dev->dev.parent;
13561357
int ret = -EINVAL;
13571358
unsigned int val;
13581359
int i, j;
@@ -1371,7 +1372,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
13711372
};
13721373

13731374

1374-
adev = ACPI_COMPANION(indio_dev->dev.parent);
1375+
adev = ACPI_COMPANION(parent);
13751376
if (!adev)
13761377
return -ENXIO;
13771378

@@ -1380,8 +1381,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
13801381
if (status == AE_NOT_FOUND) {
13811382
return -ENXIO;
13821383
} else if (ACPI_FAILURE(status)) {
1383-
dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n",
1384-
status);
1384+
dev_warn(parent, "failed to execute _ONT: %d\n", status);
13851385
return status;
13861386
}
13871387

@@ -1457,12 +1457,12 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
14571457
}
14581458

14591459
ret = 0;
1460-
dev_info(&indio_dev->dev, "computed mount matrix from ACPI\n");
1460+
dev_info(parent, "computed mount matrix from ACPI\n");
14611461

14621462
out:
14631463
kfree(buffer.pointer);
14641464
if (ret)
1465-
dev_dbg(&indio_dev->dev,
1465+
dev_dbg(parent,
14661466
"failed to apply ACPI orientation data: %d\n", ret);
14671467

14681468
return ret;

drivers/iio/adc/ad7380.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,8 +1953,9 @@ static int ad7380_probe(struct spi_device *spi)
19531953

19541954
if (st->chip_info->has_hardware_gain) {
19551955
device_for_each_child_node_scoped(dev, node) {
1956-
unsigned int channel, gain;
1956+
unsigned int channel;
19571957
int gain_idx;
1958+
u16 gain;
19581959

19591960
ret = fwnode_property_read_u32(node, "reg", &channel);
19601961
if (ret)
@@ -1966,7 +1967,7 @@ static int ad7380_probe(struct spi_device *spi)
19661967
"Invalid channel number %i\n",
19671968
channel);
19681969

1969-
ret = fwnode_property_read_u32(node, "adi,gain-milli",
1970+
ret = fwnode_property_read_u16(node, "adi,gain-milli",
19701971
&gain);
19711972
if (ret && ret != -EINVAL)
19721973
return dev_err_probe(dev, ret,

drivers/iio/adc/ad7949.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ static void ad7949_disable_reg(void *reg)
308308

309309
static int ad7949_spi_probe(struct spi_device *spi)
310310
{
311-
u32 spi_ctrl_mask = spi->controller->bits_per_word_mask;
312311
struct device *dev = &spi->dev;
313312
const struct ad7949_adc_spec *spec;
314313
struct ad7949_adc_chip *ad7949_adc;
@@ -337,11 +336,11 @@ static int ad7949_spi_probe(struct spi_device *spi)
337336
ad7949_adc->resolution = spec->resolution;
338337

339338
/* Set SPI bits per word */
340-
if (spi_ctrl_mask & SPI_BPW_MASK(ad7949_adc->resolution)) {
339+
if (spi_is_bpw_supported(spi, ad7949_adc->resolution)) {
341340
spi->bits_per_word = ad7949_adc->resolution;
342-
} else if (spi_ctrl_mask == SPI_BPW_MASK(16)) {
341+
} else if (spi_is_bpw_supported(spi, 16)) {
343342
spi->bits_per_word = 16;
344-
} else if (spi_ctrl_mask == SPI_BPW_MASK(8)) {
343+
} else if (spi_is_bpw_supported(spi, 8)) {
345344
spi->bits_per_word = 8;
346345
} else {
347346
dev_err(dev, "unable to find common BPW with spi controller\n");

drivers/iio/adc/adi-axi-adc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int axi_adc_raw_read(struct iio_backend *back, u32 *val)
445445
static int ad7606_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val)
446446
{
447447
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
448-
int addr;
448+
u32 addr, reg_val;
449449

450450
guard(mutex)(&st->lock);
451451

@@ -455,7 +455,9 @@ static int ad7606_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val)
455455
*/
456456
addr = FIELD_PREP(ADI_AXI_REG_ADDRESS_MASK, reg) | ADI_AXI_REG_READ_BIT;
457457
axi_adc_raw_write(back, addr);
458-
axi_adc_raw_read(back, val);
458+
axi_adc_raw_read(back, &reg_val);
459+
460+
*val = FIELD_GET(ADI_AXI_REG_VALUE_MASK, reg_val);
459461

460462
/* Write 0x0 on the bus to get back to ADC mode */
461463
axi_adc_raw_write(back, 0);

drivers/iio/adc/axp20x_adc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ static struct iio_map axp717_maps[] = {
187187
.consumer_channel = "batt_chrg_i",
188188
.adc_channel_label = "batt_chrg_i",
189189
},
190+
{ }
190191
};
191192

192193
/*

drivers/iio/adc/max1363.c

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,10 @@ static const struct iio_event_spec max1363_events[] = {
511511
MAX1363_CHAN_U(1, _s1, 1, bits, ev_spec, num_ev_spec), \
512512
MAX1363_CHAN_U(2, _s2, 2, bits, ev_spec, num_ev_spec), \
513513
MAX1363_CHAN_U(3, _s3, 3, bits, ev_spec, num_ev_spec), \
514-
MAX1363_CHAN_B(0, 1, d0m1, 4, bits, ev_spec, num_ev_spec), \
515-
MAX1363_CHAN_B(2, 3, d2m3, 5, bits, ev_spec, num_ev_spec), \
516-
MAX1363_CHAN_B(1, 0, d1m0, 6, bits, ev_spec, num_ev_spec), \
517-
MAX1363_CHAN_B(3, 2, d3m2, 7, bits, ev_spec, num_ev_spec), \
514+
MAX1363_CHAN_B(0, 1, d0m1, 12, bits, ev_spec, num_ev_spec), \
515+
MAX1363_CHAN_B(2, 3, d2m3, 13, bits, ev_spec, num_ev_spec), \
516+
MAX1363_CHAN_B(1, 0, d1m0, 18, bits, ev_spec, num_ev_spec), \
517+
MAX1363_CHAN_B(3, 2, d3m2, 19, bits, ev_spec, num_ev_spec), \
518518
IIO_CHAN_SOFT_TIMESTAMP(8) \
519519
}
520520

@@ -532,23 +532,23 @@ static const struct iio_chan_spec max1363_channels[] =
532532
/* Applies to max1236, max1237 */
533533
static const enum max1363_modes max1236_mode_list[] = {
534534
_s0, _s1, _s2, _s3,
535-
s0to1, s0to2, s0to3,
535+
s0to1, s0to2, s2to3, s0to3,
536536
d0m1, d2m3, d1m0, d3m2,
537537
d0m1to2m3, d1m0to3m2,
538-
s2to3,
539538
};
540539

541540
/* Applies to max1238, max1239 */
542541
static const enum max1363_modes max1238_mode_list[] = {
543542
_s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7, _s8, _s9, _s10, _s11,
544543
s0to1, s0to2, s0to3, s0to4, s0to5, s0to6,
544+
s6to7, s6to8, s6to9, s6to10, s6to11,
545545
s0to7, s0to8, s0to9, s0to10, s0to11,
546546
d0m1, d2m3, d4m5, d6m7, d8m9, d10m11,
547547
d1m0, d3m2, d5m4, d7m6, d9m8, d11m10,
548-
d0m1to2m3, d0m1to4m5, d0m1to6m7, d0m1to8m9, d0m1to10m11,
549-
d1m0to3m2, d1m0to5m4, d1m0to7m6, d1m0to9m8, d1m0to11m10,
550-
s6to7, s6to8, s6to9, s6to10, s6to11,
551-
d6m7to8m9, d6m7to10m11, d7m6to9m8, d7m6to11m10,
548+
d0m1to2m3, d0m1to4m5, d0m1to6m7, d6m7to8m9,
549+
d0m1to8m9, d6m7to10m11, d0m1to10m11, d1m0to3m2,
550+
d1m0to5m4, d1m0to7m6, d7m6to9m8, d1m0to9m8,
551+
d7m6to11m10, d1m0to11m10,
552552
};
553553

554554
#define MAX1363_12X_CHANS(bits) { \
@@ -584,16 +584,15 @@ static const struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12);
584584

585585
static const enum max1363_modes max11607_mode_list[] = {
586586
_s0, _s1, _s2, _s3,
587-
s0to1, s0to2, s0to3,
588-
s2to3,
587+
s0to1, s0to2, s2to3,
588+
s0to3,
589589
d0m1, d2m3, d1m0, d3m2,
590590
d0m1to2m3, d1m0to3m2,
591591
};
592592

593593
static const enum max1363_modes max11608_mode_list[] = {
594594
_s0, _s1, _s2, _s3, _s4, _s5, _s6, _s7,
595-
s0to1, s0to2, s0to3, s0to4, s0to5, s0to6, s0to7,
596-
s6to7,
595+
s0to1, s0to2, s0to3, s0to4, s0to5, s0to6, s6to7, s0to7,
597596
d0m1, d2m3, d4m5, d6m7,
598597
d1m0, d3m2, d5m4, d7m6,
599598
d0m1to2m3, d0m1to4m5, d0m1to6m7,
@@ -609,14 +608,14 @@ static const enum max1363_modes max11608_mode_list[] = {
609608
MAX1363_CHAN_U(5, _s5, 5, bits, NULL, 0), \
610609
MAX1363_CHAN_U(6, _s6, 6, bits, NULL, 0), \
611610
MAX1363_CHAN_U(7, _s7, 7, bits, NULL, 0), \
612-
MAX1363_CHAN_B(0, 1, d0m1, 8, bits, NULL, 0), \
613-
MAX1363_CHAN_B(2, 3, d2m3, 9, bits, NULL, 0), \
614-
MAX1363_CHAN_B(4, 5, d4m5, 10, bits, NULL, 0), \
615-
MAX1363_CHAN_B(6, 7, d6m7, 11, bits, NULL, 0), \
616-
MAX1363_CHAN_B(1, 0, d1m0, 12, bits, NULL, 0), \
617-
MAX1363_CHAN_B(3, 2, d3m2, 13, bits, NULL, 0), \
618-
MAX1363_CHAN_B(5, 4, d5m4, 14, bits, NULL, 0), \
619-
MAX1363_CHAN_B(7, 6, d7m6, 15, bits, NULL, 0), \
611+
MAX1363_CHAN_B(0, 1, d0m1, 12, bits, NULL, 0), \
612+
MAX1363_CHAN_B(2, 3, d2m3, 13, bits, NULL, 0), \
613+
MAX1363_CHAN_B(4, 5, d4m5, 14, bits, NULL, 0), \
614+
MAX1363_CHAN_B(6, 7, d6m7, 15, bits, NULL, 0), \
615+
MAX1363_CHAN_B(1, 0, d1m0, 18, bits, NULL, 0), \
616+
MAX1363_CHAN_B(3, 2, d3m2, 19, bits, NULL, 0), \
617+
MAX1363_CHAN_B(5, 4, d5m4, 20, bits, NULL, 0), \
618+
MAX1363_CHAN_B(7, 6, d7m6, 21, bits, NULL, 0), \
620619
IIO_CHAN_SOFT_TIMESTAMP(16) \
621620
}
622621
static const struct iio_chan_spec max11602_channels[] = MAX1363_8X_CHANS(8);

drivers/iio/adc/stm32-adc-core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,9 @@ static int stm32_adc_irq_probe(struct platform_device *pdev,
430430
return -ENOMEM;
431431
}
432432

433-
for (i = 0; i < priv->cfg->num_irqs; i++) {
434-
irq_set_chained_handler(priv->irq[i], stm32_adc_irq_handler);
435-
irq_set_handler_data(priv->irq[i], priv);
436-
}
433+
for (i = 0; i < priv->cfg->num_irqs; i++)
434+
irq_set_chained_handler_and_data(priv->irq[i],
435+
stm32_adc_irq_handler, priv);
437436

438437
return 0;
439438
}

0 commit comments

Comments
 (0)