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. -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmeICcARHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0Foj+phAAg2nQIkFUP1pWaLWNnPYDPZAT6T4N9J8O CYkVysYeO3iDotG875eEOKaG4UCXM9QfuNs/nZF8HYL3Hluq3OiKlDOYJEo2mAoD qUeQNfkWfzLE5OwqVQjcSpdOmQjbOyQNx4BNf52SV3VtcBHv+rl4M/x+ZLB8hRRc /9L57niQtqk0x7ARLLvx3XjBe+bWEGA8b/lV26c112XkJcsIlWxXTPQubafxUiur +IAEomDSMEfBnhc4I0oDnTxLsa/H1hKAVSPIe5xCDCUrk5pQoqiHweZS7QOz3pPV C3If+fxZA0uFNksrVFUGtwwJuWj5+ITueBrD72G9KQXQvyBr8tWQ0HHwD8jR9V19 USeQ3w+H4AyNuvJ2GEvDGCZsBlH5AFuFByiGdoJFAXxdiu96MKumVb1bdTmrwGxq XCJZXPYRJAmS3qIePqJYw/9oUjVGPhWLPH+4VaToVi/TqTULmtLlVwsJ4HaYpVGx em3OJBHHl9fCafpu0Q6QDZ0tW1BFINltKTZ3kDndkPB/wgZoem1j8jnOOB6TWvjh aEQ0ygnIRwI5cPLVVPDNub5gi+XnKlCNwS171CTTIccOlxQwLeFu1Yq8pqc6a+Dq YNHzn2Q9vICTcdjpIVA0pOKvbhV+vx0apvdVBWd6cDhlO8YQ864/Wg2r+meGUC0R Dt2jKx/bMUY= =J9mF -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
3fb06981ce
9 changed files with 64 additions and 36 deletions
|
@ -91,7 +91,7 @@ examples:
|
|||
vrefn-supply = <&dac_vrefn>;
|
||||
reset-gpios = <&gpio_bd 16 GPIO_ACTIVE_LOW>;
|
||||
clear-gpios = <&gpio_bd 17 GPIO_ACTIVE_LOW>;
|
||||
ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_HIGH>;
|
||||
ldac-gpios = <&gpio_bd 18 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
...
|
||||
|
|
|
@ -175,17 +175,17 @@ static const struct iio_chan_spec ad7616_channels[] = {
|
|||
AD7606_CHANNEL(15, 16),
|
||||
};
|
||||
|
||||
static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7607_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7607_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7608_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7608_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
static int ad7609_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7609_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
|
||||
const struct ad7606_chip_info ad7605_4_info = {
|
||||
|
@ -323,9 +323,10 @@ int ad7606_reset(struct ad7606_state *st)
|
|||
}
|
||||
EXPORT_SYMBOL_NS_GPL(ad7606_reset, "IIO_AD7606");
|
||||
|
||||
static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
if (!st->sw_mode_en) {
|
||||
|
@ -345,10 +346,12 @@ static int ad7606_16bit_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
|
||||
static int ad7606_get_chan_config(struct iio_dev *indio_dev, int ch,
|
||||
bool *bipolar, bool *differential)
|
||||
{
|
||||
unsigned int num_channels = st->chip_info->num_channels - 1;
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
unsigned int num_channels = st->chip_info->num_adc_channels;
|
||||
unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels;
|
||||
struct device *dev = st->dev;
|
||||
int ret;
|
||||
|
||||
|
@ -364,7 +367,7 @@ static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
|
|||
continue;
|
||||
|
||||
/* channel number (here) is from 1 to num_channels */
|
||||
if (reg == 0 || reg > num_channels) {
|
||||
if (reg < offset || reg > num_channels) {
|
||||
dev_warn(dev,
|
||||
"Invalid channel number (ignoring): %d\n", reg);
|
||||
continue;
|
||||
|
@ -399,9 +402,10 @@ static int ad7606_get_chan_config(struct ad7606_state *st, int ch,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
bool bipolar, differential;
|
||||
int ret;
|
||||
|
@ -413,7 +417,7 @@ static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
ret = ad7606_get_chan_config(st, ch, &bipolar, &differential);
|
||||
ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -455,9 +459,10 @@ static int ad7606c_18bit_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
bool bipolar, differential;
|
||||
int ret;
|
||||
|
@ -469,7 +474,7 @@ static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
ret = ad7606_get_chan_config(st, ch, &bipolar, &differential);
|
||||
ret = ad7606_get_chan_config(indio_dev, ch, &bipolar, &differential);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -512,9 +517,10 @@ static int ad7606c_16bit_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ad7607_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7607_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
cs->range = 0;
|
||||
|
@ -523,9 +529,10 @@ static int ad7607_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ad7608_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7608_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
cs->range = 0;
|
||||
|
@ -534,9 +541,10 @@ static int ad7608_chan_scale_setup(struct ad7606_state *st,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ad7609_chan_scale_setup(struct ad7606_state *st,
|
||||
static int ad7609_chan_scale_setup(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch)
|
||||
{
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
struct ad7606_chan_scale *cs = &st->chan_scales[ch];
|
||||
|
||||
cs->range = 0;
|
||||
|
@ -1146,8 +1154,8 @@ static int ad7606_sw_mode_setup(struct iio_dev *indio_dev)
|
|||
|
||||
static int ad7606_chan_scales_setup(struct iio_dev *indio_dev)
|
||||
{
|
||||
unsigned int num_channels = indio_dev->num_channels - 1;
|
||||
struct ad7606_state *st = iio_priv(indio_dev);
|
||||
unsigned int offset = indio_dev->num_channels - st->chip_info->num_adc_channels;
|
||||
struct iio_chan_spec *chans;
|
||||
size_t size;
|
||||
int ch, ret;
|
||||
|
@ -1161,8 +1169,8 @@ static int ad7606_chan_scales_setup(struct iio_dev *indio_dev)
|
|||
memcpy(chans, indio_dev->channels, size);
|
||||
indio_dev->channels = chans;
|
||||
|
||||
for (ch = 0; ch < num_channels; ch++) {
|
||||
ret = st->chip_info->scale_setup_cb(st, &chans[ch + 1], ch);
|
||||
for (ch = 0; ch < st->chip_info->num_adc_channels; ch++) {
|
||||
ret = st->chip_info->scale_setup_cb(indio_dev, &chans[ch + offset], ch);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
struct ad7606_state;
|
||||
|
||||
typedef int (*ad7606_scale_setup_cb_t)(struct ad7606_state *st,
|
||||
typedef int (*ad7606_scale_setup_cb_t)(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec *chan, int ch);
|
||||
|
||||
/**
|
||||
|
|
|
@ -879,11 +879,11 @@ static int __bme680_read_raw(struct iio_dev *indio_dev,
|
|||
case IIO_CHAN_INFO_RAW:
|
||||
switch (chan->type) {
|
||||
case IIO_TEMP:
|
||||
ret = bme680_read_temp(data, (s16 *)&chan_val);
|
||||
ret = bme680_read_temp(data, &temp_chan_val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*val = chan_val;
|
||||
*val = temp_chan_val;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_PRESSURE:
|
||||
ret = bme680_read_press(data, &chan_val);
|
||||
|
|
|
@ -22,11 +22,10 @@ EXPORT_SYMBOL_NS_GPL(ad3552r_ch_ranges, "IIO_AD3552R");
|
|||
|
||||
const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2] = {
|
||||
[AD3542R_CH_OUTPUT_RANGE_0__2P5V] = { 0, 2500 },
|
||||
[AD3542R_CH_OUTPUT_RANGE_0__3V] = { 0, 3000 },
|
||||
[AD3542R_CH_OUTPUT_RANGE_0__5V] = { 0, 5000 },
|
||||
[AD3542R_CH_OUTPUT_RANGE_0__10V] = { 0, 10000 },
|
||||
[AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 },
|
||||
[AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 }
|
||||
[AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 },
|
||||
[AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 }
|
||||
};
|
||||
EXPORT_SYMBOL_NS_GPL(ad3542r_ch_ranges, "IIO_AD3552R");
|
||||
|
||||
|
|
|
@ -329,6 +329,12 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st)
|
|||
dev_info(st->dev, "Chip ID error. Expected 0x%x, Read 0x%x\n",
|
||||
AD3552R_ID, id);
|
||||
|
||||
/* Clear reset error flag, see ad3552r manual, rev B table 38. */
|
||||
ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_ERR_STATUS,
|
||||
AD3552R_MASK_RESET_STATUS, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = st->data->bus_reg_write(st->back,
|
||||
AD3552R_REG_ADDR_SH_REFERENCE_CONFIG,
|
||||
0, 1);
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
#define AD3552R_CH1_ACTIVE BIT(1)
|
||||
|
||||
#define AD3552R_MAX_RANGES 5
|
||||
#define AD3542R_MAX_RANGES 6
|
||||
#define AD3542R_MAX_RANGES 5
|
||||
#define AD3552R_QUAD_SPI 2
|
||||
|
||||
extern const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2];
|
||||
|
@ -189,16 +189,14 @@ enum ad3552r_ch_vref_select {
|
|||
enum ad3542r_ch_output_range {
|
||||
/* Range from 0 V to 2.5 V. Requires Rfb1x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_0__2P5V,
|
||||
/* Range from 0 V to 3 V. Requires Rfb1x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_0__3V,
|
||||
/* Range from 0 V to 5 V. Requires Rfb1x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_0__5V,
|
||||
/* Range from 0 V to 10 V. Requires Rfb2x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_0__10V,
|
||||
/* Range from -2.5 V to 7.5 V. Requires Rfb2x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V,
|
||||
/* Range from -5 V to 5 V. Requires Rfb2x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_NEG_5__5V,
|
||||
/* Range from -2.5 V to 7.5 V. Requires Rfb2x connection */
|
||||
AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V,
|
||||
};
|
||||
|
||||
enum ad3552r_ch_output_range {
|
||||
|
|
|
@ -177,6 +177,12 @@ struct as73211_data {
|
|||
BIT(AS73211_SCAN_INDEX_TEMP) | \
|
||||
AS73211_SCAN_MASK_COLOR)
|
||||
|
||||
static const unsigned long as73211_scan_masks[] = {
|
||||
AS73211_SCAN_MASK_COLOR,
|
||||
AS73211_SCAN_MASK_ALL,
|
||||
0
|
||||
};
|
||||
|
||||
static const struct iio_chan_spec as73211_channels[] = {
|
||||
{
|
||||
.type = IIO_TEMP,
|
||||
|
@ -672,9 +678,12 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
|
|||
|
||||
/* AS73211 starts reading at address 2 */
|
||||
ret = i2c_master_recv(data->client,
|
||||
(char *)&scan.chan[1], 3 * sizeof(scan.chan[1]));
|
||||
(char *)&scan.chan[0], 3 * sizeof(scan.chan[0]));
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
/* Avoid pushing uninitialized data */
|
||||
scan.chan[3] = 0;
|
||||
}
|
||||
|
||||
if (data_result) {
|
||||
|
@ -682,9 +691,15 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
|
|||
* Saturate all channels (in case of overflows). Temperature channel
|
||||
* is not affected by overflows.
|
||||
*/
|
||||
scan.chan[1] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[2] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[3] = cpu_to_le16(U16_MAX);
|
||||
if (*indio_dev->active_scan_mask == AS73211_SCAN_MASK_ALL) {
|
||||
scan.chan[1] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[2] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[3] = cpu_to_le16(U16_MAX);
|
||||
} else {
|
||||
scan.chan[0] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[1] = cpu_to_le16(U16_MAX);
|
||||
scan.chan[2] = cpu_to_le16(U16_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
|||
indio_dev->channels = data->spec_dev->channels;
|
||||
indio_dev->num_channels = data->spec_dev->num_channels;
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
indio_dev->available_scan_masks = as73211_scan_masks;
|
||||
|
||||
ret = i2c_smbus_read_byte_data(data->client, AS73211_REG_OSR);
|
||||
if (ret < 0)
|
||||
|
|
|
@ -94,6 +94,7 @@ static int prox_read_raw(struct iio_dev *indio_dev,
|
|||
*val2 = 0;
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
case IIO_CHAN_INFO_PROCESSED:
|
||||
if (chan->scan_index >= prox_state->num_channels)
|
||||
return -EINVAL;
|
||||
address = prox_state->channel2usage[chan->scan_index];
|
||||
|
|
Loading…
Add table
Reference in a new issue