Skip to content

Commit 36a7060

Browse files
committed
Merge tag 'iio-fixes-for-6.19a' 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.19 cycle The usual mixed bag of fixes for ancient problems plus some more recent ones. adi,ad7280a - Check for errors from spi_setup(). adi,ad3552r - Fix potential buffer overflow when setting to use the internal ramp. adi,ax5695r - Fill in the data for this device in the chip info table. adi,ad7606 - Don't store a negative error in an unsigned int. adi,ad9467 - Fix incorrect register mask value. adi,adxl380 - Fix inverted condition for whether INT1 interrupt present in dt. atmel,at91-sama5d2 - Cancel work on remove to avoid a potential use-after-free invensense,icm45600 - Fix temperature scaling. samsung,eynos_adc - Use of_platform_depolulate() to correctly clear up such that child devices are created correctly if the driver is rebound. sensiron,scd4x - Fix incorrect endianness reported to user-space. st,accel - Fix gain reported for the iis329dq. st,lsm6dsx - Hide event related interfaces on parts that don't support events. ti,pac1934 - Ensure output of clamp() is used rather than unclamped value. * tag 'iio-fixes-for-6.19a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: dac: ad3552r-hs: fix out-of-bound write in ad3552r_hs_write_data_source iio: accel: iis328dq: fix gain values iio: core: add separate lockdep class for info_exist_lock iio: chemical: scd4x: fix reported channel endianness iio: imu: inv_icm45600: fix temperature offset reporting iio: adc: exynos_adc: fix OF populate on driver rebind iio: dac: ad5686: add AD5695R to ad5686_chip_info_tbl iio: accel: adxl380: fix handling of unavailable "INT1" interrupt iio: imu: st_lsm6dsx: fix iio_chan_spec for sensors without event detection iio: adc: pac1934: Fix clamped value in pac1934_reg_snapshot iio: adc: ad9467: fix ad9434 vref mask iio: adc: ad7606: Fix incorrect type for error return variable iio: adc: ad7280a: handle spi_setup() errors in probe() iio: adc: at91-sama5d2_adc: Fix potential use-after-free in sama5d2_adc driver
2 parents 0f61b18 + 978d281 commit 36a7060

15 files changed

Lines changed: 120 additions & 36 deletions

File tree

drivers/iio/accel/adxl380.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,9 +1784,9 @@ static int adxl380_config_irq(struct iio_dev *indio_dev)
17841784
st->int_map[1] = ADXL380_INT0_MAP1_REG;
17851785
} else {
17861786
st->irq = fwnode_irq_get_byname(dev_fwnode(st->dev), "INT1");
1787-
if (st->irq > 0)
1788-
return dev_err_probe(st->dev, -ENODEV,
1789-
"no interrupt name specified");
1787+
if (st->irq < 0)
1788+
return dev_err_probe(st->dev, st->irq,
1789+
"no interrupt name specified\n");
17901790
st->int_map[0] = ADXL380_INT1_MAP0_REG;
17911791
st->int_map[1] = ADXL380_INT1_MAP1_REG;
17921792
}

drivers/iio/accel/st_accel_core.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
517517
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
518518
.sensors_supported = {
519519
[0] = H3LIS331DL_ACCEL_DEV_NAME,
520-
[1] = IIS328DQ_ACCEL_DEV_NAME,
521520
},
522521
.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
523522
.odr = {
@@ -584,6 +583,77 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
584583
.multi_read_bit = true,
585584
.bootime = 2,
586585
},
586+
{
587+
.wai = 0x32,
588+
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
589+
.sensors_supported = {
590+
[0] = IIS328DQ_ACCEL_DEV_NAME,
591+
},
592+
.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
593+
.odr = {
594+
.addr = 0x20,
595+
.mask = 0x18,
596+
.odr_avl = {
597+
{ .hz = 50, .value = 0x00, },
598+
{ .hz = 100, .value = 0x01, },
599+
{ .hz = 400, .value = 0x02, },
600+
{ .hz = 1000, .value = 0x03, },
601+
},
602+
},
603+
.pw = {
604+
.addr = 0x20,
605+
.mask = 0x20,
606+
.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
607+
.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
608+
},
609+
.enable_axis = {
610+
.addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
611+
.mask = ST_SENSORS_DEFAULT_AXIS_MASK,
612+
},
613+
.fs = {
614+
.addr = 0x23,
615+
.mask = 0x30,
616+
.fs_avl = {
617+
[0] = {
618+
.num = ST_ACCEL_FS_AVL_100G,
619+
.value = 0x00,
620+
.gain = IIO_G_TO_M_S_2(980),
621+
},
622+
[1] = {
623+
.num = ST_ACCEL_FS_AVL_200G,
624+
.value = 0x01,
625+
.gain = IIO_G_TO_M_S_2(1950),
626+
},
627+
[2] = {
628+
.num = ST_ACCEL_FS_AVL_400G,
629+
.value = 0x03,
630+
.gain = IIO_G_TO_M_S_2(3910),
631+
},
632+
},
633+
},
634+
.bdu = {
635+
.addr = 0x23,
636+
.mask = 0x80,
637+
},
638+
.drdy_irq = {
639+
.int1 = {
640+
.addr = 0x22,
641+
.mask = 0x02,
642+
},
643+
.int2 = {
644+
.addr = 0x22,
645+
.mask = 0x10,
646+
},
647+
.addr_ihl = 0x22,
648+
.mask_ihl = 0x80,
649+
},
650+
.sim = {
651+
.addr = 0x23,
652+
.value = BIT(0),
653+
},
654+
.multi_read_bit = true,
655+
.bootime = 2,
656+
},
587657
{
588658
/* No WAI register present */
589659
.sensors_supported = {

drivers/iio/adc/ad7280a.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,9 @@ static int ad7280_probe(struct spi_device *spi)
10241024

10251025
st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_HZ;
10261026
st->spi->mode = SPI_MODE_1;
1027-
spi_setup(st->spi);
1027+
ret = spi_setup(st->spi);
1028+
if (ret < 0)
1029+
return ret;
10281030

10291031
st->ctrl_lb = FIELD_PREP(AD7280A_CTRL_LB_ACQ_TIME_MSK, st->acquisition_time) |
10301032
FIELD_PREP(AD7280A_CTRL_LB_THERMISTOR_MSK, st->thermistor_term_en);

drivers/iio/adc/ad7606_par.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static int ad7606_par_bus_setup_iio_backend(struct device *dev,
4343
struct iio_dev *indio_dev)
4444
{
4545
struct ad7606_state *st = iio_priv(indio_dev);
46-
unsigned int ret, c;
46+
unsigned int c;
47+
int ret;
4748
struct iio_backend_data_fmt data = {
4849
.sign_extend = true,
4950
.enable = true,

drivers/iio/adc/ad9467.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
#define CHIPID_AD9434 0x6A
9797
#define AD9434_DEF_OUTPUT_MODE 0x00
98-
#define AD9434_REG_VREF_MASK 0xC0
98+
#define AD9434_REG_VREF_MASK GENMASK(4, 0)
9999

100100
/*
101101
* Analog Devices AD9467 16-Bit, 200/250 MSPS ADC

drivers/iio/adc/at91-sama5d2_adc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,7 @@ static void at91_adc_remove(struct platform_device *pdev)
24812481
struct at91_adc_state *st = iio_priv(indio_dev);
24822482

24832483
iio_device_unregister(indio_dev);
2484+
cancel_work_sync(&st->touch_st.workq);
24842485

24852486
at91_adc_dma_disable(st);
24862487

drivers/iio/adc/exynos_adc.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,6 @@ static const struct iio_chan_spec exynos_adc_iio_channels[] = {
540540
ADC_CHANNEL(9, "adc9"),
541541
};
542542

543-
static int exynos_adc_remove_devices(struct device *dev, void *c)
544-
{
545-
struct platform_device *pdev = to_platform_device(dev);
546-
547-
platform_device_unregister(pdev);
548-
549-
return 0;
550-
}
551-
552543
static int exynos_adc_probe(struct platform_device *pdev)
553544
{
554545
struct exynos_adc *info = NULL;
@@ -660,8 +651,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
660651
return 0;
661652

662653
err_of_populate:
663-
device_for_each_child(&indio_dev->dev, NULL,
664-
exynos_adc_remove_devices);
654+
of_platform_depopulate(&indio_dev->dev);
665655
iio_device_unregister(indio_dev);
666656
err_irq:
667657
free_irq(info->irq, info);
@@ -681,8 +671,7 @@ static void exynos_adc_remove(struct platform_device *pdev)
681671
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
682672
struct exynos_adc *info = iio_priv(indio_dev);
683673

684-
device_for_each_child(&indio_dev->dev, NULL,
685-
exynos_adc_remove_devices);
674+
of_platform_depopulate(&indio_dev->dev);
686675
iio_device_unregister(indio_dev);
687676
free_irq(info->irq, info);
688677
if (info->data->exit_hw)

drivers/iio/adc/pac1934.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,9 @@ static int pac1934_reg_snapshot(struct pac1934_chip_info *info,
665665
/* add the power_acc field */
666666
curr_energy += inc;
667667

668-
clamp(curr_energy, PAC_193X_MIN_POWER_ACC, PAC_193X_MAX_POWER_ACC);
669-
670-
reg_data->energy_sec_acc[cnt] = curr_energy;
668+
reg_data->energy_sec_acc[cnt] = clamp(curr_energy,
669+
PAC_193X_MIN_POWER_ACC,
670+
PAC_193X_MAX_POWER_ACC);
671671
}
672672

673673
offset_reg_data_p += PAC1934_VPOWER_ACC_REG_LEN;

drivers/iio/chemical/scd4x.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
584584
.sign = 'u',
585585
.realbits = 16,
586586
.storagebits = 16,
587-
.endianness = IIO_BE,
587+
.endianness = IIO_CPU,
588588
},
589589
},
590590
{
@@ -599,7 +599,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
599599
.sign = 'u',
600600
.realbits = 16,
601601
.storagebits = 16,
602-
.endianness = IIO_BE,
602+
.endianness = IIO_CPU,
603603
},
604604
},
605605
{
@@ -612,7 +612,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
612612
.sign = 'u',
613613
.realbits = 16,
614614
.storagebits = 16,
615-
.endianness = IIO_BE,
615+
.endianness = IIO_CPU,
616616
},
617617
},
618618
};

drivers/iio/dac/ad3552r-hs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,15 @@ static ssize_t ad3552r_hs_write_data_source(struct file *f,
549549

550550
guard(mutex)(&st->lock);
551551

552+
if (count >= sizeof(buf))
553+
return -ENOSPC;
554+
552555
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf,
553556
count);
554557
if (ret < 0)
555558
return ret;
556559

557-
buf[count] = '\0';
560+
buf[ret] = '\0';
558561

559562
ret = match_string(dbgfs_attr_source, ARRAY_SIZE(dbgfs_attr_source),
560563
buf);

0 commit comments

Comments
 (0)