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