Merge tag 'iio-fixes-for-6.13a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus

Jonathan writes:

IIO: 1st set of fixes for 6.13 cycle.

The usual mixed back of fixes for ancient and recent bugs

A number of these were from an audit by Javier Carrasco of places
we may leak stack data via holes in structures passed to userspace that
were not explicitly zeroed. Very helpful effort after we found a similar
bug in review of new code.

This affected:
- dummy driver
- kionix,kmx61
- murrata,zpa2326
- rockchip,saradc
- rohm,bh1745
- veml,vcnl4035
- ti,ads1119
- ti,ads8688
- ti,tmp0006

Other fixes:

core,inkern
- Underflow fo reference count issue in error path of iio_channel_get_all()
for devices we haven't yet gotten.
tests
- Kconfig typo fix so it's possible to tell what test is being enabled.
- Check for allocation failures.

adi,ad4695
- Ensure timing requirement wrt to final clock edge vs next conversion
signal are met by adding an additional SPI transfer.
adi,ad7124
- Ensure channels are disabled at probe to avoid wrong data if channel 0
is not the first one read.
adi,ad7173
- Fix handing of multiple devices by not editing a single static
structure and instead making a per instance copy.
adi,ad9467
- Fix handing of multiple devices by not editing a single static
structure and instead making a per instance copy.
adi,ad9832
- Off by one error on input verification for phase control
adi,ad9834
- Off by one error on input verification for phase control.
atmel,at91
- In an error path don't use a variable that hasn't been initialized yet.
invensense,icm42600
- SPI burst write does not work for some icm426000 chips, disable it.
- Ensure correct handling of timestamps after resume.
st,sensors
- Add back accidentally dropped IIS2MDC compatible in binding doc.
st,stm32-dfsdm:
- label property was accidentally made a required property. Make it optional
again to fix use of older DT.
ti,ads1119
- Use a fixed size for the channel data rather than an integer, bringing
the code inline with the advertised 16 bit channel size and avoiding
userspace misinterpreting the data.
ti,ads124s08
- Use _cansleep gpio calls as no reason to prevent sleeping and it
was stopping a new board design working (trivial fix).
ti,ads1298
- Add a check on failure of devm_kasprintf()

* tag 'iio-fixes-for-6.13a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (27 commits)
iio: adc: ti-ads1119: fix sample size in scan struct for triggered buffer
iio: temperature: tmp006: fix information leak in triggered buffer
iio: inkern: call iio_device_put() only on mapped devices
iio: adc: ad9467: Fix the "don't allow reading vref if not available" case
iio: adc: at91: call input_free_device() on allocated iio_dev
iio: adc: ad7173: fix using shared static info struct
iio: adc: ti-ads124s08: Use gpiod_set_value_cansleep()
iio: adc: ti-ads1119: fix information leak in triggered buffer
iio: pressure: zpa2326: fix information leak in triggered buffer
iio: adc: rockchip_saradc: fix information leak in triggered buffer
iio: imu: kmx61: fix information leak in triggered buffer
iio: light: vcnl4035: fix information leak in triggered buffer
iio: light: bh1745: fix information leak in triggered buffer
iio: adc: ti-ads8688: fix information leak in triggered buffer
iio: dummy: iio_simply_dummy_buffer: fix information leak in triggered buffer
iio: test: Fix GTS test config
dt-bindings: iio: st-sensors: Re-add IIS2MDC magnetometer
iio: adc: ti-ads1298: Add NULL check in ads1298_init
iio: adc: stm32-dfsdm: handle label as an optional property
iio: adc: ad4695: fix buffered read, single sample timings
...

+1
Documentation/devicetree/bindings/iio/st,st-sensors.yaml
··· 65 - st,lsm9ds0-gyro 66 - description: STMicroelectronics Magnetometers 67 enum: 68 - st,lis2mdl 69 - st,lis3mdl-magn 70 - st,lsm303agr-magn
··· 65 - st,lsm9ds0-gyro 66 - description: STMicroelectronics Magnetometers 67 enum: 68 + - st,iis2mdc 69 - st,lis2mdl 70 - st,lis3mdl-magn 71 - st,lsm303agr-magn
+68 -30
drivers/iio/adc/ad4695.c
··· 91 #define AD4695_T_WAKEUP_SW_MS 3 92 #define AD4695_T_REFBUF_MS 100 93 #define AD4695_T_REGCONFIG_NS 20 94 #define AD4695_REG_ACCESS_SCLK_HZ (10 * MEGA) 95 96 /* Max number of voltage input channels. */ ··· 133 unsigned int vref_mv; 134 /* Common mode input pin voltage. */ 135 unsigned int com_mv; 136 - /* 1 per voltage and temperature chan plus 1 xfer to trigger 1st CNV */ 137 - struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS + 2]; 138 struct spi_message buf_read_msg; 139 /* Raw conversion data received. */ 140 u8 buf[ALIGN((AD4695_MAX_CHANNELS + 2) * AD4695_MAX_CHANNEL_SIZE, ··· 429 u8 temp_chan_bit = st->chip_info->num_voltage_inputs; 430 u32 bit, num_xfer, num_slots; 431 u32 temp_en = 0; 432 - int ret; 433 434 /* 435 * We are using the advanced sequencer since it is the only way to read ··· 455 iio_for_each_active_channel(indio_dev, bit) { 456 xfer = &st->buf_read_xfer[num_xfer]; 457 xfer->bits_per_word = 16; 458 - xfer->rx_buf = &st->buf[(num_xfer - 1) * 2]; 459 xfer->len = 2; 460 - xfer->cs_change = 1; 461 - xfer->cs_change_delay.value = AD4695_T_CONVERT_NS; 462 - xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS; 463 464 if (bit == temp_chan_bit) { 465 temp_en = 1; ··· 472 } 473 474 num_xfer++; 475 } 476 477 /* 478 * The advanced sequencer requires that at least 2 slots are enabled. 479 * Since slot 0 is always used for other purposes, we need only 1 480 - * enabled voltage channel to meet this requirement. If the temperature 481 - * channel is the only enabled channel, we need to add one more slot 482 - * in the sequence but not read from it. 483 */ 484 if (num_slots < 2) { 485 - /* move last xfer so we can insert one more xfer before it */ 486 - st->buf_read_xfer[num_xfer] = *xfer; 487 num_xfer++; 488 489 - /* modify 2nd to last xfer for extra slot */ 490 memset(xfer, 0, sizeof(*xfer)); 491 xfer->cs_change = 1; 492 xfer->delay.value = st->chip_info->t_acq_ns; ··· 526 return ret; 527 528 num_slots++; 529 } 530 531 /* ··· 616 */ 617 static int ad4695_read_one_sample(struct ad4695_state *st, unsigned int address) 618 { 619 - struct spi_transfer xfer[2] = { }; 620 - int ret, i = 0; 621 622 ret = ad4695_set_single_cycle_mode(st, address); 623 if (ret) ··· 637 638 /* 639 * Setting the first channel to the temperature channel isn't supported 640 - * in single-cycle mode, so we have to do an extra xfer to read the 641 - * temperature. 642 */ 643 if (address == AD4695_CMD_TEMP_CHAN) { 644 - /* We aren't reading, so we can make this a short xfer. */ 645 - st->cnv_cmd2 = AD4695_CMD_TEMP_CHAN << 3; 646 - xfer[0].tx_buf = &st->cnv_cmd2; 647 - xfer[0].len = 1; 648 - xfer[0].cs_change = 1; 649 - xfer[0].cs_change_delay.value = AD4695_T_CONVERT_NS; 650 - xfer[0].cs_change_delay.unit = SPI_DELAY_UNIT_NSECS; 651 652 - i = 1; 653 } 654 655 /* Then read the result and exit conversion mode. */ 656 st->cnv_cmd = AD4695_CMD_EXIT_CNV_MODE << 11; 657 - xfer[i].bits_per_word = 16; 658 - xfer[i].tx_buf = &st->cnv_cmd; 659 - xfer[i].rx_buf = &st->raw_data; 660 - xfer[i].len = 2; 661 662 - return spi_sync_transfer(st->spi, xfer, i + 1); 663 } 664 665 static int ad4695_read_raw(struct iio_dev *indio_dev,
··· 91 #define AD4695_T_WAKEUP_SW_MS 3 92 #define AD4695_T_REFBUF_MS 100 93 #define AD4695_T_REGCONFIG_NS 20 94 + #define AD4695_T_SCK_CNV_DELAY_NS 80 95 #define AD4695_REG_ACCESS_SCLK_HZ (10 * MEGA) 96 97 /* Max number of voltage input channels. */ ··· 132 unsigned int vref_mv; 133 /* Common mode input pin voltage. */ 134 unsigned int com_mv; 135 + /* 136 + * 2 per voltage and temperature chan plus 1 xfer to trigger 1st 137 + * CNV. Excluding the trigger xfer, every 2nd xfer only serves 138 + * to control CS and add a delay between the last SCLK and next 139 + * CNV rising edges. 140 + */ 141 + struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3]; 142 struct spi_message buf_read_msg; 143 /* Raw conversion data received. */ 144 u8 buf[ALIGN((AD4695_MAX_CHANNELS + 2) * AD4695_MAX_CHANNEL_SIZE, ··· 423 u8 temp_chan_bit = st->chip_info->num_voltage_inputs; 424 u32 bit, num_xfer, num_slots; 425 u32 temp_en = 0; 426 + int ret, rx_buf_offset = 0; 427 428 /* 429 * We are using the advanced sequencer since it is the only way to read ··· 449 iio_for_each_active_channel(indio_dev, bit) { 450 xfer = &st->buf_read_xfer[num_xfer]; 451 xfer->bits_per_word = 16; 452 + xfer->rx_buf = &st->buf[rx_buf_offset]; 453 xfer->len = 2; 454 + rx_buf_offset += xfer->len; 455 456 if (bit == temp_chan_bit) { 457 temp_en = 1; ··· 468 } 469 470 num_xfer++; 471 + 472 + /* 473 + * We need to add a blank xfer in data reads, to meet the timing 474 + * requirement of a minimum delay between the last SCLK rising 475 + * edge and the CS deassert. 476 + */ 477 + xfer = &st->buf_read_xfer[num_xfer]; 478 + xfer->delay.value = AD4695_T_SCK_CNV_DELAY_NS; 479 + xfer->delay.unit = SPI_DELAY_UNIT_NSECS; 480 + xfer->cs_change = 1; 481 + xfer->cs_change_delay.value = AD4695_T_CONVERT_NS; 482 + xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS; 483 + 484 + num_xfer++; 485 } 486 487 /* 488 * The advanced sequencer requires that at least 2 slots are enabled. 489 * Since slot 0 is always used for other purposes, we need only 1 490 + * enabled voltage channel to meet this requirement. If the temperature 491 + * channel is the only enabled channel, we need to add one more slot in 492 + * the sequence but not read from it. This is because the temperature 493 + * sensor is sampled at the end of the channel sequence in advanced 494 + * sequencer mode (see datasheet page 38). 495 + * 496 + * From the iio_for_each_active_channel() block above, we now have an 497 + * xfer with data followed by a blank xfer to allow us to meet the 498 + * timing spec, so move both of those up before adding an extra to 499 + * handle the temperature-only case. 500 */ 501 if (num_slots < 2) { 502 + /* Move last two xfers */ 503 + st->buf_read_xfer[num_xfer] = st->buf_read_xfer[num_xfer - 1]; 504 + st->buf_read_xfer[num_xfer - 1] = st->buf_read_xfer[num_xfer - 2]; 505 num_xfer++; 506 507 + /* Modify inserted xfer for extra slot. */ 508 + xfer = &st->buf_read_xfer[num_xfer - 3]; 509 memset(xfer, 0, sizeof(*xfer)); 510 xfer->cs_change = 1; 511 xfer->delay.value = st->chip_info->t_acq_ns; ··· 499 return ret; 500 501 num_slots++; 502 + 503 + /* 504 + * We still want to point at the last xfer when finished, so 505 + * update the pointer. 506 + */ 507 + xfer = &st->buf_read_xfer[num_xfer - 1]; 508 } 509 510 /* ··· 583 */ 584 static int ad4695_read_one_sample(struct ad4695_state *st, unsigned int address) 585 { 586 + struct spi_transfer xfers[2] = { 587 + { 588 + .speed_hz = AD4695_REG_ACCESS_SCLK_HZ, 589 + .bits_per_word = 16, 590 + .tx_buf = &st->cnv_cmd, 591 + .len = 2, 592 + }, 593 + { 594 + /* Required delay between last SCLK and CNV/CS */ 595 + .delay.value = AD4695_T_SCK_CNV_DELAY_NS, 596 + .delay.unit = SPI_DELAY_UNIT_NSECS, 597 + } 598 + }; 599 + int ret; 600 601 ret = ad4695_set_single_cycle_mode(st, address); 602 if (ret) ··· 592 593 /* 594 * Setting the first channel to the temperature channel isn't supported 595 + * in single-cycle mode, so we have to do an extra conversion to read 596 + * the temperature. 597 */ 598 if (address == AD4695_CMD_TEMP_CHAN) { 599 + st->cnv_cmd = AD4695_CMD_TEMP_CHAN << 11; 600 601 + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); 602 + if (ret) 603 + return ret; 604 } 605 606 /* Then read the result and exit conversion mode. */ 607 st->cnv_cmd = AD4695_CMD_EXIT_CNV_MODE << 11; 608 + xfers[0].rx_buf = &st->raw_data; 609 610 + return spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); 611 } 612 613 static int ad4695_read_raw(struct iio_dev *indio_dev,
+3
drivers/iio/adc/ad7124.c
··· 917 * set all channels to this default value. 918 */ 919 ad7124_set_channel_odr(st, i, 10); 920 } 921 922 ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);
··· 917 * set all channels to this default value. 918 */ 919 ad7124_set_channel_odr(st, i, 10); 920 + 921 + /* Disable all channels to prevent unintended conversions. */ 922 + ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, 0); 923 } 924 925 ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);
+6 -4
drivers/iio/adc/ad7173.c
··· 200 201 struct ad7173_state { 202 struct ad_sigma_delta sd; 203 const struct ad7173_device_info *info; 204 struct ad7173_channel *channels; 205 struct regulator_bulk_data regulators[3]; ··· 754 return ad_sd_write_reg(sd, AD7173_REG_CH(chan), 2, 0); 755 } 756 757 - static struct ad_sigma_delta_info ad7173_sigma_delta_info = { 758 .set_channel = ad7173_set_channel, 759 .append_status = ad7173_append_status, 760 .disable_all = ad7173_disable_all, ··· 1404 if (ret < 0) 1405 return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n"); 1406 1407 - ad7173_sigma_delta_info.irq_line = ret; 1408 1409 return ad7173_fw_parse_channel_config(indio_dev); 1410 } ··· 1437 spi->mode = SPI_MODE_3; 1438 spi_setup(spi); 1439 1440 - ad7173_sigma_delta_info.num_slots = st->info->num_configs; 1441 - ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7173_sigma_delta_info); 1442 if (ret) 1443 return ret; 1444
··· 200 201 struct ad7173_state { 202 struct ad_sigma_delta sd; 203 + struct ad_sigma_delta_info sigma_delta_info; 204 const struct ad7173_device_info *info; 205 struct ad7173_channel *channels; 206 struct regulator_bulk_data regulators[3]; ··· 753 return ad_sd_write_reg(sd, AD7173_REG_CH(chan), 2, 0); 754 } 755 756 + static const struct ad_sigma_delta_info ad7173_sigma_delta_info = { 757 .set_channel = ad7173_set_channel, 758 .append_status = ad7173_append_status, 759 .disable_all = ad7173_disable_all, ··· 1403 if (ret < 0) 1404 return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n"); 1405 1406 + st->sigma_delta_info.irq_line = ret; 1407 1408 return ad7173_fw_parse_channel_config(indio_dev); 1409 } ··· 1436 spi->mode = SPI_MODE_3; 1437 spi_setup(spi); 1438 1439 + st->sigma_delta_info = ad7173_sigma_delta_info; 1440 + st->sigma_delta_info.num_slots = st->info->num_configs; 1441 + ret = ad_sd_init(&st->sd, indio_dev, spi, &st->sigma_delta_info); 1442 if (ret) 1443 return ret; 1444
+12 -3
drivers/iio/adc/ad9467.c
··· 895 return 0; 896 } 897 898 - static struct iio_info ad9467_info = { 899 .read_raw = ad9467_read_raw, 900 .write_raw = ad9467_write_raw, 901 .update_scan_mode = ad9467_update_scan_mode, 902 .debugfs_reg_access = ad9467_reg_access, 903 .read_avail = ad9467_read_avail, 904 }; 905 906 static int ad9467_scale_fill(struct ad9467_state *st) ··· 1222 } 1223 1224 if (st->info->num_scales > 1) 1225 - ad9467_info.read_avail = ad9467_read_avail; 1226 indio_dev->name = st->info->name; 1227 indio_dev->channels = st->info->channels; 1228 indio_dev->num_channels = st->info->num_channels; 1229 - indio_dev->info = &ad9467_info; 1230 1231 ret = ad9467_iio_backend_get(st); 1232 if (ret)
··· 895 return 0; 896 } 897 898 + static const struct iio_info ad9467_info = { 899 .read_raw = ad9467_read_raw, 900 .write_raw = ad9467_write_raw, 901 .update_scan_mode = ad9467_update_scan_mode, 902 .debugfs_reg_access = ad9467_reg_access, 903 .read_avail = ad9467_read_avail, 904 + }; 905 + 906 + /* Same as above, but without .read_avail */ 907 + static const struct iio_info ad9467_info_no_read_avail = { 908 + .read_raw = ad9467_read_raw, 909 + .write_raw = ad9467_write_raw, 910 + .update_scan_mode = ad9467_update_scan_mode, 911 + .debugfs_reg_access = ad9467_reg_access, 912 }; 913 914 static int ad9467_scale_fill(struct ad9467_state *st) ··· 1214 } 1215 1216 if (st->info->num_scales > 1) 1217 + indio_dev->info = &ad9467_info; 1218 + else 1219 + indio_dev->info = &ad9467_info_no_read_avail; 1220 indio_dev->name = st->info->name; 1221 indio_dev->channels = st->info->channels; 1222 indio_dev->num_channels = st->info->num_channels; 1223 1224 ret = ad9467_iio_backend_get(st); 1225 if (ret)
+1 -1
drivers/iio/adc/at91_adc.c
··· 979 return ret; 980 981 err: 982 - input_free_device(st->ts_input); 983 return ret; 984 } 985
··· 979 return ret; 980 981 err: 982 + input_free_device(input); 983 return ret; 984 } 985
+2
drivers/iio/adc/rockchip_saradc.c
··· 368 int ret; 369 int i, j = 0; 370 371 mutex_lock(&info->lock); 372 373 iio_for_each_active_channel(i_dev, i) {
··· 368 int ret; 369 int i, j = 0; 370 371 + memset(&data, 0, sizeof(data)); 372 + 373 mutex_lock(&info->lock); 374 375 iio_for_each_active_channel(i_dev, i) {
+8 -5
drivers/iio/adc/stm32-dfsdm-adc.c
··· 691 return -EINVAL; 692 } 693 694 - ret = fwnode_property_read_string(node, "label", &ch->datasheet_name); 695 - if (ret < 0) { 696 - dev_err(&indio_dev->dev, 697 - " Error parsing 'label' for idx %d\n", ch->channel); 698 - return ret; 699 } 700 701 df_ch = &dfsdm->ch_list[ch->channel];
··· 691 return -EINVAL; 692 } 693 694 + if (fwnode_property_present(node, "label")) { 695 + /* label is optional */ 696 + ret = fwnode_property_read_string(node, "label", &ch->datasheet_name); 697 + if (ret < 0) { 698 + dev_err(&indio_dev->dev, 699 + " Error parsing 'label' for idx %d\n", ch->channel); 700 + return ret; 701 + } 702 } 703 704 df_ch = &dfsdm->ch_list[ch->channel];
+3 -1
drivers/iio/adc/ti-ads1119.c
··· 500 struct iio_dev *indio_dev = pf->indio_dev; 501 struct ads1119_state *st = iio_priv(indio_dev); 502 struct { 503 - unsigned int sample; 504 s64 timestamp __aligned(8); 505 } scan; 506 unsigned int index; 507 int ret; 508 509 if (!iio_trigger_using_own(indio_dev)) { 510 index = find_first_bit(indio_dev->active_scan_mask,
··· 500 struct iio_dev *indio_dev = pf->indio_dev; 501 struct ads1119_state *st = iio_priv(indio_dev); 502 struct { 503 + s16 sample; 504 s64 timestamp __aligned(8); 505 } scan; 506 unsigned int index; 507 int ret; 508 + 509 + memset(&scan, 0, sizeof(scan)); 510 511 if (!iio_trigger_using_own(indio_dev)) { 512 index = find_first_bit(indio_dev->active_scan_mask,
+2 -2
drivers/iio/adc/ti-ads124s08.c
··· 183 struct ads124s_private *priv = iio_priv(indio_dev); 184 185 if (priv->reset_gpio) { 186 - gpiod_set_value(priv->reset_gpio, 0); 187 udelay(200); 188 - gpiod_set_value(priv->reset_gpio, 1); 189 } else { 190 return ads124s_write_cmd(indio_dev, ADS124S08_CMD_RESET); 191 }
··· 183 struct ads124s_private *priv = iio_priv(indio_dev); 184 185 if (priv->reset_gpio) { 186 + gpiod_set_value_cansleep(priv->reset_gpio, 0); 187 udelay(200); 188 + gpiod_set_value_cansleep(priv->reset_gpio, 1); 189 } else { 190 return ads124s_write_cmd(indio_dev, ADS124S08_CMD_RESET); 191 }
+2
drivers/iio/adc/ti-ads1298.c
··· 613 } 614 indio_dev->name = devm_kasprintf(dev, GFP_KERNEL, "ads129%u%s", 615 indio_dev->num_channels, suffix); 616 617 /* Enable internal test signal, double amplitude, double frequency */ 618 ret = regmap_write(priv->regmap, ADS1298_REG_CONFIG2,
··· 613 } 614 indio_dev->name = devm_kasprintf(dev, GFP_KERNEL, "ads129%u%s", 615 indio_dev->num_channels, suffix); 616 + if (!indio_dev->name) 617 + return -ENOMEM; 618 619 /* Enable internal test signal, double amplitude, double frequency */ 620 ret = regmap_write(priv->regmap, ADS1298_REG_CONFIG2,
+1 -1
drivers/iio/adc/ti-ads8688.c
··· 381 struct iio_poll_func *pf = p; 382 struct iio_dev *indio_dev = pf->indio_dev; 383 /* Ensure naturally aligned timestamp */ 384 - u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8); 385 int i, j = 0; 386 387 iio_for_each_active_channel(indio_dev, i) {
··· 381 struct iio_poll_func *pf = p; 382 struct iio_dev *indio_dev = pf->indio_dev; 383 /* Ensure naturally aligned timestamp */ 384 + u16 buffer[ADS8688_MAX_CHANNELS + sizeof(s64)/sizeof(u16)] __aligned(8) = { }; 385 int i, j = 0; 386 387 iio_for_each_active_channel(indio_dev, i) {
+1 -1
drivers/iio/dummy/iio_simple_dummy_buffer.c
··· 48 int i = 0, j; 49 u16 *data; 50 51 - data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); 52 if (!data) 53 goto done; 54
··· 48 int i = 0, j; 49 u16 *data; 50 51 + data = kzalloc(indio_dev->scan_bytes, GFP_KERNEL); 52 if (!data) 53 goto done; 54
+9 -2
drivers/iio/gyro/fxas21002c_core.c
··· 730 int ret; 731 732 mutex_lock(&data->lock); 733 - ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB, 734 - data->buffer, CHANNEL_SCAN_MAX * sizeof(s16)); 735 if (ret < 0) 736 goto out_unlock; 737 738 iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, 739 data->timestamp); 740 741 out_unlock: 742 mutex_unlock(&data->lock);
··· 730 int ret; 731 732 mutex_lock(&data->lock); 733 + ret = fxas21002c_pm_get(data); 734 if (ret < 0) 735 goto out_unlock; 736 737 + ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB, 738 + data->buffer, CHANNEL_SCAN_MAX * sizeof(s16)); 739 + if (ret < 0) 740 + goto out_pm_put; 741 + 742 iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, 743 data->timestamp); 744 + 745 + out_pm_put: 746 + fxas21002c_pm_put(data); 747 748 out_unlock: 749 mutex_unlock(&data->lock);
+1
drivers/iio/imu/inv_icm42600/inv_icm42600.h
··· 403 typedef int (*inv_icm42600_bus_setup)(struct inv_icm42600_state *); 404 405 extern const struct regmap_config inv_icm42600_regmap_config; 406 extern const struct dev_pm_ops inv_icm42600_pm_ops; 407 408 const struct iio_mount_matrix *
··· 403 typedef int (*inv_icm42600_bus_setup)(struct inv_icm42600_state *); 404 405 extern const struct regmap_config inv_icm42600_regmap_config; 406 + extern const struct regmap_config inv_icm42600_spi_regmap_config; 407 extern const struct dev_pm_ops inv_icm42600_pm_ops; 408 409 const struct iio_mount_matrix *
+21 -1
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
··· 87 }; 88 EXPORT_SYMBOL_NS_GPL(inv_icm42600_regmap_config, "IIO_ICM42600"); 89 90 struct inv_icm42600_hw { 91 uint8_t whoami; 92 const char *name; ··· 829 static int inv_icm42600_resume(struct device *dev) 830 { 831 struct inv_icm42600_state *st = dev_get_drvdata(dev); 832 int ret; 833 834 mutex_lock(&st->lock); ··· 851 goto out_unlock; 852 853 /* restore FIFO data streaming */ 854 - if (st->fifo.on) 855 ret = regmap_write(st->map, INV_ICM42600_REG_FIFO_CONFIG, 856 INV_ICM42600_FIFO_CONFIG_STREAM); 857 858 out_unlock: 859 mutex_unlock(&st->lock);
··· 87 }; 88 EXPORT_SYMBOL_NS_GPL(inv_icm42600_regmap_config, "IIO_ICM42600"); 89 90 + /* define specific regmap for SPI not supporting burst write */ 91 + const struct regmap_config inv_icm42600_spi_regmap_config = { 92 + .name = "inv_icm42600", 93 + .reg_bits = 8, 94 + .val_bits = 8, 95 + .max_register = 0x4FFF, 96 + .ranges = inv_icm42600_regmap_ranges, 97 + .num_ranges = ARRAY_SIZE(inv_icm42600_regmap_ranges), 98 + .volatile_table = inv_icm42600_regmap_volatile_accesses, 99 + .rd_noinc_table = inv_icm42600_regmap_rd_noinc_accesses, 100 + .cache_type = REGCACHE_RBTREE, 101 + .use_single_write = true, 102 + }; 103 + EXPORT_SYMBOL_NS_GPL(inv_icm42600_spi_regmap_config, "IIO_ICM42600"); 104 + 105 struct inv_icm42600_hw { 106 uint8_t whoami; 107 const char *name; ··· 814 static int inv_icm42600_resume(struct device *dev) 815 { 816 struct inv_icm42600_state *st = dev_get_drvdata(dev); 817 + struct inv_icm42600_sensor_state *gyro_st = iio_priv(st->indio_gyro); 818 + struct inv_icm42600_sensor_state *accel_st = iio_priv(st->indio_accel); 819 int ret; 820 821 mutex_lock(&st->lock); ··· 834 goto out_unlock; 835 836 /* restore FIFO data streaming */ 837 + if (st->fifo.on) { 838 + inv_sensors_timestamp_reset(&gyro_st->ts); 839 + inv_sensors_timestamp_reset(&accel_st->ts); 840 ret = regmap_write(st->map, INV_ICM42600_REG_FIFO_CONFIG, 841 INV_ICM42600_FIFO_CONFIG_STREAM); 842 + } 843 844 out_unlock: 845 mutex_unlock(&st->lock);
+2 -1
drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
··· 59 return -EINVAL; 60 chip = (uintptr_t)match; 61 62 - regmap = devm_regmap_init_spi(spi, &inv_icm42600_regmap_config); 63 if (IS_ERR(regmap)) 64 return PTR_ERR(regmap); 65
··· 59 return -EINVAL; 60 chip = (uintptr_t)match; 61 62 + /* use SPI specific regmap */ 63 + regmap = devm_regmap_init_spi(spi, &inv_icm42600_spi_regmap_config); 64 if (IS_ERR(regmap)) 65 return PTR_ERR(regmap); 66
+1 -1
drivers/iio/imu/kmx61.c
··· 1193 struct kmx61_data *data = kmx61_get_data(indio_dev); 1194 int bit, ret, i = 0; 1195 u8 base; 1196 - s16 buffer[8]; 1197 1198 if (indio_dev == data->acc_indio_dev) 1199 base = KMX61_ACC_XOUT_L;
··· 1193 struct kmx61_data *data = kmx61_get_data(indio_dev); 1194 int bit, ret, i = 0; 1195 u8 base; 1196 + s16 buffer[8] = { }; 1197 1198 if (indio_dev == data->acc_indio_dev) 1199 base = KMX61_ACC_XOUT_L;
+1 -1
drivers/iio/inkern.c
··· 500 return_ptr(chans); 501 502 error_free_chans: 503 - for (i = 0; i < nummaps; i++) 504 iio_device_put(chans[i].indio_dev); 505 return ERR_PTR(ret); 506 }
··· 500 return_ptr(chans); 501 502 error_free_chans: 503 + for (i = 0; i < mapind; i++) 504 iio_device_put(chans[i].indio_dev); 505 return ERR_PTR(ret); 506 }
+2
drivers/iio/light/bh1745.c
··· 746 int i; 747 int j = 0; 748 749 iio_for_each_active_channel(indio_dev, i) { 750 ret = regmap_bulk_read(data->regmap, BH1745_RED_LSB + 2 * i, 751 &value, 2);
··· 746 int i; 747 int j = 0; 748 749 + memset(&scan, 0, sizeof(scan)); 750 + 751 iio_for_each_active_channel(indio_dev, i) { 752 ret = regmap_bulk_read(data->regmap, BH1745_RED_LSB + 2 * i, 753 &value, 2);
+1 -1
drivers/iio/light/vcnl4035.c
··· 105 struct iio_dev *indio_dev = pf->indio_dev; 106 struct vcnl4035_data *data = iio_priv(indio_dev); 107 /* Ensure naturally aligned timestamp */ 108 - u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8); 109 int ret; 110 111 ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer);
··· 105 struct iio_dev *indio_dev = pf->indio_dev; 106 struct vcnl4035_data *data = iio_priv(indio_dev); 107 /* Ensure naturally aligned timestamp */ 108 + u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)] __aligned(8) = { }; 109 int ret; 110 111 ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer);
+2
drivers/iio/pressure/zpa2326.c
··· 586 } sample; 587 int err; 588 589 if (test_bit(0, indio_dev->active_scan_mask)) { 590 /* Get current pressure from hardware FIFO. */ 591 err = zpa2326_dequeue_pressure(indio_dev, &sample.pressure);
··· 586 } sample; 587 int err; 588 589 + memset(&sample, 0, sizeof(sample)); 590 + 591 if (test_bit(0, indio_dev->active_scan_mask)) { 592 /* Get current pressure from hardware FIFO. */ 593 err = zpa2326_dequeue_pressure(indio_dev, &sample.pressure);
+2
drivers/iio/temperature/tmp006.c
··· 252 } scan; 253 s32 ret; 254 255 ret = i2c_smbus_read_word_data(data->client, TMP006_VOBJECT); 256 if (ret < 0) 257 goto err;
··· 252 } scan; 253 s32 ret; 254 255 + memset(&scan, 0, sizeof(scan)); 256 + 257 ret = i2c_smbus_read_word_data(data->client, TMP006_VOBJECT); 258 if (ret < 0) 259 goto err;
+1 -1
drivers/iio/test/Kconfig
··· 5 6 # Keep in alphabetical order 7 config IIO_GTS_KUNIT_TEST 8 - tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS 9 depends on KUNIT 10 select IIO_GTS_HELPER 11 select TEST_KUNIT_DEVICE_HELPERS
··· 5 6 # Keep in alphabetical order 7 config IIO_GTS_KUNIT_TEST 8 + tristate "Test IIO gain-time-scale helpers" if !KUNIT_ALL_TESTS 9 depends on KUNIT 10 select IIO_GTS_HELPER 11 select TEST_KUNIT_DEVICE_HELPERS
+4
drivers/iio/test/iio-test-rescale.c
··· 652 int rel_ppm; 653 int ret; 654 655 rescale.numerator = t->numerator; 656 rescale.denominator = t->denominator; 657 rescale.offset = t->offset; ··· 682 struct rescale rescale; 683 int values[2]; 684 int ret; 685 686 rescale.numerator = t->numerator; 687 rescale.denominator = t->denominator;
··· 652 int rel_ppm; 653 int ret; 654 655 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff); 656 + 657 rescale.numerator = t->numerator; 658 rescale.denominator = t->denominator; 659 rescale.offset = t->offset; ··· 680 struct rescale rescale; 681 int values[2]; 682 int ret; 683 + 684 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff_off); 685 686 rescale.numerator = t->numerator; 687 rescale.denominator = t->denominator;
+1 -1
drivers/staging/iio/frequency/ad9832.c
··· 158 static int ad9832_write_phase(struct ad9832_state *st, 159 unsigned long addr, unsigned long phase) 160 { 161 - if (phase > BIT(AD9832_PHASE_BITS)) 162 return -EINVAL; 163 164 st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
··· 158 static int ad9832_write_phase(struct ad9832_state *st, 159 unsigned long addr, unsigned long phase) 160 { 161 + if (phase >= BIT(AD9832_PHASE_BITS)) 162 return -EINVAL; 163 164 st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
+1 -1
drivers/staging/iio/frequency/ad9834.c
··· 131 static int ad9834_write_phase(struct ad9834_state *st, 132 unsigned long addr, unsigned long phase) 133 { 134 - if (phase > BIT(AD9834_PHASE_BITS)) 135 return -EINVAL; 136 st->data = cpu_to_be16(addr | phase); 137
··· 131 static int ad9834_write_phase(struct ad9834_state *st, 132 unsigned long addr, unsigned long phase) 133 { 134 + if (phase >= BIT(AD9834_PHASE_BITS)) 135 return -EINVAL; 136 st->data = cpu_to_be16(addr | phase); 137