Skip to content

Commit 3fb0698

Browse files
committed
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
2 parents a68d3cb + 012b827 commit 3fb0698

File tree

9 files changed

+64
-36
lines changed

9 files changed

+64
-36
lines changed

Documentation/devicetree/bindings/iio/dac/adi,ad5791.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ examples:
9191
vrefn-supply = <&dac_vrefn>;
9292
reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>;
9393
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>;
9595
};
9696
};
9797
...

drivers/iio/adc/ad7606.c

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,17 @@ static const struct iio_chan_spec ad7616_channels[] = {
175175
AD7606_CHANNEL(15, 16),
176176
};
177177

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,
179179
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,
181181
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,
183183
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,
185185
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,
187187
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,
189189
struct iio_chan_spec *chan, int ch);
190190

191191
const struct ad7606_chip_info ad7605_4_info = {
@@ -323,9 +323,10 @@ int ad7606_reset(struct ad7606_state *st)
323323
}
324324
EXPORT_SYMBOL_NS_GPL(ad7606_reset, "IIO_AD7606");
325325

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,
327327
struct iio_chan_spec *chan, int ch)
328328
{
329+
struct ad7606_state *st = iio_priv(indio_dev);
329330
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
330331

331332
if (!st->sw_mode_en) {
@@ -345,10 +346,12 @@ static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
345346
return 0;
346347
}
347348

348-
static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
349+
static int ad7606_get_chan_config(struct iio_dev *indio_dev, int ch,
349350
bool *bipolar, bool *differential)
350351
{
351-
unsigned int num_channels = st->chip_info->num_channels - 1;
352+
struct ad7606_state *st = iio_priv(indio_dev);
353+
unsigned int num_channels = st->chip_info->num_adc_channels;
354+
unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels;
352355
struct device *dev = st->dev;
353356
int ret;
354357

@@ -364,7 +367,7 @@ static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
364367
continue;
365368

366369
/* channel number (here) is from 1 to num_channels */
367-
if (reg == 0 || reg > num_channels) {
370+
if (reg < offset || reg > num_channels) {
368371
dev_warn(dev,
369372
"Invalid channel number (ignoring): %d\n", reg);
370373
continue;
@@ -399,9 +402,10 @@ static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
399402
return 0;
400403
}
401404

402-
static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
405+
static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev,
403406
struct iio_chan_spec *chan, int ch)
404407
{
408+
struct ad7606_state *st = iio_priv(indio_dev);
405409
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
406410
bool bipolar, differential;
407411
int ret;
@@ -413,7 +417,7 @@ static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
413417
return 0;
414418
}
415419

416-
ret = ad7606_get_chan_config(st, ch, &bipolar, &differential);
420+
ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential);
417421
if (ret)
418422
return ret;
419423

@@ -455,9 +459,10 @@ static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
455459
return 0;
456460
}
457461

458-
static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
462+
static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev,
459463
struct iio_chan_spec *chan, int ch)
460464
{
465+
struct ad7606_state *st = iio_priv(indio_dev);
461466
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
462467
bool bipolar, differential;
463468
int ret;
@@ -469,7 +474,7 @@ static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
469474
return 0;
470475
}
471476

472-
ret = ad7606_get_chan_config(st, ch, &bipolar, &differential);
477+
ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential);
473478
if (ret)
474479
return ret;
475480

@@ -512,9 +517,10 @@ static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
512517
return 0;
513518
}
514519

515-
static int ad7607_chan_scale_setup(struct ad7606_state *st,
520+
static int ad7607_chan_scale_setup(struct iio_dev *indio_dev,
516521
struct iio_chan_spec *chan, int ch)
517522
{
523+
struct ad7606_state *st = iio_priv(indio_dev);
518524
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
519525

520526
cs->range = 0;
@@ -523,9 +529,10 @@ static int ad7607_chan_scale_setup(struct ad7606_state *st,
523529
return 0;
524530
}
525531

526-
static int ad7608_chan_scale_setup(struct ad7606_state *st,
532+
static int ad7608_chan_scale_setup(struct iio_dev *indio_dev,
527533
struct iio_chan_spec *chan, int ch)
528534
{
535+
struct ad7606_state *st = iio_priv(indio_dev);
529536
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
530537

531538
cs->range = 0;
@@ -534,9 +541,10 @@ static int ad7608_chan_scale_setup(struct ad7606_state *st,
534541
return 0;
535542
}
536543

537-
static int ad7609_chan_scale_setup(struct ad7606_state *st,
544+
static int ad7609_chan_scale_setup(struct iio_dev *indio_dev,
538545
struct iio_chan_spec *chan, int ch)
539546
{
547+
struct ad7606_state *st = iio_priv(indio_dev);
540548
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
541549

542550
cs->range = 0;
@@ -1146,8 +1154,8 @@ static int ad7606_sw_mode_setup(struct iio_dev *indio_dev)
11461154

11471155
static int ad7606_chan_scales_setup(struct iio_dev *indio_dev)
11481156
{
1149-
unsigned int num_channels = indio_dev->num_channels - 1;
11501157
struct ad7606_state *st = iio_priv(indio_dev);
1158+
unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels;
11511159
struct iio_chan_spec *chans;
11521160
size_t size;
11531161
int ch, ret;
@@ -1161,8 +1169,8 @@ static int ad7606_chan_scales_setup(struct iio_dev *indio_dev)
11611169
memcpy(chans, indio_dev->channels, size);
11621170
indio_dev->channels = chans;
11631171

1164-
for (ch = 0; ch < num_channels; ch++) {
1165-
ret = st->chip_info->scale_setup_cb(st, &chans[ch + 1], ch);
1172+
for (ch = 0; ch < st->chip_info->num_adc_channels; ch++) {
1173+
ret = st->chip_info->scale_setup_cb(indio_dev, &chans[ch + offset], ch);
11661174
if (ret)
11671175
return ret;
11681176
}

drivers/iio/adc/ad7606.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
struct ad7606_state;
7171

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,
7373
struct iio_chan_spec *chan, int ch);
7474

7575
/**

drivers/iio/chemical/bme680_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,11 +879,11 @@ static int __bme680_read_raw(struct iio_dev *indio_dev,
879879
case IIO_CHAN_INFO_RAW:
880880
switch (chan->type) {
881881
case IIO_TEMP:
882-
ret = bme680_read_temp(data, (s16 *)&chan_val);
882+
ret = bme680_read_temp(data, &temp_chan_val);
883883
if (ret)
884884
return ret;
885885

886-
*val = chan_val;
886+
*val = temp_chan_val;
887887
return IIO_VAL_INT;
888888
case IIO_PRESSURE:
889889
ret = bme680_read_press(data, &chan_val);

drivers/iio/dac/ad3552r-common.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ EXPORT_SYMBOL_NS_GPL(ad3552r_ch_ranges, "IIO_AD3552R");
2222

2323
const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2] = {
2424
[AD3542R_CH_OUTPUT_RANGE_0__2P5V] = { 0, 2500 },
25-
[AD3542R_CH_OUTPUT_RANGE_0__3V] = { 0, 3000 },
2625
[AD3542R_CH_OUTPUT_RANGE_0__5V] = { 0, 5000 },
2726
[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 }
3029
};
3130
EXPORT_SYMBOL_NS_GPL(ad3542r_ch_ranges, "IIO_AD3552R");
3231

drivers/iio/dac/ad3552r-hs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st)
329329
dev_info(st->dev, "Chip ID error. Expected 0x%x, Read 0x%x\n",
330330
AD3552R_ID, id);
331331

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+
332338
ret = st->data->bus_reg_write(st->back,
333339
AD3552R_REG_ADDR_SH_REFERENCE_CONFIG,
334340
0, 1);

drivers/iio/dac/ad3552r.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
#define AD3552R_CH1_ACTIVE BIT(1)
132132

133133
#define AD3552R_MAX_RANGES 5
134-
#define AD3542R_MAX_RANGES 6
134+
#define AD3542R_MAX_RANGES 5
135135
#define AD3552R_QUAD_SPI 2
136136

137137
extern const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2];
@@ -189,16 +189,14 @@ enum ad3552r_ch_vref_select {
189189
enum ad3542r_ch_output_range {
190190
/* Range from 0 V to 2.5 V. Requires Rfb1x connection */
191191
AD3542R_CH_OUTPUT_RANGE_0__2P5V,
192-
/* Range from 0 V to 3 V. Requires Rfb1x connection */
193-
AD3542R_CH_OUTPUT_RANGE_0__3V,
194192
/* Range from 0 V to 5 V. Requires Rfb1x connection */
195193
AD3542R_CH_OUTPUT_RANGE_0__5V,
196194
/* Range from 0 V to 10 V. Requires Rfb2x connection */
197195
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,
200196
/* Range from -5 V to 5 V. Requires Rfb2x connection */
201197
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,
202200
};
203201

204202
enum ad3552r_ch_output_range {

drivers/iio/light/as73211.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ struct as73211_data {
177177
BIT(AS73211_SCAN_INDEX_TEMP) | \
178178
AS73211_SCAN_MASK_COLOR)
179179

180+
static const unsigned long as73211_scan_masks[] = {
181+
AS73211_SCAN_MASK_COLOR,
182+
AS73211_SCAN_MASK_ALL,
183+
0
184+
};
185+
180186
static const struct iio_chan_spec as73211_channels[] = {
181187
{
182188
.type = IIO_TEMP,
@@ -672,19 +678,28 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
672678

673679
/* AS73211 starts reading at address 2 */
674680
ret = i2c_master_recv(data->client,
675-
(char *)&scan.chan[1], 3 * sizeof(scan.chan[1]));
681+
(char *)&scan.chan[0], 3 * sizeof(scan.chan[0]));
676682
if (ret < 0)
677683
goto done;
684+
685+
/* Avoid pushing uninitialized data */
686+
scan.chan[3] = 0;
678687
}
679688

680689
if (data_result) {
681690
/*
682691
* Saturate all channels (in case of overflows). Temperature channel
683692
* is not affected by overflows.
684693
*/
685-
scan.chan[1] = cpu_to_le16(U16_MAX);
686-
scan.chan[2] = cpu_to_le16(U16_MAX);
687-
scan.chan[3] = cpu_to_le16(U16_MAX);
694+
if (*indio_dev->active_scan_mask == AS73211_SCAN_MASK_ALL) {
695+
scan.chan[1] = cpu_to_le16(U16_MAX);
696+
scan.chan[2] = cpu_to_le16(U16_MAX);
697+
scan.chan[3] = cpu_to_le16(U16_MAX);
698+
} else {
699+
scan.chan[0] = cpu_to_le16(U16_MAX);
700+
scan.chan[1] = cpu_to_le16(U16_MAX);
701+
scan.chan[2] = cpu_to_le16(U16_MAX);
702+
}
688703
}
689704

690705
iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
@@ -758,6 +773,7 @@ static int as73211_probe(struct i2c_client *client)
758773
indio_dev->channels = data->spec_dev->channels;
759774
indio_dev->num_channels = data->spec_dev->num_channels;
760775
indio_dev->modes = INDIO_DIRECT_MODE;
776+
indio_dev->available_scan_masks = as73211_scan_masks;
761777

762778
ret = i2c_smbus_read_byte_data(data->client, AS73211_REG_OSR);
763779
if (ret < 0)

drivers/iio/light/hid-sensor-prox.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
9494
*val2 = 0;
9595
switch (mask) {
9696
case IIO_CHAN_INFO_RAW:
97+
case IIO_CHAN_INFO_PROCESSED:
9798
if (chan->scan_index >= prox_state->num_channels)
9899
return -EINVAL;
99100
address = prox_state->channel2usage[chan->scan_index];

0 commit comments

Comments
 (0)