Skip to content

Commit 0cbe104

Browse files
committed
Merge tag 'char-misc-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc/IIO driver fixes from Greg KH: "Here are a bunch of small IIO and interconnect and other driver fixes to resolve reported issues. Included in here are: - loads of iio driver fixes as a result of an audit of places where uninitialized data would leak to userspace. - other smaller, and normal, iio driver fixes. - mhi driver fix - interconnect driver fixes - pci1xxxx driver fix All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (32 commits) misc: microchip: pci1xxxx: Resolve return code mismatch during GPIO set config misc: microchip: pci1xxxx: Resolve kernel panic during GPIO IRQ handling interconnect: icc-clk: check return values of devm_kasprintf() interconnect: qcom: icc-rpm: Set the count member before accessing the flex array 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 ...
2 parents 083f9fa + c7a5378 commit 0cbe104

File tree

31 files changed

+173
-62
lines changed

31 files changed

+173
-62
lines changed

Documentation/devicetree/bindings/iio/st,st-sensors.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ properties:
6565
- st,lsm9ds0-gyro
6666
- description: STMicroelectronics Magnetometers
6767
enum:
68+
- st,iis2mdc
6869
- st,lis2mdl
6970
- st,lis3mdl-magn
7071
- st,lsm303agr-magn

drivers/bus/mhi/host/pci_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ static int mhi_pci_claim(struct mhi_controller *mhi_cntrl,
917917
return err;
918918
}
919919

920-
mhi_cntrl->regs = pcim_iomap_region(pdev, 1 << bar_num, pci_name(pdev));
920+
mhi_cntrl->regs = pcim_iomap_region(pdev, bar_num, pci_name(pdev));
921921
if (IS_ERR(mhi_cntrl->regs)) {
922922
err = PTR_ERR(mhi_cntrl->regs);
923923
dev_err(&pdev->dev, "failed to map pci region: %d\n", err);

drivers/iio/adc/ad4695.c

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#define AD4695_T_WAKEUP_SW_MS 3
9292
#define AD4695_T_REFBUF_MS 100
9393
#define AD4695_T_REGCONFIG_NS 20
94+
#define AD4695_T_SCK_CNV_DELAY_NS 80
9495
#define AD4695_REG_ACCESS_SCLK_HZ (10 * MEGA)
9596

9697
/* Max number of voltage input channels. */
@@ -132,8 +133,13 @@ struct ad4695_state {
132133
unsigned int vref_mv;
133134
/* Common mode input pin voltage. */
134135
unsigned int com_mv;
135-
/* 1 per voltage and temperature chan plus 1 xfer to trigger 1st CNV */
136-
struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS + 2];
136+
/*
137+
* 2 per voltage and temperature chan plus 1 xfer to trigger 1st
138+
* CNV. Excluding the trigger xfer, every 2nd xfer only serves
139+
* to control CS and add a delay between the last SCLK and next
140+
* CNV rising edges.
141+
*/
142+
struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3];
137143
struct spi_message buf_read_msg;
138144
/* Raw conversion data received. */
139145
u8 buf[ALIGN((AD4695_MAX_CHANNELS + 2) * AD4695_MAX_CHANNEL_SIZE,
@@ -423,7 +429,7 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
423429
u8 temp_chan_bit = st->chip_info->num_voltage_inputs;
424430
u32 bit, num_xfer, num_slots;
425431
u32 temp_en = 0;
426-
int ret;
432+
int ret, rx_buf_offset = 0;
427433

428434
/*
429435
* We are using the advanced sequencer since it is the only way to read
@@ -449,11 +455,9 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
449455
iio_for_each_active_channel(indio_dev, bit) {
450456
xfer = &st->buf_read_xfer[num_xfer];
451457
xfer->bits_per_word = 16;
452-
xfer->rx_buf = &st->buf[(num_xfer - 1) * 2];
458+
xfer->rx_buf = &st->buf[rx_buf_offset];
453459
xfer->len = 2;
454-
xfer->cs_change = 1;
455-
xfer->cs_change_delay.value = AD4695_T_CONVERT_NS;
456-
xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
460+
rx_buf_offset += xfer->len;
457461

458462
if (bit == temp_chan_bit) {
459463
temp_en = 1;
@@ -468,21 +472,44 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
468472
}
469473

470474
num_xfer++;
475+
476+
/*
477+
* We need to add a blank xfer in data reads, to meet the timing
478+
* requirement of a minimum delay between the last SCLK rising
479+
* edge and the CS deassert.
480+
*/
481+
xfer = &st->buf_read_xfer[num_xfer];
482+
xfer->delay.value = AD4695_T_SCK_CNV_DELAY_NS;
483+
xfer->delay.unit = SPI_DELAY_UNIT_NSECS;
484+
xfer->cs_change = 1;
485+
xfer->cs_change_delay.value = AD4695_T_CONVERT_NS;
486+
xfer->cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
487+
488+
num_xfer++;
471489
}
472490

473491
/*
474492
* The advanced sequencer requires that at least 2 slots are enabled.
475493
* Since slot 0 is always used for other purposes, we need only 1
476-
* enabled voltage channel to meet this requirement. If the temperature
477-
* channel is the only enabled channel, we need to add one more slot
478-
* in the sequence but not read from it.
494+
* enabled voltage channel to meet this requirement. If the temperature
495+
* channel is the only enabled channel, we need to add one more slot in
496+
* the sequence but not read from it. This is because the temperature
497+
* sensor is sampled at the end of the channel sequence in advanced
498+
* sequencer mode (see datasheet page 38).
499+
*
500+
* From the iio_for_each_active_channel() block above, we now have an
501+
* xfer with data followed by a blank xfer to allow us to meet the
502+
* timing spec, so move both of those up before adding an extra to
503+
* handle the temperature-only case.
479504
*/
480505
if (num_slots < 2) {
481-
/* move last xfer so we can insert one more xfer before it */
482-
st->buf_read_xfer[num_xfer] = *xfer;
506+
/* Move last two xfers */
507+
st->buf_read_xfer[num_xfer] = st->buf_read_xfer[num_xfer - 1];
508+
st->buf_read_xfer[num_xfer - 1] = st->buf_read_xfer[num_xfer - 2];
483509
num_xfer++;
484510

485-
/* modify 2nd to last xfer for extra slot */
511+
/* Modify inserted xfer for extra slot. */
512+
xfer = &st->buf_read_xfer[num_xfer - 3];
486513
memset(xfer, 0, sizeof(*xfer));
487514
xfer->cs_change = 1;
488515
xfer->delay.value = st->chip_info->t_acq_ns;
@@ -499,6 +526,12 @@ static int ad4695_buffer_preenable(struct iio_dev *indio_dev)
499526
return ret;
500527

501528
num_slots++;
529+
530+
/*
531+
* We still want to point at the last xfer when finished, so
532+
* update the pointer.
533+
*/
534+
xfer = &st->buf_read_xfer[num_xfer - 1];
502535
}
503536

504537
/*
@@ -583,38 +616,43 @@ static irqreturn_t ad4695_trigger_handler(int irq, void *p)
583616
*/
584617
static int ad4695_read_one_sample(struct ad4695_state *st, unsigned int address)
585618
{
586-
struct spi_transfer xfer[2] = { };
587-
int ret, i = 0;
619+
struct spi_transfer xfers[2] = {
620+
{
621+
.speed_hz = AD4695_REG_ACCESS_SCLK_HZ,
622+
.bits_per_word = 16,
623+
.tx_buf = &st->cnv_cmd,
624+
.len = 2,
625+
},
626+
{
627+
/* Required delay between last SCLK and CNV/CS */
628+
.delay.value = AD4695_T_SCK_CNV_DELAY_NS,
629+
.delay.unit = SPI_DELAY_UNIT_NSECS,
630+
}
631+
};
632+
int ret;
588633

589634
ret = ad4695_set_single_cycle_mode(st, address);
590635
if (ret)
591636
return ret;
592637

593638
/*
594639
* Setting the first channel to the temperature channel isn't supported
595-
* in single-cycle mode, so we have to do an extra xfer to read the
596-
* temperature.
640+
* in single-cycle mode, so we have to do an extra conversion to read
641+
* the temperature.
597642
*/
598643
if (address == AD4695_CMD_TEMP_CHAN) {
599-
/* We aren't reading, so we can make this a short xfer. */
600-
st->cnv_cmd2 = AD4695_CMD_TEMP_CHAN << 3;
601-
xfer[0].tx_buf = &st->cnv_cmd2;
602-
xfer[0].len = 1;
603-
xfer[0].cs_change = 1;
604-
xfer[0].cs_change_delay.value = AD4695_T_CONVERT_NS;
605-
xfer[0].cs_change_delay.unit = SPI_DELAY_UNIT_NSECS;
606-
607-
i = 1;
644+
st->cnv_cmd = AD4695_CMD_TEMP_CHAN << 11;
645+
646+
ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
647+
if (ret)
648+
return ret;
608649
}
609650

610651
/* Then read the result and exit conversion mode. */
611652
st->cnv_cmd = AD4695_CMD_EXIT_CNV_MODE << 11;
612-
xfer[i].bits_per_word = 16;
613-
xfer[i].tx_buf = &st->cnv_cmd;
614-
xfer[i].rx_buf = &st->raw_data;
615-
xfer[i].len = 2;
653+
xfers[0].rx_buf = &st->raw_data;
616654

617-
return spi_sync_transfer(st->spi, xfer, i + 1);
655+
return spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
618656
}
619657

620658
static int ad4695_read_raw(struct iio_dev *indio_dev,

drivers/iio/adc/ad7124.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,9 @@ static int ad7124_setup(struct ad7124_state *st)
917917
* set all channels to this default value.
918918
*/
919919
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);
920923
}
921924

922925
ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control);

drivers/iio/adc/ad7173.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ struct ad7173_channel {
200200

201201
struct ad7173_state {
202202
struct ad_sigma_delta sd;
203+
struct ad_sigma_delta_info sigma_delta_info;
203204
const struct ad7173_device_info *info;
204205
struct ad7173_channel *channels;
205206
struct regulator_bulk_data regulators[3];
@@ -753,7 +754,7 @@ static int ad7173_disable_one(struct ad_sigma_delta *sd, unsigned int chan)
753754
return ad_sd_write_reg(sd, AD7173_REG_CH(chan), 2, 0);
754755
}
755756

756-
static struct ad_sigma_delta_info ad7173_sigma_delta_info = {
757+
static const struct ad_sigma_delta_info ad7173_sigma_delta_info = {
757758
.set_channel = ad7173_set_channel,
758759
.append_status = ad7173_append_status,
759760
.disable_all = ad7173_disable_all,
@@ -1403,7 +1404,7 @@ static int ad7173_fw_parse_device_config(struct iio_dev *indio_dev)
14031404
if (ret < 0)
14041405
return dev_err_probe(dev, ret, "Interrupt 'rdy' is required\n");
14051406

1406-
ad7173_sigma_delta_info.irq_line = ret;
1407+
st->sigma_delta_info.irq_line = ret;
14071408

14081409
return ad7173_fw_parse_channel_config(indio_dev);
14091410
}
@@ -1436,8 +1437,9 @@ static int ad7173_probe(struct spi_device *spi)
14361437
spi->mode = SPI_MODE_3;
14371438
spi_setup(spi);
14381439

1439-
ad7173_sigma_delta_info.num_slots = st->info->num_configs;
1440-
ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7173_sigma_delta_info);
1440+
st->sigma_delta_info = ad7173_sigma_delta_info;
1441+
st->sigma_delta_info.num_slots = st->info->num_configs;
1442+
ret = ad_sd_init(&st->sd, indio_dev, spi, &st->sigma_delta_info);
14411443
if (ret)
14421444
return ret;
14431445

drivers/iio/adc/ad9467.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,14 +895,22 @@ static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
895895
return 0;
896896
}
897897

898-
static struct iio_info ad9467_info = {
898+
static const struct iio_info ad9467_info = {
899899
.read_raw = ad9467_read_raw,
900900
.write_raw = ad9467_write_raw,
901901
.update_scan_mode = ad9467_update_scan_mode,
902902
.debugfs_reg_access = ad9467_reg_access,
903903
.read_avail = ad9467_read_avail,
904904
};
905905

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+
906914
static int ad9467_scale_fill(struct ad9467_state *st)
907915
{
908916
const struct ad9467_chip_info *info = st->info;
@@ -1214,11 +1222,12 @@ static int ad9467_probe(struct spi_device *spi)
12141222
}
12151223

12161224
if (st->info->num_scales > 1)
1217-
ad9467_info.read_avail = ad9467_read_avail;
1225+
indio_dev->info = &ad9467_info;
1226+
else
1227+
indio_dev->info = &ad9467_info_no_read_avail;
12181228
indio_dev->name = st->info->name;
12191229
indio_dev->channels = st->info->channels;
12201230
indio_dev->num_channels = st->info->num_channels;
1221-
indio_dev->info = &ad9467_info;
12221231

12231232
ret = ad9467_iio_backend_get(st);
12241233
if (ret)

drivers/iio/adc/at91_adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static int at91_ts_register(struct iio_dev *idev,
979979
return ret;
980980

981981
err:
982-
input_free_device(st->ts_input);
982+
input_free_device(input);
983983
return ret;
984984
}
985985

drivers/iio/adc/rockchip_saradc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ static irqreturn_t rockchip_saradc_trigger_handler(int irq, void *p)
368368
int ret;
369369
int i, j = 0;
370370

371+
memset(&data, 0, sizeof(data));
372+
371373
mutex_lock(&info->lock);
372374

373375
iio_for_each_active_channel(i_dev, i) {

drivers/iio/adc/stm32-dfsdm-adc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,14 @@ static int stm32_dfsdm_generic_channel_parse_of(struct stm32_dfsdm *dfsdm,
691691
return -EINVAL;
692692
}
693693

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+
}
699702
}
700703

701704
df_ch = &dfsdm->ch_list[ch->channel];

drivers/iio/adc/ti-ads1119.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ static irqreturn_t ads1119_trigger_handler(int irq, void *private)
500500
struct iio_dev *indio_dev = pf->indio_dev;
501501
struct ads1119_state *st = iio_priv(indio_dev);
502502
struct {
503-
unsigned int sample;
503+
s16 sample;
504504
s64 timestamp __aligned(8);
505505
} scan;
506506
unsigned int index;
507507
int ret;
508508

509+
memset(&scan, 0, sizeof(scan));
510+
509511
if (!iio_trigger_using_own(indio_dev)) {
510512
index = find_first_bit(indio_dev->active_scan_mask,
511513
iio_get_masklength(indio_dev));

drivers/iio/adc/ti-ads124s08.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ static int ads124s_reset(struct iio_dev *indio_dev)
183183
struct ads124s_private *priv = iio_priv(indio_dev);
184184

185185
if (priv->reset_gpio) {
186-
gpiod_set_value(priv->reset_gpio, 0);
186+
gpiod_set_value_cansleep(priv->reset_gpio, 0);
187187
udelay(200);
188-
gpiod_set_value(priv->reset_gpio, 1);
188+
gpiod_set_value_cansleep(priv->reset_gpio, 1);
189189
} else {
190190
return ads124s_write_cmd(indio_dev, ADS124S08_CMD_RESET);
191191
}

drivers/iio/adc/ti-ads1298.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,8 @@ static int ads1298_init(struct iio_dev *indio_dev)
613613
}
614614
indio_dev->name = devm_kasprintf(dev, GFP_KERNEL, "ads129%u%s",
615615
indio_dev->num_channels, suffix);
616+
if (!indio_dev->name)
617+
return -ENOMEM;
616618

617619
/* Enable internal test signal, double amplitude, double frequency */
618620
ret = regmap_write(priv->regmap, ADS1298_REG_CONFIG2,

drivers/iio/adc/ti-ads8688.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p)
381381
struct iio_poll_func *pf = p;
382382
struct iio_dev *indio_dev = pf->indio_dev;
383383
/* 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) = { };
385385
int i, j = 0;
386386

387387
iio_for_each_active_channel(indio_dev, i) {

drivers/iio/dummy/iio_simple_dummy_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
4848
int i = 0, j;
4949
u16 *data;
5050

51-
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
51+
data = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
5252
if (!data)
5353
goto done;
5454

drivers/iio/gyro/fxas21002c_core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,21 @@ static irqreturn_t fxas21002c_trigger_handler(int irq, void *p)
730730
int ret;
731731

732732
mutex_lock(&data->lock);
733+
ret = fxas21002c_pm_get(data);
734+
if (ret < 0)
735+
goto out_unlock;
736+
733737
ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB,
734738
data->buffer, CHANNEL_SCAN_MAX * sizeof(s16));
735739
if (ret < 0)
736-
goto out_unlock;
740+
goto out_pm_put;
737741

738742
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
739743
data->timestamp);
740744

745+
out_pm_put:
746+
fxas21002c_pm_put(data);
747+
741748
out_unlock:
742749
mutex_unlock(&data->lock);
743750

0 commit comments

Comments
 (0)