Skip to content

Commit fda0573

Browse files
committed
Pull set of IIO fixes for 5.18 from Jonathan Cameron: "1st set of IIO fixes for the 5.18 cycle ad3552r: - Fix a bug with error codes being stored in unsigned local variable. - Fix IS_ERR when value is either NULL or not rather than ERR_PTR ad5446 - Fix shifting of read_raw value. ad5592r - Fix missing return value being set for a fwnode property read. ad7280a - Wrong variable being used to set thresholds. admv8818 - Kconfig dependency fix. ak8975 - Missing regulator disable in error path. bmi160 - Disable regulators in an error path. dac5571 - Fix chip id detection for devices with OF bindings. inv_icm42600 - Handle a case of a missing I2C NACK during initially configuration. ltc2688 - Fix voltage scaling where integer part was written twice and decimal part not at all. scd4x - Handle error before using value. sx9310 - Device property parsing against indio_dev->dev.of_node which hasn't been set yet. sx9324 - Fix hardware gain related maths. - Wrong defaults for precharge internal resistance register." * tag 'iio-fixes-for-5.18a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: imu: inv_icm42600: Fix I2C init possible nack iio: dac: ltc2688: fix voltage scale read iio:dac:ad3552r: Fix an IS_ERR() vs NULL check iio: sx9324: Fix default precharge internal resistance register iio: dac: ad5446: Fix read_raw not returning set value iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on() iio:proximity:sx9324: Fix hardware gain read/write iio:proximity:sx_common: Fix device property parsing on DT systems iio: adc: ad7280a: Fix wrong variable used when setting thresholds. iio:filter:admv8818: select REGMAP_SPI for ADMV8818 iio: dac: ad5592r: Fix the missing return value. iio: dac: dac5571: Fix chip id detection for OF devices iio:imu:bmi160: disable regulator in error path iio: scd4x: check return of scd4x_write_and_fetch iio: dac: ad3552r: fix signedness bug in ad3552r_reset()
2 parents 5b47b75 + b5d6ba0 commit fda0573

File tree

13 files changed

+85
-42
lines changed

13 files changed

+85
-42
lines changed

drivers/iio/adc/ad7280a.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,15 +745,15 @@ static int ad7280a_write_thresh(struct iio_dev *indio_dev,
745745
case IIO_EV_DIR_RISING:
746746
addr = AD7280A_CELL_OVERVOLTAGE_REG;
747747
ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, addr,
748-
1, val);
748+
1, value);
749749
if (ret)
750750
break;
751751
st->cell_threshhigh = value;
752752
break;
753753
case IIO_EV_DIR_FALLING:
754754
addr = AD7280A_CELL_UNDERVOLTAGE_REG;
755755
ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, addr,
756-
1, val);
756+
1, value);
757757
if (ret)
758758
break;
759759
st->cell_threshlow = value;
@@ -770,18 +770,18 @@ static int ad7280a_write_thresh(struct iio_dev *indio_dev,
770770
case IIO_EV_DIR_RISING:
771771
addr = AD7280A_AUX_ADC_OVERVOLTAGE_REG;
772772
ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, addr,
773-
1, val);
773+
1, value);
774774
if (ret)
775775
break;
776-
st->aux_threshhigh = val;
776+
st->aux_threshhigh = value;
777777
break;
778778
case IIO_EV_DIR_FALLING:
779779
addr = AD7280A_AUX_ADC_UNDERVOLTAGE_REG;
780780
ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, addr,
781-
1, val);
781+
1, value);
782782
if (ret)
783783
break;
784-
st->aux_threshlow = val;
784+
st->aux_threshlow = value;
785785
break;
786786
default:
787787
ret = -EINVAL;

drivers/iio/chemical/scd4x.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,15 @@ static ssize_t calibration_forced_value_store(struct device *dev,
471471
ret = scd4x_write_and_fetch(state, CMD_FRC, arg, &val, sizeof(val));
472472
mutex_unlock(&state->lock);
473473

474+
if (ret)
475+
return ret;
476+
474477
if (val == 0xff) {
475478
dev_err(dev, "forced calibration has failed");
476479
return -EINVAL;
477480
}
478481

479-
return ret ?: len;
482+
return len;
480483
}
481484

482485
static IIO_DEVICE_ATTR_RW(calibration_auto_enable, 0);

drivers/iio/dac/ad3552r.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static int ad3552r_reset(struct ad3552r_desc *dac)
656656
{
657657
struct reg_addr_pool addr;
658658
int ret;
659-
u16 val;
659+
int val;
660660

661661
dac->gpio_reset = devm_gpiod_get_optional(&dac->spi->dev, "reset",
662662
GPIOD_OUT_LOW);
@@ -809,10 +809,10 @@ static int ad3552r_configure_custom_gain(struct ad3552r_desc *dac,
809809

810810
gain_child = fwnode_get_named_child_node(child,
811811
"custom-output-range-config");
812-
if (IS_ERR(gain_child)) {
812+
if (!gain_child) {
813813
dev_err(dev,
814814
"mandatory custom-output-range-config property missing\n");
815-
return PTR_ERR(gain_child);
815+
return -EINVAL;
816816
}
817817

818818
dac->ch_data[ch].range_override = 1;

drivers/iio/dac/ad5446.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,
178178

179179
switch (m) {
180180
case IIO_CHAN_INFO_RAW:
181-
*val = st->cached_val;
181+
*val = st->cached_val >> chan->scan_type.shift;
182182
return IIO_VAL_INT;
183183
case IIO_CHAN_INFO_SCALE:
184184
*val = st->vref_mv;

drivers/iio/dac/ad5592r-base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ static int ad5592r_alloc_channels(struct iio_dev *iio_dev)
522522
if (!ret)
523523
st->channel_modes[reg] = tmp;
524524

525-
fwnode_property_read_u32(child, "adi,off-state", &tmp);
525+
ret = fwnode_property_read_u32(child, "adi,off-state", &tmp);
526526
if (!ret)
527527
st->channel_offstate[reg] = tmp;
528528
}

drivers/iio/dac/ltc2688.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static int ltc2688_read_raw(struct iio_dev *indio_dev,
298298
if (ret)
299299
return ret;
300300

301-
*val = 16;
301+
*val2 = 16;
302302
return IIO_VAL_FRACTIONAL_LOG2;
303303
case IIO_CHAN_INFO_CALIBBIAS:
304304
ret = regmap_read(st->regmap,

drivers/iio/dac/ti-dac5571.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/i2c.h>
2020
#include <linux/module.h>
2121
#include <linux/mod_devicetable.h>
22+
#include <linux/property.h>
2223
#include <linux/regulator/consumer.h>
2324

2425
enum chip_id {
@@ -311,6 +312,7 @@ static int dac5571_probe(struct i2c_client *client,
311312
const struct dac5571_spec *spec;
312313
struct dac5571_data *data;
313314
struct iio_dev *indio_dev;
315+
enum chip_id chip_id;
314316
int ret, i;
315317

316318
indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
@@ -326,7 +328,13 @@ static int dac5571_probe(struct i2c_client *client,
326328
indio_dev->modes = INDIO_DIRECT_MODE;
327329
indio_dev->channels = dac5571_channels;
328330

329-
spec = &dac5571_spec[id->driver_data];
331+
if (dev_fwnode(dev))
332+
chip_id = (uintptr_t)device_get_match_data(dev);
333+
else
334+
chip_id = id->driver_data;
335+
336+
spec = &dac5571_spec[chip_id];
337+
330338
indio_dev->num_channels = spec->num_channels;
331339
data->spec = spec;
332340

@@ -385,15 +393,15 @@ static int dac5571_remove(struct i2c_client *i2c)
385393
}
386394

387395
static const struct of_device_id dac5571_of_id[] = {
388-
{.compatible = "ti,dac5571"},
389-
{.compatible = "ti,dac6571"},
390-
{.compatible = "ti,dac7571"},
391-
{.compatible = "ti,dac5574"},
392-
{.compatible = "ti,dac6574"},
393-
{.compatible = "ti,dac7574"},
394-
{.compatible = "ti,dac5573"},
395-
{.compatible = "ti,dac6573"},
396-
{.compatible = "ti,dac7573"},
396+
{.compatible = "ti,dac5571", .data = (void *)single_8bit},
397+
{.compatible = "ti,dac6571", .data = (void *)single_10bit},
398+
{.compatible = "ti,dac7571", .data = (void *)single_12bit},
399+
{.compatible = "ti,dac5574", .data = (void *)quad_8bit},
400+
{.compatible = "ti,dac6574", .data = (void *)quad_10bit},
401+
{.compatible = "ti,dac7574", .data = (void *)quad_12bit},
402+
{.compatible = "ti,dac5573", .data = (void *)quad_8bit},
403+
{.compatible = "ti,dac6573", .data = (void *)quad_10bit},
404+
{.compatible = "ti,dac7573", .data = (void *)quad_12bit},
397405
{}
398406
};
399407
MODULE_DEVICE_TABLE(of, dac5571_of_id);

drivers/iio/filter/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ menu "Filters"
88
config ADMV8818
99
tristate "Analog Devices ADMV8818 High-Pass and Low-Pass Filter"
1010
depends on SPI && COMMON_CLK && 64BIT
11+
select REGMAP_SPI
1112
help
1213
Say yes here to build support for Analog Devices ADMV8818
1314
2 GHz to 18 GHz, Digitally Tunable, High-Pass and Low-Pass Filter.

drivers/iio/imu/bmi160/bmi160_core.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static int bmi160_chip_init(struct bmi160_data *data, bool use_spi)
730730

731731
ret = regmap_write(data->regmap, BMI160_REG_CMD, BMI160_CMD_SOFTRESET);
732732
if (ret)
733-
return ret;
733+
goto disable_regulator;
734734

735735
usleep_range(BMI160_SOFTRESET_USLEEP, BMI160_SOFTRESET_USLEEP + 1);
736736

@@ -741,29 +741,37 @@ static int bmi160_chip_init(struct bmi160_data *data, bool use_spi)
741741
if (use_spi) {
742742
ret = regmap_read(data->regmap, BMI160_REG_DUMMY, &val);
743743
if (ret)
744-
return ret;
744+
goto disable_regulator;
745745
}
746746

747747
ret = regmap_read(data->regmap, BMI160_REG_CHIP_ID, &val);
748748
if (ret) {
749749
dev_err(dev, "Error reading chip id\n");
750-
return ret;
750+
goto disable_regulator;
751751
}
752752
if (val != BMI160_CHIP_ID_VAL) {
753753
dev_err(dev, "Wrong chip id, got %x expected %x\n",
754754
val, BMI160_CHIP_ID_VAL);
755-
return -ENODEV;
755+
ret = -ENODEV;
756+
goto disable_regulator;
756757
}
757758

758759
ret = bmi160_set_mode(data, BMI160_ACCEL, true);
759760
if (ret)
760-
return ret;
761+
goto disable_regulator;
761762

762763
ret = bmi160_set_mode(data, BMI160_GYRO, true);
763764
if (ret)
764-
return ret;
765+
goto disable_accel;
765766

766767
return 0;
768+
769+
disable_accel:
770+
bmi160_set_mode(data, BMI160_ACCEL, false);
771+
772+
disable_regulator:
773+
regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
774+
return ret;
767775
}
768776

769777
static int bmi160_data_rdy_trigger_set_state(struct iio_trigger *trig,

drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ static int inv_icm42600_i2c_bus_setup(struct inv_icm42600_state *st)
1818
unsigned int mask, val;
1919
int ret;
2020

21-
/* setup interface registers */
22-
ret = regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG6,
23-
INV_ICM42600_INTF_CONFIG6_MASK,
24-
INV_ICM42600_INTF_CONFIG6_I3C_EN);
25-
if (ret)
26-
return ret;
21+
/*
22+
* setup interface registers
23+
* This register write to REG_INTF_CONFIG6 enables a spike filter that
24+
* is impacting the line and can prevent the I2C ACK to be seen by the
25+
* controller. So we don't test the return value.
26+
*/
27+
regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG6,
28+
INV_ICM42600_INTF_CONFIG6_MASK,
29+
INV_ICM42600_INTF_CONFIG6_I3C_EN);
2730

2831
ret = regmap_update_bits(st->map, INV_ICM42600_REG_INTF_CONFIG4,
2932
INV_ICM42600_INTF_CONFIG4_I3C_BUS_ONLY, 0);

0 commit comments

Comments
 (0)