Skip to content

Commit a3245eb

Browse files
committed
Merge tag 'iio-fixes-for-6.15b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
Jonathan writes: IIO: 2nd set of fixes for 6.15 (or 6.16 merge window) Usual mixed bag. adi,ad4851 - Avoid a buffer overrun due to bug in pointer arithmetic. adi,ad7173 - Fix compiling if gpiolib is not enabled adi,ad7606 - Fix raw reads for 18-bit chips by ensuring we mask out upper bits as some SPI controllers do not do so for 18bit words. - Fix wrong masking for register writes. adi,ad7944 - Mask high bits for raw reads. adi,axi-adc - Add check on whether the busy flag has cleared before first access. invensense,icm42600 - Fix the temperature offset to take scale into account. nxp,fxls8962af - Fix temperature to be in milli degrees Celsius not degrees. - Fix sign of temperature channel. * tag 'iio-fixes-for-6.15b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: accel: fxls8962af: Fix temperature scan element sign iio: accel: fxls8962af: Fix temperature calculation iio: adc: ad7944: mask high bits on direct read iio: adc: ad4851: fix ad4858 chan pointer handling iio: imu: inv_icm42600: Fix temperature calculation iio: dac: adi-axi-dac: fix bus read iio: adc: ad7606_spi: fix reg write value mask iio: adc: ad7606: fix raw read for 18-bit chips iio: adc: ad7173: fix compiling without gpiolib
2 parents 3ab3112 + 9c78317 commit a3245eb

File tree

9 files changed

+50
-40
lines changed

9 files changed

+50
-40
lines changed

drivers/iio/accel/fxls8962af-core.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/regulator/consumer.h>
2424
#include <linux/regmap.h>
2525
#include <linux/types.h>
26+
#include <linux/units.h>
2627

2728
#include <linux/iio/buffer.h>
2829
#include <linux/iio/events.h>
@@ -439,8 +440,16 @@ static int fxls8962af_read_raw(struct iio_dev *indio_dev,
439440
*val = FXLS8962AF_TEMP_CENTER_VAL;
440441
return IIO_VAL_INT;
441442
case IIO_CHAN_INFO_SCALE:
442-
*val = 0;
443-
return fxls8962af_read_full_scale(data, val2);
443+
switch (chan->type) {
444+
case IIO_TEMP:
445+
*val = MILLIDEGREE_PER_DEGREE;
446+
return IIO_VAL_INT;
447+
case IIO_ACCEL:
448+
*val = 0;
449+
return fxls8962af_read_full_scale(data, val2);
450+
default:
451+
return -EINVAL;
452+
}
444453
case IIO_CHAN_INFO_SAMP_FREQ:
445454
return fxls8962af_read_samp_freq(data, val, val2);
446455
default:
@@ -736,9 +745,11 @@ static const struct iio_event_spec fxls8962af_event[] = {
736745
.type = IIO_TEMP, \
737746
.address = FXLS8962AF_TEMP_OUT, \
738747
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
748+
BIT(IIO_CHAN_INFO_SCALE) | \
739749
BIT(IIO_CHAN_INFO_OFFSET),\
740750
.scan_index = -1, \
741751
.scan_type = { \
752+
.sign = 's', \
742753
.realbits = 8, \
743754
.storagebits = 8, \
744755
}, \

drivers/iio/adc/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ config AD7173
129129
tristate "Analog Devices AD7173 driver"
130130
depends on SPI_MASTER
131131
select AD_SIGMA_DELTA
132-
select GPIO_REGMAP if GPIOLIB
133-
select REGMAP_SPI if GPIOLIB
132+
select GPIOLIB
133+
select GPIO_REGMAP
134+
select REGMAP_SPI
134135
help
135136
Say yes here to build support for Analog Devices AD7173 and similar ADC
136137
Currently supported models:

drivers/iio/adc/ad4851.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,23 +1034,23 @@ static int ad4858_parse_channels(struct iio_dev *indio_dev)
10341034
struct device *dev = &st->spi->dev;
10351035
struct iio_chan_spec *ad4851_channels;
10361036
const struct iio_chan_spec ad4851_chan = AD4858_IIO_CHANNEL;
1037-
int ret;
1037+
int ret, i = 0;
10381038

10391039
ret = ad4851_parse_channels_common(indio_dev, &ad4851_channels,
10401040
ad4851_chan);
10411041
if (ret < 0)
10421042
return ret;
10431043

10441044
device_for_each_child_node_scoped(dev, child) {
1045-
ad4851_channels->has_ext_scan_type = 1;
1045+
ad4851_channels[i].has_ext_scan_type = 1;
10461046
if (fwnode_property_read_bool(child, "bipolar")) {
1047-
ad4851_channels->ext_scan_type = ad4851_scan_type_20_b;
1048-
ad4851_channels->num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_b);
1047+
ad4851_channels[i].ext_scan_type = ad4851_scan_type_20_b;
1048+
ad4851_channels[i].num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_b);
10491049
} else {
1050-
ad4851_channels->ext_scan_type = ad4851_scan_type_20_u;
1051-
ad4851_channels->num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_u);
1050+
ad4851_channels[i].ext_scan_type = ad4851_scan_type_20_u;
1051+
ad4851_channels[i].num_ext_scan_type = ARRAY_SIZE(ad4851_scan_type_20_u);
10521052
}
1053-
ad4851_channels++;
1053+
i++;
10541054
}
10551055

10561056
indio_dev->channels = ad4851_channels;

drivers/iio/adc/ad7173.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,8 @@ struct ad7173_state {
230230
unsigned long long *config_cnts;
231231
struct clk *ext_clk;
232232
struct clk_hw int_clk_hw;
233-
#if IS_ENABLED(CONFIG_GPIOLIB)
234233
struct regmap *reg_gpiocon_regmap;
235234
struct gpio_regmap *gpio_regmap;
236-
#endif
237235
};
238236

239237
static unsigned int ad4115_sinc5_data_rates[] = {
@@ -288,8 +286,6 @@ static const char *const ad7173_clk_sel[] = {
288286
"ext-clk", "xtal"
289287
};
290288

291-
#if IS_ENABLED(CONFIG_GPIOLIB)
292-
293289
static const struct regmap_range ad7173_range_gpio[] = {
294290
regmap_reg_range(AD7173_REG_GPIO, AD7173_REG_GPIO),
295291
};
@@ -543,12 +539,6 @@ static int ad7173_gpio_init(struct ad7173_state *st)
543539

544540
return 0;
545541
}
546-
#else
547-
static int ad7173_gpio_init(struct ad7173_state *st)
548-
{
549-
return 0;
550-
}
551-
#endif /* CONFIG_GPIOLIB */
552542

553543
static struct ad7173_state *ad_sigma_delta_to_ad7173(struct ad_sigma_delta *sd)
554544
{
@@ -1797,10 +1787,7 @@ static int ad7173_probe(struct spi_device *spi)
17971787
if (ret)
17981788
return ret;
17991789

1800-
if (IS_ENABLED(CONFIG_GPIOLIB))
1801-
return ad7173_gpio_init(st);
1802-
1803-
return 0;
1790+
return ad7173_gpio_init(st);
18041791
}
18051792

18061793
static const struct of_device_id ad7173_of_match[] = {

drivers/iio/adc/ad7606.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -727,17 +727,16 @@ static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned int ch,
727727
goto error_ret;
728728

729729
chan = &indio_dev->channels[ch + 1];
730-
if (chan->scan_type.sign == 'u') {
731-
if (realbits > 16)
732-
*val = st->data.buf32[ch];
733-
else
734-
*val = st->data.buf16[ch];
735-
} else {
736-
if (realbits > 16)
737-
*val = sign_extend32(st->data.buf32[ch], realbits - 1);
738-
else
739-
*val = sign_extend32(st->data.buf16[ch], realbits - 1);
740-
}
730+
731+
if (realbits > 16)
732+
*val = st->data.buf32[ch];
733+
else
734+
*val = st->data.buf16[ch];
735+
736+
*val &= GENMASK(realbits - 1, 0);
737+
738+
if (chan->scan_type.sign == 's')
739+
*val = sign_extend32(*val, realbits - 1);
741740

742741
error_ret:
743742
if (!st->gpio_convst) {

drivers/iio/adc/ad7606_spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int ad7606_spi_reg_write(struct ad7606_state *st,
155155
struct spi_device *spi = to_spi_device(st->dev);
156156

157157
st->d16[0] = cpu_to_be16((st->bops->rd_wr_cmd(addr, 1) << 8) |
158-
(val & 0x1FF));
158+
(val & 0xFF));
159159

160160
return spi_write(spi, &st->d16[0], sizeof(st->d16[0]));
161161
}

drivers/iio/adc/ad7944.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ static int ad7944_single_conversion(struct ad7944_adc *adc,
377377

378378
if (chan->scan_type.sign == 's')
379379
*val = sign_extend32(*val, chan->scan_type.realbits - 1);
380+
else
381+
*val &= GENMASK(chan->scan_type.realbits - 1, 0);
380382

381383
return IIO_VAL_INT;
382384
}

drivers/iio/dac/adi-axi-dac.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
707707
{
708708
struct axi_dac_state *st = iio_backend_get_priv(back);
709709
int ret;
710+
u32 ival;
710711

711712
guard(mutex)(&st->lock);
712713

@@ -719,6 +720,13 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val,
719720
if (ret)
720721
return ret;
721722

723+
ret = regmap_read_poll_timeout(st->regmap,
724+
AXI_DAC_UI_STATUS_REG, ival,
725+
FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0,
726+
10, 100 * KILO);
727+
if (ret)
728+
return ret;
729+
722730
return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val);
723731
}
724732

drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,
6767
return IIO_VAL_INT;
6868
/*
6969
* T°C = (temp / 132.48) + 25
70-
* Tm°C = 1000 * ((temp * 100 / 13248) + 25)
70+
* Tm°C = 1000 * ((temp / 132.48) + 25)
71+
* Tm°C = 7.548309 * temp + 25000
72+
* Tm°C = (temp + 3312) * 7.548309
7173
* scale: 100000 / 13248 ~= 7.548309
72-
* offset: 25000
74+
* offset: 3312
7375
*/
7476
case IIO_CHAN_INFO_SCALE:
7577
*val = 7;
7678
*val2 = 548309;
7779
return IIO_VAL_INT_PLUS_MICRO;
7880
case IIO_CHAN_INFO_OFFSET:
79-
*val = 25000;
81+
*val = 3312;
8082
return IIO_VAL_INT;
8183
default:
8284
return -EINVAL;

0 commit comments

Comments
 (0)