Skip to content

Commit 63b93e7

Browse files
committed
Merge tag 'iio-fixes-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus
Jonathan writes: 1st set of IIO fixes for 6.5 Usual mixed bag of fixes for recently introduced issues and ones from way back that have recently been noticed. * core - Avoid a device with no parent issues seen on the dummy example device. * adi,ad71145 - Drop ref now that dt-schema supports -nanoamp. * adi,ad7192 - Fix wrong bit set for enabling AC excitation and exposure of control on devices without the feature. * adi,admv1013 - Don't ignore errors from regulator_get_voltage(). * amlogic,meson-adc - Make sure clocks enabled early enough. * google,cros_ec - Fix undersized cros_ec_command allocation that resulted in a buffer overrun. * rohm,bu27008 - Fix truncation issue with scale format that prevents smallest value being set - Report intensity as unsigned. Previously large values would be interpretted as negative intensities (and odd concept). * rohm,bu27034 - Fix truncation issue with scale format that prevents smallest value being set. * st,lsm6dsx - Return an error code, not false (which is 0 and hence success) to indicate ACPI mount matrix retrieval failed due to no ACPI support. * ti,ina2xx - Avoid a NULL pointer dereference if fall back compatible is used. * tag 'iio-fixes-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: cros_ec: Fix the allocation size for cros_ec_command iio: imu: lsm6dsx: Fix mount matrix retrieval iio: adc: meson: fix core clock enable/disable moment iio: core: Prevent invalid memory access when there is no parent iio: frequency: admv1013: propagate errors from regulator_get_voltage() dt-bindings: iio: adi,ad74115: remove ref from -nanoamp iio: adc: ina2xx: avoid NULL pointer dereference on OF device match iio: light: bu27008: Fix intensity data type iio: light: bu27008: Fix scale format iio: light: bu27034: Fix scale format iio: adc: ad7192: Fix ac excitation feature
2 parents bb6578b + 8a46290 commit 63b93e7

File tree

10 files changed

+73
-36
lines changed

10 files changed

+73
-36
lines changed

Documentation/devicetree/bindings/iio/addac/adi,ad74115.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ properties:
216216
description: Whether to enable burnout current for EXT1.
217217

218218
adi,ext1-burnout-current-nanoamp:
219-
$ref: /schemas/types.yaml#/definitions/uint32
220219
description:
221220
Burnout current in nanoamps to be applied to EXT1.
222221
enum: [0, 50, 500, 1000, 10000]
@@ -233,7 +232,6 @@ properties:
233232
description: Whether to enable burnout current for EXT2.
234233

235234
adi,ext2-burnout-current-nanoamp:
236-
$ref: /schemas/types.yaml#/definitions/uint32
237235
description: Burnout current in nanoamps to be applied to EXT2.
238236
enum: [0, 50, 500, 1000, 10000]
239237
default: 0
@@ -249,7 +247,6 @@ properties:
249247
description: Whether to enable burnout current for VIOUT.
250248

251249
adi,viout-burnout-current-nanoamp:
252-
$ref: /schemas/types.yaml#/definitions/uint32
253250
description: Burnout current in nanoamps to be applied to VIOUT.
254251
enum: [0, 1000, 10000]
255252
default: 0

drivers/iio/adc/ad7192.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#define AD7192_MODE_STA_MASK BIT(20) /* Status Register transmission Mask */
6363
#define AD7192_MODE_CLKSRC(x) (((x) & 0x3) << 18) /* Clock Source Select */
6464
#define AD7192_MODE_SINC3 BIT(15) /* SINC3 Filter Select */
65-
#define AD7192_MODE_ACX BIT(14) /* AC excitation enable(AD7195 only)*/
6665
#define AD7192_MODE_ENPAR BIT(13) /* Parity Enable */
6766
#define AD7192_MODE_CLKDIV BIT(12) /* Clock divide by 2 (AD7190/2 only)*/
6867
#define AD7192_MODE_SCYCLE BIT(11) /* Single cycle conversion */
@@ -91,6 +90,7 @@
9190
/* Configuration Register Bit Designations (AD7192_REG_CONF) */
9291

9392
#define AD7192_CONF_CHOP BIT(23) /* CHOP enable */
93+
#define AD7192_CONF_ACX BIT(22) /* AC excitation enable(AD7195 only) */
9494
#define AD7192_CONF_REFSEL BIT(20) /* REFIN1/REFIN2 Reference Select */
9595
#define AD7192_CONF_CHAN(x) ((x) << 8) /* Channel select */
9696
#define AD7192_CONF_CHAN_MASK (0x7FF << 8) /* Channel select mask */
@@ -472,7 +472,7 @@ static ssize_t ad7192_show_ac_excitation(struct device *dev,
472472
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
473473
struct ad7192_state *st = iio_priv(indio_dev);
474474

475-
return sysfs_emit(buf, "%d\n", !!(st->mode & AD7192_MODE_ACX));
475+
return sysfs_emit(buf, "%d\n", !!(st->conf & AD7192_CONF_ACX));
476476
}
477477

478478
static ssize_t ad7192_show_bridge_switch(struct device *dev,
@@ -513,13 +513,13 @@ static ssize_t ad7192_set(struct device *dev,
513513

514514
ad_sd_write_reg(&st->sd, AD7192_REG_GPOCON, 1, st->gpocon);
515515
break;
516-
case AD7192_REG_MODE:
516+
case AD7192_REG_CONF:
517517
if (val)
518-
st->mode |= AD7192_MODE_ACX;
518+
st->conf |= AD7192_CONF_ACX;
519519
else
520-
st->mode &= ~AD7192_MODE_ACX;
520+
st->conf &= ~AD7192_CONF_ACX;
521521

522-
ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
522+
ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
523523
break;
524524
default:
525525
ret = -EINVAL;
@@ -579,12 +579,11 @@ static IIO_DEVICE_ATTR(bridge_switch_en, 0644,
579579

580580
static IIO_DEVICE_ATTR(ac_excitation_en, 0644,
581581
ad7192_show_ac_excitation, ad7192_set,
582-
AD7192_REG_MODE);
582+
AD7192_REG_CONF);
583583

584584
static struct attribute *ad7192_attributes[] = {
585585
&iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr,
586586
&iio_dev_attr_bridge_switch_en.dev_attr.attr,
587-
&iio_dev_attr_ac_excitation_en.dev_attr.attr,
588587
NULL
589588
};
590589

@@ -595,6 +594,7 @@ static const struct attribute_group ad7192_attribute_group = {
595594
static struct attribute *ad7195_attributes[] = {
596595
&iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr,
597596
&iio_dev_attr_bridge_switch_en.dev_attr.attr,
597+
&iio_dev_attr_ac_excitation_en.dev_attr.attr,
598598
NULL
599599
};
600600

drivers/iio/adc/ina2xx-adc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static const struct regmap_config ina2xx_regmap_config = {
124124
enum ina2xx_ids { ina219, ina226 };
125125

126126
struct ina2xx_config {
127+
const char *name;
127128
u16 config_default;
128129
int calibration_value;
129130
int shunt_voltage_lsb; /* nV */
@@ -155,6 +156,7 @@ struct ina2xx_chip_info {
155156

156157
static const struct ina2xx_config ina2xx_config[] = {
157158
[ina219] = {
159+
.name = "ina219",
158160
.config_default = INA219_CONFIG_DEFAULT,
159161
.calibration_value = 4096,
160162
.shunt_voltage_lsb = 10000,
@@ -164,6 +166,7 @@ static const struct ina2xx_config ina2xx_config[] = {
164166
.chip_id = ina219,
165167
},
166168
[ina226] = {
169+
.name = "ina226",
167170
.config_default = INA226_CONFIG_DEFAULT,
168171
.calibration_value = 2048,
169172
.shunt_voltage_lsb = 2500,
@@ -996,7 +999,7 @@ static int ina2xx_probe(struct i2c_client *client)
996999
/* Patch the current config register with default. */
9971000
val = chip->config->config_default;
9981001

999-
if (id->driver_data == ina226) {
1002+
if (type == ina226) {
10001003
ina226_set_average(chip, INA226_DEFAULT_AVG, &val);
10011004
ina226_set_int_time_vbus(chip, INA226_DEFAULT_IT, &val);
10021005
ina226_set_int_time_vshunt(chip, INA226_DEFAULT_IT, &val);
@@ -1015,7 +1018,7 @@ static int ina2xx_probe(struct i2c_client *client)
10151018
}
10161019

10171020
indio_dev->modes = INDIO_DIRECT_MODE;
1018-
if (id->driver_data == ina226) {
1021+
if (type == ina226) {
10191022
indio_dev->channels = ina226_channels;
10201023
indio_dev->num_channels = ARRAY_SIZE(ina226_channels);
10211024
indio_dev->info = &ina226_info;
@@ -1024,7 +1027,7 @@ static int ina2xx_probe(struct i2c_client *client)
10241027
indio_dev->num_channels = ARRAY_SIZE(ina219_channels);
10251028
indio_dev->info = &ina219_info;
10261029
}
1027-
indio_dev->name = id->name;
1030+
indio_dev->name = id ? id->name : chip->config->name;
10281031

10291032
ret = devm_iio_kfifo_buffer_setup(&client->dev, indio_dev,
10301033
&ina2xx_setup_ops);

drivers/iio/adc/meson_saradc.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -916,12 +916,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
916916
goto err_vref;
917917
}
918918

919-
ret = clk_prepare_enable(priv->core_clk);
920-
if (ret) {
921-
dev_err(dev, "failed to enable core clk\n");
922-
goto err_core_clk;
923-
}
924-
925919
regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1);
926920
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0,
927921
MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval);
@@ -948,8 +942,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev)
948942
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3,
949943
MESON_SAR_ADC_REG3_ADC_EN, 0);
950944
meson_sar_adc_set_bandgap(indio_dev, false);
951-
clk_disable_unprepare(priv->core_clk);
952-
err_core_clk:
953945
regulator_disable(priv->vref);
954946
err_vref:
955947
meson_sar_adc_unlock(indio_dev);
@@ -977,8 +969,6 @@ static void meson_sar_adc_hw_disable(struct iio_dev *indio_dev)
977969

978970
meson_sar_adc_set_bandgap(indio_dev, false);
979971

980-
clk_disable_unprepare(priv->core_clk);
981-
982972
regulator_disable(priv->vref);
983973

984974
if (!ret)
@@ -1211,7 +1201,7 @@ static int meson_sar_adc_probe(struct platform_device *pdev)
12111201
if (IS_ERR(priv->clkin))
12121202
return dev_err_probe(dev, PTR_ERR(priv->clkin), "failed to get clkin\n");
12131203

1214-
priv->core_clk = devm_clk_get(dev, "core");
1204+
priv->core_clk = devm_clk_get_enabled(dev, "core");
12151205
if (IS_ERR(priv->core_clk))
12161206
return dev_err_probe(dev, PTR_ERR(priv->core_clk), "failed to get core clk\n");
12171207

@@ -1294,15 +1284,26 @@ static int meson_sar_adc_remove(struct platform_device *pdev)
12941284
static int meson_sar_adc_suspend(struct device *dev)
12951285
{
12961286
struct iio_dev *indio_dev = dev_get_drvdata(dev);
1287+
struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
12971288

12981289
meson_sar_adc_hw_disable(indio_dev);
12991290

1291+
clk_disable_unprepare(priv->core_clk);
1292+
13001293
return 0;
13011294
}
13021295

13031296
static int meson_sar_adc_resume(struct device *dev)
13041297
{
13051298
struct iio_dev *indio_dev = dev_get_drvdata(dev);
1299+
struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
1300+
int ret;
1301+
1302+
ret = clk_prepare_enable(priv->core_clk);
1303+
if (ret) {
1304+
dev_err(dev, "failed to enable core clk\n");
1305+
return ret;
1306+
}
13061307

13071308
return meson_sar_adc_hw_enable(indio_dev);
13081309
}

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
253253
platform_set_drvdata(pdev, indio_dev);
254254

255255
state->ec = ec->ec_dev;
256-
state->msg = devm_kzalloc(&pdev->dev,
256+
state->msg = devm_kzalloc(&pdev->dev, sizeof(*state->msg) +
257257
max((u16)sizeof(struct ec_params_motion_sense),
258258
state->ec->max_response), GFP_KERNEL);
259259
if (!state->msg)

drivers/iio/frequency/admv1013.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,12 @@ static int admv1013_update_quad_filters(struct admv1013_state *st)
344344

345345
static int admv1013_update_mixer_vgate(struct admv1013_state *st)
346346
{
347-
unsigned int vcm, mixer_vgate;
347+
unsigned int mixer_vgate;
348+
int vcm;
348349

349350
vcm = regulator_get_voltage(st->reg);
351+
if (vcm < 0)
352+
return vcm;
350353

351354
if (vcm < 1800000)
352355
mixer_vgate = (2389 * vcm / 1000000 + 8100) / 100;

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
26872687
static int lsm6dsx_get_acpi_mount_matrix(struct device *dev,
26882688
struct iio_mount_matrix *orientation)
26892689
{
2690-
return false;
2690+
return -EOPNOTSUPP;
26912691
}
26922692

26932693
#endif

drivers/iio/industrialio-core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,7 @@ static const struct iio_buffer_setup_ops noop_ring_setup_ops;
18881888
int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
18891889
{
18901890
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
1891-
struct fwnode_handle *fwnode;
1891+
struct fwnode_handle *fwnode = NULL;
18921892
int ret;
18931893

18941894
if (!indio_dev->info)
@@ -1899,7 +1899,8 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
18991899
/* If the calling driver did not initialize firmware node, do it here */
19001900
if (dev_fwnode(&indio_dev->dev))
19011901
fwnode = dev_fwnode(&indio_dev->dev);
1902-
else
1902+
/* The default dummy IIO device has no parent */
1903+
else if (indio_dev->dev.parent)
19031904
fwnode = dev_fwnode(indio_dev->dev.parent);
19041905
device_set_node(&indio_dev->dev, fwnode);
19051906

drivers/iio/light/rohm-bu27008.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static const struct iio_itime_sel_mul bu27008_itimes[] = {
190190
.address = BU27008_REG_##data##_LO, \
191191
.scan_index = BU27008_##color, \
192192
.scan_type = { \
193-
.sign = 's', \
193+
.sign = 'u', \
194194
.realbits = 16, \
195195
.storagebits = 16, \
196196
.endianness = IIO_LE, \
@@ -633,7 +633,7 @@ static int bu27008_try_find_new_time_gain(struct bu27008_data *data, int val,
633633
for (i = 0; i < data->gts.num_itime; i++) {
634634
new_time_sel = data->gts.itime_table[i].sel;
635635
ret = iio_gts_find_gain_sel_for_scale_using_time(&data->gts,
636-
new_time_sel, val, val2 * 1000, gain_sel);
636+
new_time_sel, val, val2, gain_sel);
637637
if (!ret)
638638
break;
639639
}
@@ -662,7 +662,7 @@ static int bu27008_set_scale(struct bu27008_data *data,
662662
goto unlock_out;
663663

664664
ret = iio_gts_find_gain_sel_for_scale_using_time(&data->gts, time_sel,
665-
val, val2 * 1000, &gain_sel);
665+
val, val2, &gain_sel);
666666
if (ret) {
667667
ret = bu27008_try_find_new_time_gain(data, val, val2, &gain_sel);
668668
if (ret)
@@ -677,6 +677,21 @@ static int bu27008_set_scale(struct bu27008_data *data,
677677
return ret;
678678
}
679679

680+
static int bu27008_write_raw_get_fmt(struct iio_dev *indio_dev,
681+
struct iio_chan_spec const *chan,
682+
long mask)
683+
{
684+
685+
switch (mask) {
686+
case IIO_CHAN_INFO_SCALE:
687+
return IIO_VAL_INT_PLUS_NANO;
688+
case IIO_CHAN_INFO_INT_TIME:
689+
return IIO_VAL_INT_PLUS_MICRO;
690+
default:
691+
return -EINVAL;
692+
}
693+
}
694+
680695
static int bu27008_write_raw(struct iio_dev *idev,
681696
struct iio_chan_spec const *chan,
682697
int val, int val2, long mask)
@@ -756,6 +771,7 @@ static int bu27008_update_scan_mode(struct iio_dev *idev,
756771
static const struct iio_info bu27008_info = {
757772
.read_raw = &bu27008_read_raw,
758773
.write_raw = &bu27008_write_raw,
774+
.write_raw_get_fmt = &bu27008_write_raw_get_fmt,
759775
.read_avail = &bu27008_read_avail,
760776
.update_scan_mode = bu27008_update_scan_mode,
761777
.validate_trigger = iio_validate_own_trigger,

drivers/iio/light/rohm-bu27034.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan,
575575
return -EINVAL;
576576

577577
if (chan == BU27034_CHAN_ALS) {
578-
if (val == 0 && val2 == 1000)
578+
if (val == 0 && val2 == 1000000)
579579
return 0;
580580

581581
return -EINVAL;
@@ -587,7 +587,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan,
587587
goto unlock_out;
588588

589589
ret = iio_gts_find_gain_sel_for_scale_using_time(&data->gts, time_sel,
590-
val, val2 * 1000, &gain_sel);
590+
val, val2, &gain_sel);
591591
if (ret) {
592592
/*
593593
* Could not support scale with given time. Need to change time.
@@ -624,7 +624,7 @@ static int bu27034_set_scale(struct bu27034_data *data, int chan,
624624

625625
/* Can we provide requested scale with this time? */
626626
ret = iio_gts_find_gain_sel_for_scale_using_time(
627-
&data->gts, new_time_sel, val, val2 * 1000,
627+
&data->gts, new_time_sel, val, val2,
628628
&gain_sel);
629629
if (ret)
630630
continue;
@@ -1217,6 +1217,21 @@ static int bu27034_read_raw(struct iio_dev *idev,
12171217
}
12181218
}
12191219

1220+
static int bu27034_write_raw_get_fmt(struct iio_dev *indio_dev,
1221+
struct iio_chan_spec const *chan,
1222+
long mask)
1223+
{
1224+
1225+
switch (mask) {
1226+
case IIO_CHAN_INFO_SCALE:
1227+
return IIO_VAL_INT_PLUS_NANO;
1228+
case IIO_CHAN_INFO_INT_TIME:
1229+
return IIO_VAL_INT_PLUS_MICRO;
1230+
default:
1231+
return -EINVAL;
1232+
}
1233+
}
1234+
12201235
static int bu27034_write_raw(struct iio_dev *idev,
12211236
struct iio_chan_spec const *chan,
12221237
int val, int val2, long mask)
@@ -1267,6 +1282,7 @@ static int bu27034_read_avail(struct iio_dev *idev,
12671282
static const struct iio_info bu27034_info = {
12681283
.read_raw = &bu27034_read_raw,
12691284
.write_raw = &bu27034_write_raw,
1285+
.write_raw_get_fmt = &bu27034_write_raw_get_fmt,
12701286
.read_avail = &bu27034_read_avail,
12711287
};
12721288

0 commit comments

Comments
 (0)