Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'iio-fixes-for-6.15b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

IIO: 2nd set of fixes for 6.15 (or 6.16 merge window)

Usual mixed bag.

adi,ad4851
- Avoid a buffer overrun due to bug in pointer arithmetic.
adi,ad7173
- Fix compiling if gpiolib is not enabled
adi,ad7606
- Fix raw reads for 18-bit chips by ensuring we mask out upper bits
as some SPI controllers do not do so for 18bit words.
- Fix wrong masking for register writes.
adi,ad7944
- Mask high bits for raw reads.
adi,axi-adc
- Add check on whether the busy flag has cleared before first access.
invensense,icm42600
- Fix the temperature offset to take scale into account.
nxp,fxls8962af
- Fix temperature to be in milli degrees Celsius not degrees.
- Fix sign of temperature channel.

* tag 'iio-fixes-for-6.15b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
iio: accel: fxls8962af: Fix temperature scan element sign
iio: accel: fxls8962af: Fix temperature calculation
iio: adc: ad7944: mask high bits on direct read
iio: adc: ad4851: fix ad4858 chan pointer handling
iio: imu: inv_icm42600: Fix temperature calculation
iio: dac: adi-axi-dac: fix bus read
iio: adc: ad7606_spi: fix reg write value mask
iio: adc: ad7606: fix raw read for 18-bit chips
iio: adc: ad7173: fix compiling without gpiolib

+50 -40
+13 -2
drivers/iio/accel/fxls8962af-core.c
··· 23 23 #include <linux/regulator/consumer.h> 24 24 #include <linux/regmap.h> 25 25 #include <linux/types.h> 26 + #include <linux/units.h> 26 27 27 28 #include <linux/iio/buffer.h> 28 29 #include <linux/iio/events.h> ··· 440 439 *val = FXLS8962AF_TEMP_CENTER_VAL; 441 440 return IIO_VAL_INT; 442 441 case IIO_CHAN_INFO_SCALE: 443 - *val = 0; 444 - return fxls8962af_read_full_scale(data, val2); 442 + switch (chan->type) { 443 + case IIO_TEMP: 444 + *val = MILLIDEGREE_PER_DEGREE; 445 + return IIO_VAL_INT; 446 + case IIO_ACCEL: 447 + *val = 0; 448 + return fxls8962af_read_full_scale(data, val2); 449 + default: 450 + return -EINVAL; 451 + } 445 452 case IIO_CHAN_INFO_SAMP_FREQ: 446 453 return fxls8962af_read_samp_freq(data, val, val2); 447 454 default: ··· 745 736 .type = IIO_TEMP, \ 746 737 .address = FXLS8962AF_TEMP_OUT, \ 747 738 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 739 + BIT(IIO_CHAN_INFO_SCALE) | \ 748 740 BIT(IIO_CHAN_INFO_OFFSET),\ 749 741 .scan_index = -1, \ 750 742 .scan_type = { \ 743 + .sign = 's', \ 751 744 .realbits = 8, \ 752 745 .storagebits = 8, \ 753 746 }, \
+3 -2
drivers/iio/adc/Kconfig
··· 129 129 tristate "Analog Devices AD7173 driver" 130 130 depends on SPI_MASTER 131 131 select AD_SIGMA_DELTA 132 - select GPIO_REGMAP if GPIOLIB 133 - select REGMAP_SPI if GPIOLIB 132 + select GPIOLIB 133 + select GPIO_REGMAP 134 + select REGMAP_SPI 134 135 help 135 136 Say yes here to build support for Analog Devices AD7173 and similar ADC 136 137 Currently supported models:
+7 -7
drivers/iio/adc/ad4851.c
··· 1034 1034 struct device *dev = &st->spi->dev; 1035 1035 struct iio_chan_spec *ad4851_channels; 1036 1036 const struct iio_chan_spec ad4851_chan = AD4858_IIO_CHANNEL; 1037 - int ret; 1037 + int ret, i = 0; 1038 1038 1039 1039 ret = ad4851_parse_channels_common(indio_dev, &ad4851_channels, 1040 1040 ad4851_chan); ··· 1042 1042 return ret; 1043 1043 1044 1044 device_for_each_child_node_scoped(dev, child) { 1045 - ad4851_channels->has_ext_scan_type = 1; 1045 + ad4851_channels[i].has_ext_scan_type = 1; 1046 1046 if (fwnode_property_read_bool(child, "bipolar")) { 1047 - ad4851_channels->ext_scan_type = ad4851_scan_type_20_b; 1048 - ad4851_channels->num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_b); 1047 + ad4851_channels[i].ext_scan_type = ad4851_scan_type_20_b; 1048 + ad4851_channels[i].num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_b); 1049 1049 } else { 1050 - ad4851_channels->ext_scan_type = ad4851_scan_type_20_u; 1051 - ad4851_channels->num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_u); 1050 + ad4851_channels[i].ext_scan_type = ad4851_scan_type_20_u; 1051 + ad4851_channels[i].num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_u); 1052 1052 } 1053 - ad4851_channels++; 1053 + i++; 1054 1054 } 1055 1055 1056 1056 indio_dev->channels = ad4851_channels;
+1 -14
drivers/iio/adc/ad7173.c
··· 230 230 unsigned long long *config_cnts; 231 231 struct clk *ext_clk; 232 232 struct clk_hw int_clk_hw; 233 - #if IS_ENABLED(CONFIG_GPIOLIB) 234 233 struct regmap *reg_gpiocon_regmap; 235 234 struct gpio_regmap *gpio_regmap; 236 - #endif 237 235 }; 238 236 239 237 static unsigned int ad4115_sinc5_data_rates[] = { ··· 285 287 static const char *const ad7173_clk_sel[] = { 286 288 "ext-clk", "xtal" 287 289 }; 288 - 289 - #if IS_ENABLED(CONFIG_GPIOLIB) 290 290 291 291 static const struct regmap_range ad7173_range_gpio[] = { 292 292 regmap_reg_range(AD7173_REG_GPIO, AD7173_REG_GPIO), ··· 539 543 540 544 return 0; 541 545 } 542 - #else 543 - static int ad7173_gpio_init(struct ad7173_state *st) 544 - { 545 - return 0; 546 - } 547 - #endif /* CONFIG_GPIOLIB */ 548 546 549 547 static struct ad7173_state *ad_sigma_delta_to_ad7173(struct ad_sigma_delta *sd) 550 548 { ··· 1787 1797 if (ret) 1788 1798 return ret; 1789 1799 1790 - if (IS_ENABLED(CONFIG_GPIOLIB)) 1791 - return ad7173_gpio_init(st); 1792 - 1793 - return 0; 1800 + return ad7173_gpio_init(st); 1794 1801 } 1795 1802 1796 1803 static const struct of_device_id ad7173_of_match[] = {
+10 -11
drivers/iio/adc/ad7606.c
··· 727 727 goto error_ret; 728 728 729 729 chan = &indio_dev->channels[ch + 1]; 730 - if (chan->scan_type.sign == 'u') { 731 - if (realbits > 16) 732 - *val = st->data.buf32[ch]; 733 - else 734 - *val = st->data.buf16[ch]; 735 - } else { 736 - if (realbits > 16) 737 - *val = sign_extend32(st->data.buf32[ch], realbits - 1); 738 - else 739 - *val = sign_extend32(st->data.buf16[ch], realbits - 1); 740 - } 730 + 731 + if (realbits > 16) 732 + *val = st->data.buf32[ch]; 733 + else 734 + *val = st->data.buf16[ch]; 735 + 736 + *val &= GENMASK(realbits - 1, 0); 737 + 738 + if (chan->scan_type.sign == 's') 739 + *val = sign_extend32(*val, realbits - 1); 741 740 742 741 error_ret: 743 742 if (!st->gpio_convst) {
+1 -1
drivers/iio/adc/ad7606_spi.c
··· 155 155 struct spi_device *spi = to_spi_device(st->dev); 156 156 157 157 st->d16[0] = cpu_to_be16((st->bops->rd_wr_cmd(addr, 1) << 8) | 158 - (val & 0x1FF)); 158 + (val & 0xFF)); 159 159 160 160 return spi_write(spi, &st->d16[0], sizeof(st->d16[0])); 161 161 }
+2
drivers/iio/adc/ad7944.c
··· 377 377 378 378 if (chan->scan_type.sign == 's') 379 379 *val = sign_extend32(*val, chan->scan_type.realbits - 1); 380 + else 381 + *val &= GENMASK(chan->scan_type.realbits - 1, 0); 380 382 381 383 return IIO_VAL_INT; 382 384 }
+8
drivers/iio/dac/adi-axi-dac.c
··· 707 707 { 708 708 struct axi_dac_state *st = iio_backend_get_priv(back); 709 709 int ret; 710 + u32 ival; 710 711 711 712 guard(mutex)(&st->lock); 712 713 ··· 717 716 */ 718 717 ret = __axi_dac_bus_reg_write(back, AXI_DAC_RD_ADDR(reg), 0, 719 718 data_size); 719 + if (ret) 720 + return ret; 721 + 722 + ret = regmap_read_poll_timeout(st->regmap, 723 + AXI_DAC_UI_STATUS_REG, ival, 724 + FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0, 725 + 10, 100 * KILO); 720 726 if (ret) 721 727 return ret; 722 728
+5 -3
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
··· 67 67 return IIO_VAL_INT; 68 68 /* 69 69 * T°C = (temp / 132.48) + 25 70 - * Tm°C = 1000 * ((temp * 100 / 13248) + 25) 70 + * Tm°C = 1000 * ((temp / 132.48) + 25) 71 + * Tm°C = 7.548309 * temp + 25000 72 + * Tm°C = (temp + 3312) * 7.548309 71 73 * scale: 100000 / 13248 ~= 7.548309 72 - * offset: 25000 74 + * offset: 3312 73 75 */ 74 76 case IIO_CHAN_INFO_SCALE: 75 77 *val = 7; 76 78 *val2 = 548309; 77 79 return IIO_VAL_INT_PLUS_MICRO; 78 80 case IIO_CHAN_INFO_OFFSET: 79 - *val = 25000; 81 + *val = 3312; 80 82 return IIO_VAL_INT; 81 83 default: 82 84 return -EINVAL;