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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'char-misc-6.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc/iio fixes from Greg KH:
"Here are a small number of char/misc/iio and other driver fixes for
6.17-rc3. Included in here are:

- IIO driver bugfixes for reported issues

- bunch of comedi driver fixes

- most core bugfix

- fpga driver bugfix

- cdx driver bugfix

All of these have been in linux-next this week with no reported
issues"

* tag 'char-misc-6.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
most: core: Drop device reference after usage in get_channel()
comedi: Make insn_rw_emulate_bits() do insn->n samples
comedi: Fix use of uninitialized memory in do_insn_ioctl() and do_insnlist_ioctl()
comedi: pcl726: Prevent invalid irq number
cdx: Fix off-by-one error in cdx_rpmsg_probe()
fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable()
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
iio: light: as73211: Ensure buffer holes are zeroed
iio: adc: rzg2l_adc: Set driver data before enabling runtime PM
iio: adc: rzg2l: Cleanup suspend/resume path
iio: adc: ad7380: fix missing max_conversion_rate_hz on adaq4381-4
iio: adc: bd79124: Add GPIOLIB dependency
iio: imu: inv_icm42600: change invalid data error to -EBUSY
iio: adc: ad7124: fix channel lookup in syscalib functions
iio: temperature: maxim_thermocouple: use DMA-safe buffer for spi_read()
iio: adc: ad7173: prevent scan if too many setups requested
iio: proximity: isl29501: fix buffered read on big-endian systems
iio: accel: sca3300: fix uninitialized iio scan data

+159 -85
+1 -2
drivers/cdx/controller/cdx_rpmsg.c
··· 129 129 130 130 chinfo.src = RPMSG_ADDR_ANY; 131 131 chinfo.dst = rpdev->dst; 132 - strscpy(chinfo.name, cdx_rpmsg_id_table[0].name, 133 - strlen(cdx_rpmsg_id_table[0].name)); 132 + strscpy(chinfo.name, cdx_rpmsg_id_table[0].name, sizeof(chinfo.name)); 134 133 135 134 cdx_mcdi->ept = rpmsg_create_ept(rpdev, cdx_rpmsg_cb, NULL, chinfo); 136 135 if (!cdx_mcdi->ept) {
+5
drivers/comedi/comedi_fops.c
··· 1587 1587 memset(&data[n], 0, (MIN_SAMPLES - n) * 1588 1588 sizeof(unsigned int)); 1589 1589 } 1590 + } else { 1591 + memset(data, 0, max_t(unsigned int, n, MIN_SAMPLES) * 1592 + sizeof(unsigned int)); 1590 1593 } 1591 1594 ret = parse_insn(dev, insns + i, data, file); 1592 1595 if (ret < 0) ··· 1673 1670 memset(&data[insn->n], 0, 1674 1671 (MIN_SAMPLES - insn->n) * sizeof(unsigned int)); 1675 1672 } 1673 + } else { 1674 + memset(data, 0, n_data * sizeof(unsigned int)); 1676 1675 } 1677 1676 ret = parse_insn(dev, insn, data, file); 1678 1677 if (ret < 0)
+14 -13
drivers/comedi/drivers.c
··· 620 620 unsigned int chan = CR_CHAN(insn->chanspec); 621 621 unsigned int base_chan = (chan < 32) ? 0 : chan; 622 622 unsigned int _data[2]; 623 + unsigned int i; 623 624 int ret; 624 - 625 - if (insn->n == 0) 626 - return 0; 627 625 628 626 memset(_data, 0, sizeof(_data)); 629 627 memset(&_insn, 0, sizeof(_insn)); ··· 633 635 if (insn->insn == INSN_WRITE) { 634 636 if (!(s->subdev_flags & SDF_WRITABLE)) 635 637 return -EINVAL; 636 - _data[0] = 1U << (chan - base_chan); /* mask */ 637 - _data[1] = data[0] ? (1U << (chan - base_chan)) : 0; /* bits */ 638 + _data[0] = 1U << (chan - base_chan); /* mask */ 639 + } 640 + for (i = 0; i < insn->n; i++) { 641 + if (insn->insn == INSN_WRITE) 642 + _data[1] = data[i] ? _data[0] : 0; /* bits */ 643 + 644 + ret = s->insn_bits(dev, s, &_insn, _data); 645 + if (ret < 0) 646 + return ret; 647 + 648 + if (insn->insn == INSN_READ) 649 + data[i] = (_data[1] >> (chan - base_chan)) & 1; 638 650 } 639 651 640 - ret = s->insn_bits(dev, s, &_insn, _data); 641 - if (ret < 0) 642 - return ret; 643 - 644 - if (insn->insn == INSN_READ) 645 - data[0] = (_data[1] >> (chan - base_chan)) & 1; 646 - 647 - return 1; 652 + return insn->n; 648 653 } 649 654 650 655 static int __comedi_device_postconfig_async(struct comedi_device *dev,
+2 -1
drivers/comedi/drivers/pcl726.c
··· 328 328 * Hook up the external trigger source interrupt only if the 329 329 * user config option is valid and the board supports interrupts. 330 330 */ 331 - if (it->options[1] && (board->irq_mask & (1 << it->options[1]))) { 331 + if (it->options[1] > 0 && it->options[1] < 16 && 332 + (board->irq_mask & (1U << it->options[1]))) { 332 333 ret = request_irq(it->options[1], pcl726_interrupt, 0, 333 334 dev->board_name, dev); 334 335 if (ret == 0) {
+4 -4
drivers/fpga/zynq-fpga.c
··· 405 405 } 406 406 } 407 407 408 - priv->dma_nelms = 409 - dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0); 410 - if (priv->dma_nelms == 0) { 408 + err = dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0); 409 + if (err) { 411 410 dev_err(&mgr->dev, "Unable to DMA map (TO_DEVICE)\n"); 412 - return -ENOMEM; 411 + return err; 413 412 } 413 + priv->dma_nelms = sgt->nents; 414 414 415 415 /* enable clock */ 416 416 err = clk_enable(priv->clk);
+1 -1
drivers/iio/accel/sca3300.c
··· 477 477 struct iio_dev *indio_dev = pf->indio_dev; 478 478 struct sca3300_data *data = iio_priv(indio_dev); 479 479 int bit, ret, val, i = 0; 480 - IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX); 480 + IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX) = { }; 481 481 482 482 iio_for_each_active_channel(indio_dev, bit) { 483 483 ret = sca3300_read_reg(data, indio_dev->channels[bit].address, &val);
+1 -1
drivers/iio/adc/Kconfig
··· 1300 1300 1301 1301 config ROHM_BD79124 1302 1302 tristate "Rohm BD79124 ADC driver" 1303 - depends on I2C 1303 + depends on I2C && GPIOLIB 1304 1304 select REGMAP_I2C 1305 1305 select IIO_ADC_HELPER 1306 1306 help
+7 -7
drivers/iio/adc/ad7124.c
··· 849 849 static int ad7124_syscalib_locked(struct ad7124_state *st, const struct iio_chan_spec *chan) 850 850 { 851 851 struct device *dev = &st->sd.spi->dev; 852 - struct ad7124_channel *ch = &st->channels[chan->channel]; 852 + struct ad7124_channel *ch = &st->channels[chan->address]; 853 853 int ret; 854 854 855 855 if (ch->syscalib_mode == AD7124_SYSCALIB_ZERO_SCALE) { ··· 865 865 if (ret < 0) 866 866 return ret; 867 867 868 - dev_dbg(dev, "offset for channel %d after zero-scale calibration: 0x%x\n", 869 - chan->channel, ch->cfg.calibration_offset); 868 + dev_dbg(dev, "offset for channel %lu after zero-scale calibration: 0x%x\n", 869 + chan->address, ch->cfg.calibration_offset); 870 870 } else { 871 871 ch->cfg.calibration_gain = st->gain_default; 872 872 ··· 880 880 if (ret < 0) 881 881 return ret; 882 882 883 - dev_dbg(dev, "gain for channel %d after full-scale calibration: 0x%x\n", 884 - chan->channel, ch->cfg.calibration_gain); 883 + dev_dbg(dev, "gain for channel %lu after full-scale calibration: 0x%x\n", 884 + chan->address, ch->cfg.calibration_gain); 885 885 } 886 886 887 887 return 0; ··· 924 924 { 925 925 struct ad7124_state *st = iio_priv(indio_dev); 926 926 927 - st->channels[chan->channel].syscalib_mode = mode; 927 + st->channels[chan->address].syscalib_mode = mode; 928 928 929 929 return 0; 930 930 } ··· 934 934 { 935 935 struct ad7124_state *st = iio_priv(indio_dev); 936 936 937 - return st->channels[chan->channel].syscalib_mode; 937 + return st->channels[chan->address].syscalib_mode; 938 938 } 939 939 940 940 static const struct iio_enum ad7124_syscalib_mode_enum = {
+75 -12
drivers/iio/adc/ad7173.c
··· 200 200 /* 201 201 * Following fields are used to compare equality. If you 202 202 * make adaptations in it, you most likely also have to adapt 203 - * ad7173_find_live_config(), too. 203 + * ad7173_is_setup_equal(), too. 204 204 */ 205 205 struct_group(config_props, 206 206 bool bipolar; ··· 561 561 st->config_usage_counter = 0; 562 562 } 563 563 564 - static struct ad7173_channel_config * 565 - ad7173_find_live_config(struct ad7173_state *st, struct ad7173_channel_config *cfg) 564 + /** 565 + * ad7173_is_setup_equal - Compare two channel setups 566 + * @cfg1: First channel configuration 567 + * @cfg2: Second channel configuration 568 + * 569 + * Compares all configuration options that affect the registers connected to 570 + * SETUP_SEL, namely CONFIGx, FILTERx, GAINx and OFFSETx. 571 + * 572 + * Returns: true if the setups are identical, false otherwise 573 + */ 574 + static bool ad7173_is_setup_equal(const struct ad7173_channel_config *cfg1, 575 + const struct ad7173_channel_config *cfg2) 566 576 { 567 - struct ad7173_channel_config *cfg_aux; 568 - int i; 569 - 570 577 /* 571 578 * This is just to make sure that the comparison is adapted after 572 579 * struct ad7173_channel_config was changed. ··· 586 579 u8 ref_sel; 587 580 })); 588 581 582 + return cfg1->bipolar == cfg2->bipolar && 583 + cfg1->input_buf == cfg2->input_buf && 584 + cfg1->odr == cfg2->odr && 585 + cfg1->ref_sel == cfg2->ref_sel; 586 + } 587 + 588 + static struct ad7173_channel_config * 589 + ad7173_find_live_config(struct ad7173_state *st, struct ad7173_channel_config *cfg) 590 + { 591 + struct ad7173_channel_config *cfg_aux; 592 + int i; 593 + 589 594 for (i = 0; i < st->num_channels; i++) { 590 595 cfg_aux = &st->channels[i].cfg; 591 596 592 - if (cfg_aux->live && 593 - cfg->bipolar == cfg_aux->bipolar && 594 - cfg->input_buf == cfg_aux->input_buf && 595 - cfg->odr == cfg_aux->odr && 596 - cfg->ref_sel == cfg_aux->ref_sel) 597 + if (cfg_aux->live && ad7173_is_setup_equal(cfg, cfg_aux)) 597 598 return cfg_aux; 598 599 } 599 600 return NULL; ··· 1243 1228 const unsigned long *scan_mask) 1244 1229 { 1245 1230 struct ad7173_state *st = iio_priv(indio_dev); 1246 - int i, ret; 1231 + int i, j, k, ret; 1247 1232 1248 1233 for (i = 0; i < indio_dev->num_channels; i++) { 1249 1234 if (test_bit(i, scan_mask)) ··· 1252 1237 ret = ad_sd_write_reg(&st->sd, AD7173_REG_CH(i), 2, 0); 1253 1238 if (ret < 0) 1254 1239 return ret; 1240 + } 1241 + 1242 + /* 1243 + * On some chips, there are more channels that setups, so if there were 1244 + * more unique setups requested than the number of available slots, 1245 + * ad7173_set_channel() will have written over some of the slots. We 1246 + * can detect this by making sure each assigned cfg_slot matches the 1247 + * requested configuration. If it doesn't, we know that the slot was 1248 + * overwritten by a different channel. 1249 + */ 1250 + for_each_set_bit(i, scan_mask, indio_dev->num_channels) { 1251 + const struct ad7173_channel_config *cfg1, *cfg2; 1252 + 1253 + cfg1 = &st->channels[i].cfg; 1254 + 1255 + for_each_set_bit(j, scan_mask, indio_dev->num_channels) { 1256 + cfg2 = &st->channels[j].cfg; 1257 + 1258 + /* 1259 + * Only compare configs that are assigned to the same 1260 + * SETUP_SEL slot and don't compare channel to itself. 1261 + */ 1262 + if (i == j || cfg1->cfg_slot != cfg2->cfg_slot) 1263 + continue; 1264 + 1265 + /* 1266 + * If we find two different configs trying to use the 1267 + * same SETUP_SEL slot, then we know that the that we 1268 + * have too many unique configurations requested for 1269 + * the available slots and at least one was overwritten. 1270 + */ 1271 + if (!ad7173_is_setup_equal(cfg1, cfg2)) { 1272 + /* 1273 + * At this point, there isn't a way to tell 1274 + * which setups are actually programmed in the 1275 + * ADC anymore, so we could read them back to 1276 + * see, but it is simpler to just turn off all 1277 + * of the live flags so that everything gets 1278 + * reprogramed on the next attempt read a sample. 1279 + */ 1280 + for (k = 0; k < st->num_channels; k++) 1281 + st->channels[k].cfg.live = false; 1282 + 1283 + dev_err(&st->sd.spi->dev, 1284 + "Too many unique channel configurations requested for scan\n"); 1285 + return -EINVAL; 1286 + } 1287 + } 1255 1288 } 1256 1289 1257 1290 return 0;
+1
drivers/iio/adc/ad7380.c
··· 873 873 .has_hardware_gain = true, 874 874 .available_scan_masks = ad7380_4_channel_scan_masks, 875 875 .timing_specs = &ad7380_4_timing, 876 + .max_conversion_rate_hz = 4 * MEGA, 876 877 }; 877 878 878 879 static const struct spi_offload_config ad7380_offload_config = {
+10 -23
drivers/iio/adc/rzg2l_adc.c
··· 89 89 struct completion completion; 90 90 struct mutex lock; 91 91 u16 last_val[RZG2L_ADC_MAX_CHANNELS]; 92 - bool was_rpm_active; 93 92 }; 94 93 95 94 /** ··· 427 428 if (!indio_dev) 428 429 return -ENOMEM; 429 430 431 + platform_set_drvdata(pdev, indio_dev); 432 + 430 433 adc = iio_priv(indio_dev); 431 434 432 435 adc->hw_params = device_get_match_data(dev); ··· 460 459 ret = devm_pm_runtime_enable(dev); 461 460 if (ret) 462 461 return ret; 463 - 464 - platform_set_drvdata(pdev, indio_dev); 465 462 466 463 ret = rzg2l_adc_hw_init(dev, adc); 467 464 if (ret) ··· 540 541 }; 541 542 int ret; 542 543 543 - if (pm_runtime_suspended(dev)) { 544 - adc->was_rpm_active = false; 545 - } else { 546 - ret = pm_runtime_force_suspend(dev); 547 - if (ret) 548 - return ret; 549 - adc->was_rpm_active = true; 550 - } 544 + ret = pm_runtime_force_suspend(dev); 545 + if (ret) 546 + return ret; 551 547 552 548 ret = reset_control_bulk_assert(ARRAY_SIZE(resets), resets); 553 549 if (ret) ··· 551 557 return 0; 552 558 553 559 rpm_restore: 554 - if (adc->was_rpm_active) 555 - pm_runtime_force_resume(dev); 556 - 560 + pm_runtime_force_resume(dev); 557 561 return ret; 558 562 } 559 563 ··· 569 577 if (ret) 570 578 return ret; 571 579 572 - if (adc->was_rpm_active) { 573 - ret = pm_runtime_force_resume(dev); 574 - if (ret) 575 - goto resets_restore; 576 - } 580 + ret = pm_runtime_force_resume(dev); 581 + if (ret) 582 + goto resets_restore; 577 583 578 584 ret = rzg2l_adc_hw_init(dev, adc); 579 585 if (ret) ··· 580 590 return 0; 581 591 582 592 rpm_restore: 583 - if (adc->was_rpm_active) { 584 - pm_runtime_mark_last_busy(dev); 585 - pm_runtime_put_autosuspend(dev); 586 - } 593 + pm_runtime_force_suspend(dev); 587 594 resets_restore: 588 595 reset_control_bulk_assert(ARRAY_SIZE(resets), resets); 589 596 return ret;
+5 -1
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
··· 32 32 goto exit; 33 33 34 34 *temp = (s16)be16_to_cpup(raw); 35 + /* 36 + * Temperature data is invalid if both accel and gyro are off. 37 + * Return -EBUSY in this case. 38 + */ 35 39 if (*temp == INV_ICM42600_DATA_INVALID) 36 - ret = -EINVAL; 40 + ret = -EBUSY; 37 41 38 42 exit: 39 43 mutex_unlock(&st->lock);
+1 -1
drivers/iio/light/as73211.c
··· 639 639 struct { 640 640 __le16 chan[4]; 641 641 aligned_s64 ts; 642 - } scan; 642 + } scan = { }; 643 643 int data_result, ret; 644 644 645 645 mutex_lock(&data->mutex);
+5 -4
drivers/iio/pressure/bmp280-core.c
··· 3213 3213 3214 3214 /* Bring chip out of reset if there is an assigned GPIO line */ 3215 3215 gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 3216 + if (IS_ERR(gpiod)) 3217 + return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get reset GPIO\n"); 3218 + 3216 3219 /* Deassert the signal */ 3217 - if (gpiod) { 3218 - dev_info(dev, "release reset\n"); 3219 - gpiod_set_value(gpiod, 0); 3220 - } 3220 + dev_info(dev, "release reset\n"); 3221 + gpiod_set_value(gpiod, 0); 3221 3222 3222 3223 data->regmap = regmap; 3223 3224
+10 -4
drivers/iio/proximity/isl29501.c
··· 938 938 struct iio_dev *indio_dev = pf->indio_dev; 939 939 struct isl29501_private *isl29501 = iio_priv(indio_dev); 940 940 const unsigned long *active_mask = indio_dev->active_scan_mask; 941 - u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */ 941 + u32 value; 942 + struct { 943 + u16 data; 944 + aligned_s64 ts; 945 + } scan = { }; 942 946 943 - if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) 944 - isl29501_register_read(isl29501, REG_DISTANCE, buffer); 947 + if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) { 948 + isl29501_register_read(isl29501, REG_DISTANCE, &value); 949 + scan.data = value; 950 + } 945 951 946 - iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); 952 + iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp); 947 953 iio_trigger_notify_done(indio_dev->trig); 948 954 949 955 return IRQ_HANDLED;
+16 -10
drivers/iio/temperature/maxim_thermocouple.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/err.h> 13 13 #include <linux/spi/spi.h> 14 + #include <linux/types.h> 14 15 #include <linux/iio/iio.h> 15 16 #include <linux/iio/sysfs.h> 16 17 #include <linux/iio/trigger.h> ··· 122 121 struct spi_device *spi; 123 122 const struct maxim_thermocouple_chip *chip; 124 123 char tc_type; 125 - 126 - u8 buffer[16] __aligned(IIO_DMA_MINALIGN); 124 + /* Buffer for reading up to 2 hardware channels. */ 125 + struct { 126 + union { 127 + __be16 raw16; 128 + __be32 raw32; 129 + __be16 raw[2]; 130 + }; 131 + aligned_s64 timestamp; 132 + } buffer __aligned(IIO_DMA_MINALIGN); 127 133 }; 128 134 129 135 static int maxim_thermocouple_read(struct maxim_thermocouple_data *data, ··· 138 130 { 139 131 unsigned int storage_bytes = data->chip->read_size; 140 132 unsigned int shift = chan->scan_type.shift + (chan->address * 8); 141 - __be16 buf16; 142 - __be32 buf32; 143 133 int ret; 144 134 145 135 switch (storage_bytes) { 146 136 case 2: 147 - ret = spi_read(data->spi, (void *)&buf16, storage_bytes); 148 - *val = be16_to_cpu(buf16); 137 + ret = spi_read(data->spi, &data->buffer.raw16, storage_bytes); 138 + *val = be16_to_cpu(data->buffer.raw16); 149 139 break; 150 140 case 4: 151 - ret = spi_read(data->spi, (void *)&buf32, storage_bytes); 152 - *val = be32_to_cpu(buf32); 141 + ret = spi_read(data->spi, &data->buffer.raw32, storage_bytes); 142 + *val = be32_to_cpu(data->buffer.raw32); 153 143 break; 154 144 default: 155 145 ret = -EINVAL; ··· 172 166 struct maxim_thermocouple_data *data = iio_priv(indio_dev); 173 167 int ret; 174 168 175 - ret = spi_read(data->spi, data->buffer, data->chip->read_size); 169 + ret = spi_read(data->spi, data->buffer.raw, data->chip->read_size); 176 170 if (!ret) { 177 - iio_push_to_buffers_with_ts(indio_dev, data->buffer, 171 + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, 178 172 sizeof(data->buffer), 179 173 iio_get_time_ns(indio_dev)); 180 174 }
+1 -1
drivers/most/core.c
··· 538 538 dev = bus_find_device_by_name(&mostbus, NULL, mdev); 539 539 if (!dev) 540 540 return NULL; 541 - put_device(dev); 542 541 iface = dev_get_drvdata(dev); 542 + put_device(dev); 543 543 list_for_each_entry_safe(c, tmp, &iface->p->channel_list, list) { 544 544 if (!strcmp(dev_name(&c->dev), mdev_ch)) 545 545 return c;