Skip to content

Commit bca7a46

Browse files
committed
Merge tag 'iio-fixes-for-6.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus
Jonathan writes: 1st set of IIO fixes for the 6.4 cycle. Usual mixed bag of issues in new code for this cycle and old issues that have surfaced in the last few weeks. - adi,ad_sigma_delta * Ensure irq lazy disable handing is not used as it breaks completion detection. - adi,ad4130 * Fix failure to remove clock provider. - adi,ad5758 * Wrong CONFIG variable used to control driver build. - adi,ad7192 * Fix repeated channel index by just expressing shorted channels as differential channel between a channel and itself. - adi,ad74413 * Fix error handling for resistance input processing to not fail in case of success. - rohm,bu27034 * Fix integration time in wrong units (should be seconds not usecs) * Ensure reset is actually written not detected as already set from regcache. - gts helper * Fix wrong parameter docs. * Fix integration time in wrong units (should be seconds not usecs) - fsl,imx8qxp-adc * Add missing vref-supply to binding doc (already used by driver) - fsl,imx93 * Fix sign bug in read_raw() so that error check didn't work. - inv,icm42600 * Fix reset of timestamp to work even if a particular sensor is off when the chip is first enabled. - kionix,kx022a * Fix irq get form fw node to not include the 0 value. - microchip,mcp4725 * Fix return value from i2c_master_send() handling to nto assume 0 on success. - mediatek,mt6370 * Fix incorrect scaling of a few currents on devices with particular vendor IDs. - fsl,mxs-lradc * Cleanup ordering issue fix. - renesas,rcar-adc bindings * Fix missing vendor prefix for adi,ad7476 - st,st_accel * Fix handling when no ACPI _ONT method present. - st,stm32-adc * Handle no adc-diff-channel present case (all single ended) * Handle no adc-channels present case (all differential) - ti,palmas * Fix off by one bug that could allow out of bounds read if callers provided wrong value. - ti,tmag5273 * Fix a runtime PM leak on measurement error - vishay,vcnl4035 * Correctly mask chip ID so devices with different addresses don't fail the test. * tag 'iio-fixes-for-6.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (23 commits) iio: imu: inv_icm42600: fix timestamp reset iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag dt-bindings: iio: adc: renesas,rcar-gyroadc: Fix adi,ad7476 compatible value iio: dac: mcp4725: Fix i2c_master_send() return value handling iio: accel: kx022a fix irq getting iio: bu27034: Ensure reset is written iio: dac: build ad5758 driver when AD5758 is selected iio: addac: ad74413: fix resistance input processing iio: light: vcnl4035: fixed chip ID check dt-bindings: iio: imx8qxp-adc: add missing vref-supply iio: adc: stm32-adc: skip adc-channels setup if none is present iio: adc: stm32-adc: skip adc-diff-channels setup if none is present iio: adc: ad7192: Change "shorted" channels to differential iio: accel: st_accel: Fix invalid mount_matrix on devices without ACPI _ONT method iio: gts-helpers: fix integration time units iio: bu27034: Fix integration time iio: fix doc for iio_gts_find_sel_by_int_time iio: adc: palmas: fix off by one bugs iio: adc: mxs-lradc: fix the order of two cleanup operations iio: ad4130: Make sure clock provider gets removed ...
2 parents 7877cb9 + bbaae0c commit bca7a46

File tree

21 files changed

+204
-84
lines changed

21 files changed

+204
-84
lines changed

Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ properties:
3939
power-domains:
4040
maxItems: 1
4141

42+
vref-supply:
43+
description: |
44+
External ADC reference voltage supply on VREFH pad. If VERID[MVI] is
45+
set, there are additional, internal reference voltages selectable.
46+
VREFH1 is always from VREFH pad.
47+
4248
"#io-channel-cells":
4349
const: 1
4450

@@ -72,6 +78,7 @@ examples:
7278
assigned-clocks = <&clk IMX_SC_R_ADC_0>;
7379
assigned-clock-rates = <24000000>;
7480
power-domains = <&pd IMX_SC_R_ADC_0>;
81+
vref-supply = <&reg_1v8>;
7582
#io-channel-cells = <1>;
7683
};
7784
};

Documentation/devicetree/bindings/iio/adc/renesas,rcar-gyroadc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ patternProperties:
9090
of the MAX chips to the GyroADC, while MISO line of each Maxim
9191
ADC connects to a shared input pin of the GyroADC.
9292
enum:
93-
- adi,7476
93+
- adi,ad7476
9494
- fujitsu,mb88101a
9595
- maxim,max1162
9696
- maxim,max11100

drivers/iio/accel/kionix-kx022a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ int kx022a_probe_internal(struct device *dev)
10481048
data->ien_reg = KX022A_REG_INC4;
10491049
} else {
10501050
irq = fwnode_irq_get_byname(fwnode, "INT2");
1051-
if (irq <= 0)
1051+
if (irq < 0)
10521052
return dev_err_probe(dev, irq, "No suitable IRQ\n");
10531053

10541054
data->inc_reg = KX022A_REG_INC5;

drivers/iio/accel/st_accel_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,12 +1291,12 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev)
12911291

12921292
adev = ACPI_COMPANION(indio_dev->dev.parent);
12931293
if (!adev)
1294-
return 0;
1294+
return -ENXIO;
12951295

12961296
/* Read _ONT data, which should be a package of 6 integers. */
12971297
status = acpi_evaluate_object(adev->handle, "_ONT", NULL, &buffer);
12981298
if (status == AE_NOT_FOUND) {
1299-
return 0;
1299+
return -ENXIO;
13001300
} else if (ACPI_FAILURE(status)) {
13011301
dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n",
13021302
status);

drivers/iio/adc/ad4130.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,13 +1817,19 @@ static const struct clk_ops ad4130_int_clk_ops = {
18171817
.unprepare = ad4130_int_clk_unprepare,
18181818
};
18191819

1820+
static void ad4130_clk_del_provider(void *of_node)
1821+
{
1822+
of_clk_del_provider(of_node);
1823+
}
1824+
18201825
static int ad4130_setup_int_clk(struct ad4130_state *st)
18211826
{
18221827
struct device *dev = &st->spi->dev;
18231828
struct device_node *of_node = dev_of_node(dev);
18241829
struct clk_init_data init;
18251830
const char *clk_name;
18261831
struct clk *clk;
1832+
int ret;
18271833

18281834
if (st->int_pin_sel == AD4130_INT_PIN_CLK ||
18291835
st->mclk_sel != AD4130_MCLK_76_8KHZ)
@@ -1843,7 +1849,11 @@ static int ad4130_setup_int_clk(struct ad4130_state *st)
18431849
if (IS_ERR(clk))
18441850
return PTR_ERR(clk);
18451851

1846-
return of_clk_add_provider(of_node, of_clk_src_simple_get, clk);
1852+
ret = of_clk_add_provider(of_node, of_clk_src_simple_get, clk);
1853+
if (ret)
1854+
return ret;
1855+
1856+
return devm_add_action_or_reset(dev, ad4130_clk_del_provider, of_node);
18471857
}
18481858

18491859
static int ad4130_setup(struct iio_dev *indio_dev)

drivers/iio/adc/ad7192.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,18 +897,14 @@ static const struct iio_info ad7195_info = {
897897
__AD719x_CHANNEL(_si, _channel1, -1, _address, NULL, IIO_VOLTAGE, \
898898
BIT(IIO_CHAN_INFO_SCALE), ad7192_calibsys_ext_info)
899899

900-
#define AD719x_SHORTED_CHANNEL(_si, _channel1, _address) \
901-
__AD719x_CHANNEL(_si, _channel1, -1, _address, "shorted", IIO_VOLTAGE, \
902-
BIT(IIO_CHAN_INFO_SCALE), ad7192_calibsys_ext_info)
903-
904900
#define AD719x_TEMP_CHANNEL(_si, _address) \
905901
__AD719x_CHANNEL(_si, 0, -1, _address, NULL, IIO_TEMP, 0, NULL)
906902

907903
static const struct iio_chan_spec ad7192_channels[] = {
908904
AD719x_DIFF_CHANNEL(0, 1, 2, AD7192_CH_AIN1P_AIN2M),
909905
AD719x_DIFF_CHANNEL(1, 3, 4, AD7192_CH_AIN3P_AIN4M),
910906
AD719x_TEMP_CHANNEL(2, AD7192_CH_TEMP),
911-
AD719x_SHORTED_CHANNEL(3, 2, AD7192_CH_AIN2P_AIN2M),
907+
AD719x_DIFF_CHANNEL(3, 2, 2, AD7192_CH_AIN2P_AIN2M),
912908
AD719x_CHANNEL(4, 1, AD7192_CH_AIN1),
913909
AD719x_CHANNEL(5, 2, AD7192_CH_AIN2),
914910
AD719x_CHANNEL(6, 3, AD7192_CH_AIN3),
@@ -922,7 +918,7 @@ static const struct iio_chan_spec ad7193_channels[] = {
922918
AD719x_DIFF_CHANNEL(2, 5, 6, AD7193_CH_AIN5P_AIN6M),
923919
AD719x_DIFF_CHANNEL(3, 7, 8, AD7193_CH_AIN7P_AIN8M),
924920
AD719x_TEMP_CHANNEL(4, AD7193_CH_TEMP),
925-
AD719x_SHORTED_CHANNEL(5, 2, AD7193_CH_AIN2P_AIN2M),
921+
AD719x_DIFF_CHANNEL(5, 2, 2, AD7193_CH_AIN2P_AIN2M),
926922
AD719x_CHANNEL(6, 1, AD7193_CH_AIN1),
927923
AD719x_CHANNEL(7, 2, AD7193_CH_AIN2),
928924
AD719x_CHANNEL(8, 3, AD7193_CH_AIN3),

drivers/iio/adc/ad_sigma_delta.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ static int devm_ad_sd_probe_trigger(struct device *dev, struct iio_dev *indio_de
584584
init_completion(&sigma_delta->completion);
585585

586586
sigma_delta->irq_dis = true;
587+
588+
/* the IRQ core clears IRQ_DISABLE_UNLAZY flag when freeing an IRQ */
589+
irq_set_status_flags(sigma_delta->spi->irq, IRQ_DISABLE_UNLAZY);
590+
587591
ret = devm_request_irq(dev, sigma_delta->spi->irq,
588592
ad_sd_data_rdy_trig_poll,
589593
sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,

drivers/iio/adc/imx93_adc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ static int imx93_adc_read_raw(struct iio_dev *indio_dev,
236236
{
237237
struct imx93_adc *adc = iio_priv(indio_dev);
238238
struct device *dev = adc->dev;
239-
long ret;
240-
u32 vref_uv;
239+
int ret;
241240

242241
switch (mask) {
243242
case IIO_CHAN_INFO_RAW:
@@ -253,10 +252,10 @@ static int imx93_adc_read_raw(struct iio_dev *indio_dev,
253252
return IIO_VAL_INT;
254253

255254
case IIO_CHAN_INFO_SCALE:
256-
ret = vref_uv = regulator_get_voltage(adc->vref);
255+
ret = regulator_get_voltage(adc->vref);
257256
if (ret < 0)
258257
return ret;
259-
*val = vref_uv / 1000;
258+
*val = ret / 1000;
260259
*val2 = 12;
261260
return IIO_VAL_FRACTIONAL_LOG2;
262261

drivers/iio/adc/mt6370-adc.c

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <dt-bindings/iio/adc/mediatek,mt6370_adc.h>
2121

22+
#define MT6370_REG_DEV_INFO 0x100
2223
#define MT6370_REG_CHG_CTRL3 0x113
2324
#define MT6370_REG_CHG_CTRL7 0x117
2425
#define MT6370_REG_CHG_ADC 0x121
@@ -27,6 +28,7 @@
2728
#define MT6370_ADC_START_MASK BIT(0)
2829
#define MT6370_ADC_IN_SEL_MASK GENMASK(7, 4)
2930
#define MT6370_AICR_ICHG_MASK GENMASK(7, 2)
31+
#define MT6370_VENID_MASK GENMASK(7, 4)
3032

3133
#define MT6370_AICR_100_mA 0x0
3234
#define MT6370_AICR_150_mA 0x1
@@ -47,6 +49,10 @@
4749
#define ADC_CONV_TIME_MS 35
4850
#define ADC_CONV_POLLING_TIME_US 1000
4951

52+
#define MT6370_VID_RT5081 0x8
53+
#define MT6370_VID_RT5081A 0xA
54+
#define MT6370_VID_MT6370 0xE
55+
5056
struct mt6370_adc_data {
5157
struct device *dev;
5258
struct regmap *regmap;
@@ -55,6 +61,7 @@ struct mt6370_adc_data {
5561
* from being read at the same time.
5662
*/
5763
struct mutex adc_lock;
64+
unsigned int vid;
5865
};
5966

6067
static int mt6370_adc_read_channel(struct mt6370_adc_data *priv, int chan,
@@ -98,6 +105,30 @@ static int mt6370_adc_read_channel(struct mt6370_adc_data *priv, int chan,
98105
return ret;
99106
}
100107

108+
static int mt6370_adc_get_ibus_scale(struct mt6370_adc_data *priv)
109+
{
110+
switch (priv->vid) {
111+
case MT6370_VID_RT5081:
112+
case MT6370_VID_RT5081A:
113+
case MT6370_VID_MT6370:
114+
return 3350;
115+
default:
116+
return 3875;
117+
}
118+
}
119+
120+
static int mt6370_adc_get_ibat_scale(struct mt6370_adc_data *priv)
121+
{
122+
switch (priv->vid) {
123+
case MT6370_VID_RT5081:
124+
case MT6370_VID_RT5081A:
125+
case MT6370_VID_MT6370:
126+
return 2680;
127+
default:
128+
return 3870;
129+
}
130+
}
131+
101132
static int mt6370_adc_read_scale(struct mt6370_adc_data *priv,
102133
int chan, int *val1, int *val2)
103134
{
@@ -123,7 +154,7 @@ static int mt6370_adc_read_scale(struct mt6370_adc_data *priv,
123154
case MT6370_AICR_250_mA:
124155
case MT6370_AICR_300_mA:
125156
case MT6370_AICR_350_mA:
126-
*val1 = 3350;
157+
*val1 = mt6370_adc_get_ibus_scale(priv);
127158
break;
128159
default:
129160
*val1 = 5000;
@@ -150,7 +181,7 @@ static int mt6370_adc_read_scale(struct mt6370_adc_data *priv,
150181
case MT6370_ICHG_600_mA:
151182
case MT6370_ICHG_700_mA:
152183
case MT6370_ICHG_800_mA:
153-
*val1 = 2680;
184+
*val1 = mt6370_adc_get_ibat_scale(priv);
154185
break;
155186
default:
156187
*val1 = 5000;
@@ -251,6 +282,20 @@ static const struct iio_chan_spec mt6370_adc_channels[] = {
251282
MT6370_ADC_CHAN(TEMP_JC, IIO_TEMP, 12, BIT(IIO_CHAN_INFO_OFFSET)),
252283
};
253284

285+
static int mt6370_get_vendor_info(struct mt6370_adc_data *priv)
286+
{
287+
unsigned int dev_info;
288+
int ret;
289+
290+
ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, &dev_info);
291+
if (ret)
292+
return ret;
293+
294+
priv->vid = FIELD_GET(MT6370_VENID_MASK, dev_info);
295+
296+
return 0;
297+
}
298+
254299
static int mt6370_adc_probe(struct platform_device *pdev)
255300
{
256301
struct device *dev = &pdev->dev;
@@ -272,6 +317,10 @@ static int mt6370_adc_probe(struct platform_device *pdev)
272317
priv->regmap = regmap;
273318
mutex_init(&priv->adc_lock);
274319

320+
ret = mt6370_get_vendor_info(priv);
321+
if (ret)
322+
return dev_err_probe(dev, ret, "Failed to get vid\n");
323+
275324
ret = regmap_write(priv->regmap, MT6370_REG_CHG_ADC, 0);
276325
if (ret)
277326
return dev_err_probe(dev, ret, "Failed to reset ADC\n");

drivers/iio/adc/mxs-lradc-adc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,13 @@ static int mxs_lradc_adc_probe(struct platform_device *pdev)
757757

758758
ret = mxs_lradc_adc_trigger_init(iio);
759759
if (ret)
760-
goto err_trig;
760+
return ret;
761761

762762
ret = iio_triggered_buffer_setup(iio, &iio_pollfunc_store_time,
763763
&mxs_lradc_adc_trigger_handler,
764764
&mxs_lradc_adc_buffer_ops);
765765
if (ret)
766-
return ret;
766+
goto err_trig;
767767

768768
adc->vref_mv = mxs_lradc_adc_vref_mv[lradc->soc];
769769

@@ -801,9 +801,9 @@ static int mxs_lradc_adc_probe(struct platform_device *pdev)
801801

802802
err_dev:
803803
mxs_lradc_adc_hw_stop(adc);
804-
mxs_lradc_adc_trigger_remove(iio);
805-
err_trig:
806804
iio_triggered_buffer_cleanup(iio);
805+
err_trig:
806+
mxs_lradc_adc_trigger_remove(iio);
807807
return ret;
808808
}
809809

@@ -814,8 +814,8 @@ static int mxs_lradc_adc_remove(struct platform_device *pdev)
814814

815815
iio_device_unregister(iio);
816816
mxs_lradc_adc_hw_stop(adc);
817-
mxs_lradc_adc_trigger_remove(iio);
818817
iio_triggered_buffer_cleanup(iio);
818+
mxs_lradc_adc_trigger_remove(iio);
819819

820820
return 0;
821821
}

0 commit comments

Comments
 (0)