IIO: Fixes for 6.12, set 2

Usual mixed back of fixes for ancient bugs and some more recently
 introduced problems.
 
 gts-helper module
 - Memory leak fixes for this library code to handle complex gain cases.
 adi,ad7124
 - Fix a divide by zero that can be triggered from userspace.
 adi,ad7380
 - Various supply fixes. Includes some minor rework that simplifies the
   fix though increases the apparent scale of the change.
 adi,ad9832
 - Avoid a potential divide by zero if clk_get_rate() returns 0.
 adi,ltc2642
 - Fix wrong Kconfig regmap dependency.
 vishay,veml6030
 - Fix a scaling problem with decimal part of processed channel.
   Note that only the illuminance channel is fixed as a larger series
   of cleanups not suitable for this point in the rc cycle removes
   the intensity channel anyway.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmccxrARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foj+mw/+L/0EfK5svAzsEApSE+xwKPo2yP8fp8D1
 6VycANSRzEjMW1RdV3n6Z3I3hcnU+p3VJ6lz8kbYQGwmDEQWw+q6a6/ONyrwg8Zx
 JM0qj3HABZf3tiPYdTgDHTVKUCE93noLxPfTgpRgtDV8FyirEw3/LL/jMxYBYggx
 19xV3y6gQQb8Hs7YwcVAMp/nilMX3OpvCN8nPbM/ZEcuB7IDZomQ3qgIuAR4FPRc
 I2wiqoQGgQAnaa91UQypsONkJRKoi7UzUWkGZ9SrlVrnehiCJlLbkOHg6Quzab8N
 GxEL3r//XPFb5i/2i4/iSvKd62Rg5z435H2dAYq7A52SmC0+uErJ6eSayxuERy6V
 x8V/GjkpTSq7TVSx4Qh0Q0MKoFZ60Kw2RjMbvjSyDN+45vEnXMUnXnAe/QU4Blcf
 1t+fkKn0RKnJ8GLIkG5Ih0MGz2JfZO+7qfg+IhlK8DqwpbJZpxdaaIVRgsO+UhH+
 rtsCDB+nKHWykZafFsF7lig/F2CFzANiNyEk4q4jbHWivm52+vEZYok0cFWYf+3v
 N19sEKTrauuyx3E/Q5ualSG/KMyOoHk/rNOeS1l7ORtUWJoeMHP9FnVssFfSIZmI
 DCNmk3p3ByasjVl2rnXITTandW8mRujmB4U3rlcgaFYZMxy6AKVQvoK6HLTuic7X
 dx422m7ijoI=
 =RFc+
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-6.12b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

IIO: Fixes for 6.12, set 2

Usual mixed back of fixes for ancient bugs and some more recently
introduced problems.

gts-helper module
- Memory leak fixes for this library code to handle complex gain cases.
adi,ad7124
- Fix a divide by zero that can be triggered from userspace.
adi,ad7380
- Various supply fixes. Includes some minor rework that simplifies the
  fix though increases the apparent scale of the change.
adi,ad9832
- Avoid a potential divide by zero if clk_get_rate() returns 0.
adi,ltc2642
- Fix wrong Kconfig regmap dependency.
vishay,veml6030
- Fix a scaling problem with decimal part of processed channel.
  Note that only the illuminance channel is fixed as a larger series
  of cleanups not suitable for this point in the rc cycle removes
  the intensity channel anyway.

* tag 'iio-fixes-for-6.12b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: dac: Kconfig: Fix build error for ltc2664
  iio: adc: ad7124: fix division by zero in ad7124_set_channel_odr()
  staging: iio: frequency: ad9832: fix division by zero in ad9832_calc_freqreg()
  docs: iio: ad7380: fix supply for ad7380-4
  iio: adc: ad7380: fix supplies for ad7380-4
  iio: adc: ad7380: add missing supplies
  iio: adc: ad7380: use devm_regulator_get_enable_read_voltage()
  dt-bindings: iio: adc: ad7380: fix ad7380-4 reference supply
  iio: light: veml6030: fix microlux value calculation
  iio: gts-helper: Fix memory leaks for the error path of iio_gts_build_avail_scale_table()
  iio: gts-helper: Fix memory leaks in iio_gts_build_avail_scale_table()
This commit is contained in:
Greg Kroah-Hartman 2024-10-29 04:10:12 +01:00
commit d0bc3b92fb
8 changed files with 121 additions and 66 deletions

View File

@ -67,6 +67,10 @@ properties:
A 2.5V to 3.3V supply for the external reference voltage. When omitted, A 2.5V to 3.3V supply for the external reference voltage. When omitted,
the internal 2.5V reference is used. the internal 2.5V reference is used.
refin-supply:
description:
A 2.5V to 3.3V supply for external reference voltage, for ad7380-4 only.
aina-supply: aina-supply:
description: description:
The common mode voltage supply for the AINA- pin on pseudo-differential The common mode voltage supply for the AINA- pin on pseudo-differential
@ -135,6 +139,23 @@ allOf:
ainc-supply: false ainc-supply: false
aind-supply: false aind-supply: false
# ad7380-4 uses refin-supply as external reference.
# All other chips from ad738x family use refio as optional external reference.
# When refio-supply is omitted, internal reference is used.
- if:
properties:
compatible:
enum:
- adi,ad7380-4
then:
properties:
refio-supply: false
required:
- refin-supply
else:
properties:
refin-supply: false
examples: examples:
- | - |
#include <dt-bindings/interrupt-controller/irq.h> #include <dt-bindings/interrupt-controller/irq.h>

View File

@ -41,13 +41,22 @@ supports only 1 SDO line.
Reference voltage Reference voltage
----------------- -----------------
2 possible reference voltage sources are supported: ad7380-4
~~~~~~~~
ad7380-4 supports only an external reference voltage (2.5V to 3.3V). It must be
declared in the device tree as ``refin-supply``.
All other devices from ad738x family
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All other devices from ad738x support 2 possible reference voltage sources:
- Internal reference (2.5V) - Internal reference (2.5V)
- External reference (2.5V to 3.3V) - External reference (2.5V to 3.3V)
The source is determined by the device tree. If ``refio-supply`` is present, The source is determined by the device tree. If ``refio-supply`` is present,
then the external reference is used, else the internal reference is used. then it is used as external reference, else the internal reference is used.
Oversampling and resolution boost Oversampling and resolution boost
--------------------------------- ---------------------------------

View File

@ -637,7 +637,7 @@ static int ad7124_write_raw(struct iio_dev *indio_dev,
switch (info) { switch (info) {
case IIO_CHAN_INFO_SAMP_FREQ: case IIO_CHAN_INFO_SAMP_FREQ:
if (val2 != 0) { if (val2 != 0 || val == 0) {
ret = -EINVAL; ret = -EINVAL;
break; break;
} }

View File

@ -75,6 +75,7 @@
#define T_CONVERT_NS 190 /* conversion time */ #define T_CONVERT_NS 190 /* conversion time */
#define T_CONVERT_0_NS 10 /* 1st conversion start time (oversampling) */ #define T_CONVERT_0_NS 10 /* 1st conversion start time (oversampling) */
#define T_CONVERT_X_NS 500 /* xth conversion start time (oversampling) */ #define T_CONVERT_X_NS 500 /* xth conversion start time (oversampling) */
#define T_POWERUP_US 5000 /* Power up */
struct ad7380_timing_specs { struct ad7380_timing_specs {
const unsigned int t_csh_ns; /* CS minimum high time */ const unsigned int t_csh_ns; /* CS minimum high time */
@ -86,6 +87,9 @@ struct ad7380_chip_info {
unsigned int num_channels; unsigned int num_channels;
unsigned int num_simult_channels; unsigned int num_simult_channels;
bool has_mux; bool has_mux;
const char * const *supplies;
unsigned int num_supplies;
bool external_ref_only;
const char * const *vcm_supplies; const char * const *vcm_supplies;
unsigned int num_vcm_supplies; unsigned int num_vcm_supplies;
const unsigned long *available_scan_masks; const unsigned long *available_scan_masks;
@ -243,6 +247,10 @@ DEFINE_AD7380_8_CHANNEL(ad7386_4_channels, 16, 0, u);
DEFINE_AD7380_8_CHANNEL(ad7387_4_channels, 14, 0, u); DEFINE_AD7380_8_CHANNEL(ad7387_4_channels, 14, 0, u);
DEFINE_AD7380_8_CHANNEL(ad7388_4_channels, 12, 0, u); DEFINE_AD7380_8_CHANNEL(ad7388_4_channels, 12, 0, u);
static const char * const ad7380_supplies[] = {
"vcc", "vlogic",
};
static const char * const ad7380_2_channel_vcm_supplies[] = { static const char * const ad7380_2_channel_vcm_supplies[] = {
"aina", "ainb", "aina", "ainb",
}; };
@ -338,6 +346,8 @@ static const struct ad7380_chip_info ad7380_chip_info = {
.channels = ad7380_channels, .channels = ad7380_channels,
.num_channels = ARRAY_SIZE(ad7380_channels), .num_channels = ARRAY_SIZE(ad7380_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
}; };
@ -347,6 +357,8 @@ static const struct ad7380_chip_info ad7381_chip_info = {
.channels = ad7381_channels, .channels = ad7381_channels,
.num_channels = ARRAY_SIZE(ad7381_channels), .num_channels = ARRAY_SIZE(ad7381_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
}; };
@ -356,6 +368,8 @@ static const struct ad7380_chip_info ad7383_chip_info = {
.channels = ad7383_channels, .channels = ad7383_channels,
.num_channels = ARRAY_SIZE(ad7383_channels), .num_channels = ARRAY_SIZE(ad7383_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.vcm_supplies = ad7380_2_channel_vcm_supplies, .vcm_supplies = ad7380_2_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
@ -367,6 +381,8 @@ static const struct ad7380_chip_info ad7384_chip_info = {
.channels = ad7384_channels, .channels = ad7384_channels,
.num_channels = ARRAY_SIZE(ad7384_channels), .num_channels = ARRAY_SIZE(ad7384_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.vcm_supplies = ad7380_2_channel_vcm_supplies, .vcm_supplies = ad7380_2_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
.available_scan_masks = ad7380_2_channel_scan_masks, .available_scan_masks = ad7380_2_channel_scan_masks,
@ -378,6 +394,8 @@ static const struct ad7380_chip_info ad7386_chip_info = {
.channels = ad7386_channels, .channels = ad7386_channels,
.num_channels = ARRAY_SIZE(ad7386_channels), .num_channels = ARRAY_SIZE(ad7386_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.has_mux = true, .has_mux = true,
.available_scan_masks = ad7380_2x2_channel_scan_masks, .available_scan_masks = ad7380_2x2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
@ -388,6 +406,8 @@ static const struct ad7380_chip_info ad7387_chip_info = {
.channels = ad7387_channels, .channels = ad7387_channels,
.num_channels = ARRAY_SIZE(ad7387_channels), .num_channels = ARRAY_SIZE(ad7387_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.has_mux = true, .has_mux = true,
.available_scan_masks = ad7380_2x2_channel_scan_masks, .available_scan_masks = ad7380_2x2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
@ -398,6 +418,8 @@ static const struct ad7380_chip_info ad7388_chip_info = {
.channels = ad7388_channels, .channels = ad7388_channels,
.num_channels = ARRAY_SIZE(ad7388_channels), .num_channels = ARRAY_SIZE(ad7388_channels),
.num_simult_channels = 2, .num_simult_channels = 2,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.has_mux = true, .has_mux = true,
.available_scan_masks = ad7380_2x2_channel_scan_masks, .available_scan_masks = ad7380_2x2_channel_scan_masks,
.timing_specs = &ad7380_timing, .timing_specs = &ad7380_timing,
@ -408,6 +430,9 @@ static const struct ad7380_chip_info ad7380_4_chip_info = {
.channels = ad7380_4_channels, .channels = ad7380_4_channels,
.num_channels = ARRAY_SIZE(ad7380_4_channels), .num_channels = ARRAY_SIZE(ad7380_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.external_ref_only = true,
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
}; };
@ -417,6 +442,8 @@ static const struct ad7380_chip_info ad7381_4_chip_info = {
.channels = ad7381_4_channels, .channels = ad7381_4_channels,
.num_channels = ARRAY_SIZE(ad7381_4_channels), .num_channels = ARRAY_SIZE(ad7381_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
}; };
@ -426,6 +453,8 @@ static const struct ad7380_chip_info ad7383_4_chip_info = {
.channels = ad7383_4_channels, .channels = ad7383_4_channels,
.num_channels = ARRAY_SIZE(ad7383_4_channels), .num_channels = ARRAY_SIZE(ad7383_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.vcm_supplies = ad7380_4_channel_vcm_supplies, .vcm_supplies = ad7380_4_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
@ -437,6 +466,8 @@ static const struct ad7380_chip_info ad7384_4_chip_info = {
.channels = ad7384_4_channels, .channels = ad7384_4_channels,
.num_channels = ARRAY_SIZE(ad7384_4_channels), .num_channels = ARRAY_SIZE(ad7384_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.vcm_supplies = ad7380_4_channel_vcm_supplies, .vcm_supplies = ad7380_4_channel_vcm_supplies,
.num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies), .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
.available_scan_masks = ad7380_4_channel_scan_masks, .available_scan_masks = ad7380_4_channel_scan_masks,
@ -448,6 +479,8 @@ static const struct ad7380_chip_info ad7386_4_chip_info = {
.channels = ad7386_4_channels, .channels = ad7386_4_channels,
.num_channels = ARRAY_SIZE(ad7386_4_channels), .num_channels = ARRAY_SIZE(ad7386_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.has_mux = true, .has_mux = true,
.available_scan_masks = ad7380_2x4_channel_scan_masks, .available_scan_masks = ad7380_2x4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
@ -458,6 +491,8 @@ static const struct ad7380_chip_info ad7387_4_chip_info = {
.channels = ad7387_4_channels, .channels = ad7387_4_channels,
.num_channels = ARRAY_SIZE(ad7387_4_channels), .num_channels = ARRAY_SIZE(ad7387_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.has_mux = true, .has_mux = true,
.available_scan_masks = ad7380_2x4_channel_scan_masks, .available_scan_masks = ad7380_2x4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
@ -468,6 +503,8 @@ static const struct ad7380_chip_info ad7388_4_chip_info = {
.channels = ad7388_4_channels, .channels = ad7388_4_channels,
.num_channels = ARRAY_SIZE(ad7388_4_channels), .num_channels = ARRAY_SIZE(ad7388_4_channels),
.num_simult_channels = 4, .num_simult_channels = 4,
.supplies = ad7380_supplies,
.num_supplies = ARRAY_SIZE(ad7380_supplies),
.has_mux = true, .has_mux = true,
.available_scan_masks = ad7380_2x4_channel_scan_masks, .available_scan_masks = ad7380_2x4_channel_scan_masks,
.timing_specs = &ad7380_4_timing, .timing_specs = &ad7380_4_timing,
@ -956,7 +993,7 @@ static const struct iio_info ad7380_info = {
.debugfs_reg_access = &ad7380_debugfs_reg_access, .debugfs_reg_access = &ad7380_debugfs_reg_access,
}; };
static int ad7380_init(struct ad7380_state *st, struct regulator *vref) static int ad7380_init(struct ad7380_state *st, bool external_ref_en)
{ {
int ret; int ret;
@ -968,13 +1005,13 @@ static int ad7380_init(struct ad7380_state *st, struct regulator *vref)
if (ret < 0) if (ret < 0)
return ret; return ret;
/* select internal or external reference voltage */ if (external_ref_en) {
ret = regmap_update_bits(st->regmap, AD7380_REG_ADDR_CONFIG1, /* select external reference voltage */
AD7380_CONFIG1_REFSEL, ret = regmap_set_bits(st->regmap, AD7380_REG_ADDR_CONFIG1,
FIELD_PREP(AD7380_CONFIG1_REFSEL, AD7380_CONFIG1_REFSEL);
vref ? 1 : 0)); if (ret < 0)
if (ret < 0) return ret;
return ret; }
/* This is the default value after reset. */ /* This is the default value after reset. */
st->oversampling_ratio = 1; st->oversampling_ratio = 1;
@ -987,16 +1024,11 @@ static int ad7380_init(struct ad7380_state *st, struct regulator *vref)
FIELD_PREP(AD7380_CONFIG2_SDO, 1)); FIELD_PREP(AD7380_CONFIG2_SDO, 1));
} }
static void ad7380_regulator_disable(void *p)
{
regulator_disable(p);
}
static int ad7380_probe(struct spi_device *spi) static int ad7380_probe(struct spi_device *spi)
{ {
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct ad7380_state *st; struct ad7380_state *st;
struct regulator *vref; bool external_ref_en;
int ret, i; int ret, i;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
@ -1009,36 +1041,38 @@ static int ad7380_probe(struct spi_device *spi)
if (!st->chip_info) if (!st->chip_info)
return dev_err_probe(&spi->dev, -EINVAL, "missing match data\n"); return dev_err_probe(&spi->dev, -EINVAL, "missing match data\n");
vref = devm_regulator_get_optional(&spi->dev, "refio"); ret = devm_regulator_bulk_get_enable(&spi->dev, st->chip_info->num_supplies,
if (IS_ERR(vref)) { st->chip_info->supplies);
if (PTR_ERR(vref) != -ENODEV)
return dev_err_probe(&spi->dev, PTR_ERR(vref),
"Failed to get refio regulator\n");
vref = NULL; if (ret)
} return dev_err_probe(&spi->dev, ret,
"Failed to enable power supplies\n");
fsleep(T_POWERUP_US);
/* if (st->chip_info->external_ref_only) {
* If there is no REFIO supply, then it means that we are using ret = devm_regulator_get_enable_read_voltage(&spi->dev,
* the internal 2.5V reference, otherwise REFIO is reference voltage. "refin");
*/
if (vref) {
ret = regulator_enable(vref);
if (ret)
return ret;
ret = devm_add_action_or_reset(&spi->dev,
ad7380_regulator_disable, vref);
if (ret)
return ret;
ret = regulator_get_voltage(vref);
if (ret < 0) if (ret < 0)
return ret; return dev_err_probe(&spi->dev, ret,
"Failed to get refin regulator\n");
st->vref_mv = ret / 1000; st->vref_mv = ret / 1000;
/* these chips don't have a register bit for this */
external_ref_en = false;
} else { } else {
st->vref_mv = AD7380_INTERNAL_REF_MV; /*
* If there is no REFIO supply, then it means that we are using
* the internal reference, otherwise REFIO is reference voltage.
*/
ret = devm_regulator_get_enable_read_voltage(&spi->dev,
"refio");
if (ret < 0 && ret != -ENODEV)
return dev_err_probe(&spi->dev, ret,
"Failed to get refio regulator\n");
external_ref_en = ret != -ENODEV;
st->vref_mv = external_ref_en ? ret / 1000 : AD7380_INTERNAL_REF_MV;
} }
if (st->chip_info->num_vcm_supplies > ARRAY_SIZE(st->vcm_mv)) if (st->chip_info->num_vcm_supplies > ARRAY_SIZE(st->vcm_mv))
@ -1050,27 +1084,13 @@ static int ad7380_probe(struct spi_device *spi)
* input pin. * input pin.
*/ */
for (i = 0; i < st->chip_info->num_vcm_supplies; i++) { for (i = 0; i < st->chip_info->num_vcm_supplies; i++) {
struct regulator *vcm; const char *vcm = st->chip_info->vcm_supplies[i];
vcm = devm_regulator_get(&spi->dev, ret = devm_regulator_get_enable_read_voltage(&spi->dev, vcm);
st->chip_info->vcm_supplies[i]);
if (IS_ERR(vcm))
return dev_err_probe(&spi->dev, PTR_ERR(vcm),
"Failed to get %s regulator\n",
st->chip_info->vcm_supplies[i]);
ret = regulator_enable(vcm);
if (ret)
return ret;
ret = devm_add_action_or_reset(&spi->dev,
ad7380_regulator_disable, vcm);
if (ret)
return ret;
ret = regulator_get_voltage(vcm);
if (ret < 0) if (ret < 0)
return ret; return dev_err_probe(&spi->dev, ret,
"Failed to get %s regulator\n",
vcm);
st->vcm_mv[i] = ret / 1000; st->vcm_mv[i] = ret / 1000;
} }
@ -1135,7 +1155,7 @@ static int ad7380_probe(struct spi_device *spi)
if (ret) if (ret)
return ret; return ret;
ret = ad7380_init(st, vref); ret = ad7380_init(st, external_ref_en);
if (ret) if (ret)
return ret; return ret;

View File

@ -380,7 +380,7 @@ config LTC2632
config LTC2664 config LTC2664
tristate "Analog Devices LTC2664 and LTC2672 DAC SPI driver" tristate "Analog Devices LTC2664 and LTC2672 DAC SPI driver"
depends on SPI depends on SPI
select REGMAP select REGMAP_SPI
help help
Say yes here to build support for Analog Devices Say yes here to build support for Analog Devices
LTC2664 and LTC2672 converters (DAC). LTC2664 and LTC2672 converters (DAC).

View File

@ -307,13 +307,15 @@ static int iio_gts_build_avail_scale_table(struct iio_gts *gts)
if (ret) if (ret)
goto err_free_out; goto err_free_out;
for (i = 0; i < gts->num_itime; i++)
kfree(per_time_gains[i]);
kfree(per_time_gains); kfree(per_time_gains);
gts->per_time_avail_scale_tables = per_time_scales; gts->per_time_avail_scale_tables = per_time_scales;
return 0; return 0;
err_free_out: err_free_out:
for (i--; i; i--) { for (i--; i >= 0; i--) {
kfree(per_time_scales[i]); kfree(per_time_scales[i]);
kfree(per_time_gains[i]); kfree(per_time_gains[i]);
} }

View File

@ -522,7 +522,7 @@ static int veml6030_read_raw(struct iio_dev *indio_dev,
} }
if (mask == IIO_CHAN_INFO_PROCESSED) { if (mask == IIO_CHAN_INFO_PROCESSED) {
*val = (reg * data->cur_resolution) / 10000; *val = (reg * data->cur_resolution) / 10000;
*val2 = (reg * data->cur_resolution) % 10000; *val2 = (reg * data->cur_resolution) % 10000 * 100;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
} }
*val = reg; *val = reg;

View File

@ -129,12 +129,15 @@ static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
static int ad9832_write_frequency(struct ad9832_state *st, static int ad9832_write_frequency(struct ad9832_state *st,
unsigned int addr, unsigned long fout) unsigned int addr, unsigned long fout)
{ {
unsigned long clk_freq;
unsigned long regval; unsigned long regval;
if (fout > (clk_get_rate(st->mclk) / 2)) clk_freq = clk_get_rate(st->mclk);
if (!clk_freq || fout > (clk_freq / 2))
return -EINVAL; return -EINVAL;
regval = ad9832_calc_freqreg(clk_get_rate(st->mclk), fout); regval = ad9832_calc_freqreg(clk_freq, fout);
st->freq_data[0] = cpu_to_be16((AD9832_CMD_FRE8BITSW << CMD_SHIFT) | st->freq_data[0] = cpu_to_be16((AD9832_CMD_FRE8BITSW << CMD_SHIFT) |
(addr << ADD_SHIFT) | (addr << ADD_SHIFT) |