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.13b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Merge from Jonathan:

IIO: 2nd set of fixes for the 6.13 cycle.

Given timing so late in cycle and that they are all confined to
specific drivers, it is fine for these to go upstream early in the
6.14 cycle.

hid-sensors
- Handle processed attention channel rather than just returning
an error.
adi,ad3552r
- Fix output ranges for ad3541r and ad3542r.
- Clear the reset status flag so that we can pick up any resets
during operation.
adi,ad5791
- Fix a misleading dt binding example where the sense of the
interrupt was reversed.
adi,ad7606
- Fix some hard coded offsets that should be taking the number of
channels on a particular part into account. These were missed
due to some racing changes.
ams,as73211
- Fix an off by one in optimized path for just reading the colour
channels.
bosch,bme680
- Fix type of variable passed as pointer, ensuring it works on
big endian systems and doesn't expose uninitialized data.

* tag 'iio-fixes-for-6.13b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
iio: dac: ad3552r-hs: clear reset status flag
iio: dac: ad3552r-common: fix ad3541/2r ranges
iio: chemical: bme680: Fix uninitialized variable in __bme680_read_raw()
iio: light: as73211: fix channel handling in only-color triggered buffer
dt-bindings: iio: dac: ad5791: ldac gpio is active low
iio: hid-sensor-prox: Fix invalid read_raw for attention
iio: adc: ad7606: Fix hardcoded offset in the ADC channels

+64 -36
+1 -1
Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml
··· 91 91 vrefn-supply = <&dac_vrefn>; 92 92 reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>; 93 93 clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>; 94 - ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>; 94 + ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_LOW>; 95 95 }; 96 96 }; 97 97 ...
+28 -20
drivers/iio/adc/ad7606.c
··· 175 175 AD7606_CHANNEL(15, 16), 176 176 }; 177 177 178 - static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st, 178 + static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev, 179 179 struct iio_chan_spec *chan, int ch); 180 - static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st, 180 + static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev, 181 181 struct iio_chan_spec *chan, int ch); 182 - static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st, 182 + static int ad7606_16bit_chan_scale_setup(struct iio_dev *indio_dev, 183 183 struct iio_chan_spec *chan, int ch); 184 - static int ad7607_chan_scale_setup(struct ad7606_state *st, 184 + static int ad7607_chan_scale_setup(struct iio_dev *indio_dev, 185 185 struct iio_chan_spec *chan, int ch); 186 - static int ad7608_chan_scale_setup(struct ad7606_state *st, 186 + static int ad7608_chan_scale_setup(struct iio_dev *indio_dev, 187 187 struct iio_chan_spec *chan, int ch); 188 - static int ad7609_chan_scale_setup(struct ad7606_state *st, 188 + static int ad7609_chan_scale_setup(struct iio_dev *indio_dev, 189 189 struct iio_chan_spec *chan, int ch); 190 190 191 191 const struct ad7606_chip_info ad7605_4_info = { ··· 323 323 } 324 324 EXPORT_SYMBOL_NS_GPL(ad7606_reset, "IIO_AD7606"); 325 325 326 - static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st, 326 + static int ad7606_16bit_chan_scale_setup(struct iio_dev *indio_dev, 327 327 struct iio_chan_spec *chan, int ch) 328 328 { 329 + struct ad7606_state *st = iio_priv(indio_dev); 329 330 struct ad7606_chan_scale *cs = &st->chan_scales[ch]; 330 331 331 332 if (!st->sw_mode_en) { ··· 346 345 return 0; 347 346 } 348 347 349 - static int ad7606_get_chan_config(struct ad7606_state *st, int ch, 348 + static int ad7606_get_chan_config(struct iio_dev *indio_dev, int ch, 350 349 bool *bipolar, bool *differential) 351 350 { 352 - unsigned int num_channels = st->chip_info->num_channels - 1; 351 + struct ad7606_state *st = iio_priv(indio_dev); 352 + unsigned int num_channels = st->chip_info->num_adc_channels; 353 + unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels; 353 354 struct device *dev = st->dev; 354 355 int ret; 355 356 ··· 367 364 continue; 368 365 369 366 /* channel number (here) is from 1 to num_channels */ 370 - if (reg == 0 || reg > num_channels) { 367 + if (reg < offset || reg > num_channels) { 371 368 dev_warn(dev, 372 369 "Invalid channel number (ignoring): %d\n", reg); 373 370 continue; ··· 402 399 return 0; 403 400 } 404 401 405 - static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st, 402 + static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev, 406 403 struct iio_chan_spec *chan, int ch) 407 404 { 405 + struct ad7606_state *st = iio_priv(indio_dev); 408 406 struct ad7606_chan_scale *cs = &st->chan_scales[ch]; 409 407 bool bipolar, differential; 410 408 int ret; ··· 417 413 return 0; 418 414 } 419 415 420 - ret = ad7606_get_chan_config(st, ch, &bipolar, &differential); 416 + ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential); 421 417 if (ret) 422 418 return ret; 423 419 ··· 459 455 return 0; 460 456 } 461 457 462 - static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st, 458 + static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev, 463 459 struct iio_chan_spec *chan, int ch) 464 460 { 461 + struct ad7606_state *st = iio_priv(indio_dev); 465 462 struct ad7606_chan_scale *cs = &st->chan_scales[ch]; 466 463 bool bipolar, differential; 467 464 int ret; ··· 474 469 return 0; 475 470 } 476 471 477 - ret = ad7606_get_chan_config(st, ch, &bipolar, &differential); 472 + ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential); 478 473 if (ret) 479 474 return ret; 480 475 ··· 517 512 return 0; 518 513 } 519 514 520 - static int ad7607_chan_scale_setup(struct ad7606_state *st, 515 + static int ad7607_chan_scale_setup(struct iio_dev *indio_dev, 521 516 struct iio_chan_spec *chan, int ch) 522 517 { 518 + struct ad7606_state *st = iio_priv(indio_dev); 523 519 struct ad7606_chan_scale *cs = &st->chan_scales[ch]; 524 520 525 521 cs->range = 0; ··· 529 523 return 0; 530 524 } 531 525 532 - static int ad7608_chan_scale_setup(struct ad7606_state *st, 526 + static int ad7608_chan_scale_setup(struct iio_dev *indio_dev, 533 527 struct iio_chan_spec *chan, int ch) 534 528 { 529 + struct ad7606_state *st = iio_priv(indio_dev); 535 530 struct ad7606_chan_scale *cs = &st->chan_scales[ch]; 536 531 537 532 cs->range = 0; ··· 541 534 return 0; 542 535 } 543 536 544 - static int ad7609_chan_scale_setup(struct ad7606_state *st, 537 + static int ad7609_chan_scale_setup(struct iio_dev *indio_dev, 545 538 struct iio_chan_spec *chan, int ch) 546 539 { 540 + struct ad7606_state *st = iio_priv(indio_dev); 547 541 struct ad7606_chan_scale *cs = &st->chan_scales[ch]; 548 542 549 543 cs->range = 0; ··· 1154 1146 1155 1147 static int ad7606_chan_scales_setup(struct iio_dev *indio_dev) 1156 1148 { 1157 - unsigned int num_channels = indio_dev->num_channels - 1; 1158 1149 struct ad7606_state *st = iio_priv(indio_dev); 1150 + unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels; 1159 1151 struct iio_chan_spec *chans; 1160 1152 size_t size; 1161 1153 int ch, ret; ··· 1169 1161 memcpy(chans, indio_dev->channels, size); 1170 1162 indio_dev->channels = chans; 1171 1163 1172 - for (ch = 0; ch < num_channels; ch++) { 1173 - ret = st->chip_info->scale_setup_cb(st, &chans[ch + 1], ch); 1164 + for (ch = 0; ch < st->chip_info->num_adc_channels; ch++) { 1165 + ret = st->chip_info->scale_setup_cb(indio_dev, &chans[ch + offset], ch); 1174 1166 if (ret) 1175 1167 return ret; 1176 1168 }
+1 -1
drivers/iio/adc/ad7606.h
··· 69 69 70 70 struct ad7606_state; 71 71 72 - typedef int (*ad7606_scale_setup_cb_t)(struct ad7606_state *st, 72 + typedef int (*ad7606_scale_setup_cb_t)(struct iio_dev *indio_dev, 73 73 struct iio_chan_spec *chan, int ch); 74 74 75 75 /**
+2 -2
drivers/iio/chemical/bme680_core.c
··· 879 879 case IIO_CHAN_INFO_RAW: 880 880 switch (chan->type) { 881 881 case IIO_TEMP: 882 - ret = bme680_read_temp(data, (s16 *)&chan_val); 882 + ret = bme680_read_temp(data, &temp_chan_val); 883 883 if (ret) 884 884 return ret; 885 885 886 - *val = chan_val; 886 + *val = temp_chan_val; 887 887 return IIO_VAL_INT; 888 888 case IIO_PRESSURE: 889 889 ret = bme680_read_press(data, &chan_val);
+2 -3
drivers/iio/dac/ad3552r-common.c
··· 22 22 23 23 const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2] = { 24 24 [AD3542R_CH_OUTPUT_RANGE_0__2P5V] = { 0, 2500 }, 25 - [AD3542R_CH_OUTPUT_RANGE_0__3V] = { 0, 3000 }, 26 25 [AD3542R_CH_OUTPUT_RANGE_0__5V] = { 0, 5000 }, 27 26 [AD3542R_CH_OUTPUT_RANGE_0__10V] = { 0, 10000 }, 28 - [AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 }, 29 - [AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 } 27 + [AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 }, 28 + [AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 } 30 29 }; 31 30 EXPORT_SYMBOL_NS_GPL(ad3542r_ch_ranges, "IIO_AD3552R"); 32 31
+6
drivers/iio/dac/ad3552r-hs.c
··· 329 329 dev_info(st->dev, "Chip ID error. Expected 0x%x, Read 0x%x\n", 330 330 AD3552R_ID, id); 331 331 332 + /* Clear reset error flag, see ad3552r manual, rev B table 38. */ 333 + ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_ERR_STATUS, 334 + AD3552R_MASK_RESET_STATUS, 1); 335 + if (ret) 336 + return ret; 337 + 332 338 ret = st->data->bus_reg_write(st->back, 333 339 AD3552R_REG_ADDR_SH_REFERENCE_CONFIG, 334 340 0, 1);
+3 -5
drivers/iio/dac/ad3552r.h
··· 131 131 #define AD3552R_CH1_ACTIVE BIT(1) 132 132 133 133 #define AD3552R_MAX_RANGES 5 134 - #define AD3542R_MAX_RANGES 6 134 + #define AD3542R_MAX_RANGES 5 135 135 #define AD3552R_QUAD_SPI 2 136 136 137 137 extern const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2]; ··· 189 189 enum ad3542r_ch_output_range { 190 190 /* Range from 0 V to 2.5 V. Requires Rfb1x connection */ 191 191 AD3542R_CH_OUTPUT_RANGE_0__2P5V, 192 - /* Range from 0 V to 3 V. Requires Rfb1x connection */ 193 - AD3542R_CH_OUTPUT_RANGE_0__3V, 194 192 /* Range from 0 V to 5 V. Requires Rfb1x connection */ 195 193 AD3542R_CH_OUTPUT_RANGE_0__5V, 196 194 /* Range from 0 V to 10 V. Requires Rfb2x connection */ 197 195 AD3542R_CH_OUTPUT_RANGE_0__10V, 198 - /* Range from -2.5 V to 7.5 V. Requires Rfb2x connection */ 199 - AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V, 200 196 /* Range from -5 V to 5 V. Requires Rfb2x connection */ 201 197 AD3542R_CH_OUTPUT_RANGE_NEG_5__5V, 198 + /* Range from -2.5 V to 7.5 V. Requires Rfb2x connection */ 199 + AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V, 202 200 }; 203 201 204 202 enum ad3552r_ch_output_range {
+20 -4
drivers/iio/light/as73211.c
··· 177 177 BIT(AS73211_SCAN_INDEX_TEMP) | \ 178 178 AS73211_SCAN_MASK_COLOR) 179 179 180 + static const unsigned long as73211_scan_masks[] = { 181 + AS73211_SCAN_MASK_COLOR, 182 + AS73211_SCAN_MASK_ALL, 183 + 0 184 + }; 185 + 180 186 static const struct iio_chan_spec as73211_channels[] = { 181 187 { 182 188 .type = IIO_TEMP, ··· 678 672 679 673 /* AS73211 starts reading at address 2 */ 680 674 ret = i2c_master_recv(data->client, 681 - (char *)&scan.chan[1], 3 * sizeof(scan.chan[1])); 675 + (char *)&scan.chan[0], 3 * sizeof(scan.chan[0])); 682 676 if (ret < 0) 683 677 goto done; 678 + 679 + /* Avoid pushing uninitialized data */ 680 + scan.chan[3] = 0; 684 681 } 685 682 686 683 if (data_result) { ··· 691 682 * Saturate all channels (in case of overflows). Temperature channel 692 683 * is not affected by overflows. 693 684 */ 694 - scan.chan[1] = cpu_to_le16(U16_MAX); 695 - scan.chan[2] = cpu_to_le16(U16_MAX); 696 - scan.chan[3] = cpu_to_le16(U16_MAX); 685 + if (*indio_dev->active_scan_mask == AS73211_SCAN_MASK_ALL) { 686 + scan.chan[1] = cpu_to_le16(U16_MAX); 687 + scan.chan[2] = cpu_to_le16(U16_MAX); 688 + scan.chan[3] = cpu_to_le16(U16_MAX); 689 + } else { 690 + scan.chan[0] = cpu_to_le16(U16_MAX); 691 + scan.chan[1] = cpu_to_le16(U16_MAX); 692 + scan.chan[2] = cpu_to_le16(U16_MAX); 693 + } 697 694 } 698 695 699 696 iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev)); ··· 773 758 indio_dev->channels = data->spec_dev->channels; 774 759 indio_dev->num_channels = data->spec_dev->num_channels; 775 760 indio_dev->modes = INDIO_DIRECT_MODE; 761 + indio_dev->available_scan_masks = as73211_scan_masks; 776 762 777 763 ret = i2c_smbus_read_byte_data(data->client, AS73211_REG_OSR); 778 764 if (ret < 0)
+1
drivers/iio/light/hid-sensor-prox.c
··· 94 94 *val2 = 0; 95 95 switch (mask) { 96 96 case IIO_CHAN_INFO_RAW: 97 + case IIO_CHAN_INFO_PROCESSED: 97 98 if (chan->scan_index >= prox_state->num_channels) 98 99 return -EINVAL; 99 100 address = prox_state->channel2usage[chan->scan_index];