Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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
...

+204 -84
+7
Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml
··· 39 39 power-domains: 40 40 maxItems: 1 41 41 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 + 42 48 "#io-channel-cells": 43 49 const: 1 44 50 ··· 78 72 assigned-clocks = <&clk IMX_SC_R_ADC_0>; 79 73 assigned-clock-rates = <24000000>; 80 74 power-domains = <&pd IMX_SC_R_ADC_0>; 75 + vref-supply = <&reg_1v8>; 81 76 #io-channel-cells = <1>; 82 77 }; 83 78 };
+1 -1
Documentation/devicetree/bindings/iio/adc/renesas,rcar-gyroadc.yaml
··· 90 90 of the MAX chips to the GyroADC, while MISO line of each Maxim 91 91 ADC connects to a shared input pin of the GyroADC. 92 92 enum: 93 - - adi,7476 93 + - adi,ad7476 94 94 - fujitsu,mb88101a 95 95 - maxim,max1162 96 96 - maxim,max11100
+1 -1
drivers/iio/accel/kionix-kx022a.c
··· 1048 1048 data->ien_reg = KX022A_REG_INC4; 1049 1049 } else { 1050 1050 irq = fwnode_irq_get_byname(fwnode, "INT2"); 1051 - if (irq <= 0) 1051 + if (irq < 0) 1052 1052 return dev_err_probe(dev, irq, "No suitable IRQ\n"); 1053 1053 1054 1054 data->inc_reg = KX022A_REG_INC5;
+2 -2
drivers/iio/accel/st_accel_core.c
··· 1291 1291 1292 1292 adev = ACPI_COMPANION(indio_dev->dev.parent); 1293 1293 if (!adev) 1294 - return 0; 1294 + return -ENXIO; 1295 1295 1296 1296 /* Read _ONT data, which should be a package of 6 integers. */ 1297 1297 status = acpi_evaluate_object(adev->handle, "_ONT", NULL, &buffer); 1298 1298 if (status == AE_NOT_FOUND) { 1299 - return 0; 1299 + return -ENXIO; 1300 1300 } else if (ACPI_FAILURE(status)) { 1301 1301 dev_warn(&indio_dev->dev, "failed to execute _ONT: %d\n", 1302 1302 status);
+11 -1
drivers/iio/adc/ad4130.c
··· 1817 1817 .unprepare = ad4130_int_clk_unprepare, 1818 1818 }; 1819 1819 1820 + static void ad4130_clk_del_provider(void *of_node) 1821 + { 1822 + of_clk_del_provider(of_node); 1823 + } 1824 + 1820 1825 static int ad4130_setup_int_clk(struct ad4130_state *st) 1821 1826 { 1822 1827 struct device *dev = &st->spi->dev; ··· 1829 1824 struct clk_init_data init; 1830 1825 const char *clk_name; 1831 1826 struct clk *clk; 1827 + int ret; 1832 1828 1833 1829 if (st->int_pin_sel == AD4130_INT_PIN_CLK || 1834 1830 st->mclk_sel != AD4130_MCLK_76_8KHZ) ··· 1849 1843 if (IS_ERR(clk)) 1850 1844 return PTR_ERR(clk); 1851 1845 1852 - return of_clk_add_provider(of_node, of_clk_src_simple_get, clk); 1846 + ret = of_clk_add_provider(of_node, of_clk_src_simple_get, clk); 1847 + if (ret) 1848 + return ret; 1849 + 1850 + return devm_add_action_or_reset(dev, ad4130_clk_del_provider, of_node); 1853 1851 } 1854 1852 1855 1853 static int ad4130_setup(struct iio_dev *indio_dev)
+2 -6
drivers/iio/adc/ad7192.c
··· 897 897 __AD719x_CHANNEL(_si, _channel1, -1, _address, NULL, IIO_VOLTAGE, \ 898 898 BIT(IIO_CHAN_INFO_SCALE), ad7192_calibsys_ext_info) 899 899 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 - 904 900 #define AD719x_TEMP_CHANNEL(_si, _address) \ 905 901 __AD719x_CHANNEL(_si, 0, -1, _address, NULL, IIO_TEMP, 0, NULL) 906 902 ··· 904 908 AD719x_DIFF_CHANNEL(0, 1, 2, AD7192_CH_AIN1P_AIN2M), 905 909 AD719x_DIFF_CHANNEL(1, 3, 4, AD7192_CH_AIN3P_AIN4M), 906 910 AD719x_TEMP_CHANNEL(2, AD7192_CH_TEMP), 907 - AD719x_SHORTED_CHANNEL(3, 2, AD7192_CH_AIN2P_AIN2M), 911 + AD719x_DIFF_CHANNEL(3, 2, 2, AD7192_CH_AIN2P_AIN2M), 908 912 AD719x_CHANNEL(4, 1, AD7192_CH_AIN1), 909 913 AD719x_CHANNEL(5, 2, AD7192_CH_AIN2), 910 914 AD719x_CHANNEL(6, 3, AD7192_CH_AIN3), ··· 918 922 AD719x_DIFF_CHANNEL(2, 5, 6, AD7193_CH_AIN5P_AIN6M), 919 923 AD719x_DIFF_CHANNEL(3, 7, 8, AD7193_CH_AIN7P_AIN8M), 920 924 AD719x_TEMP_CHANNEL(4, AD7193_CH_TEMP), 921 - AD719x_SHORTED_CHANNEL(5, 2, AD7193_CH_AIN2P_AIN2M), 925 + AD719x_DIFF_CHANNEL(5, 2, 2, AD7193_CH_AIN2P_AIN2M), 922 926 AD719x_CHANNEL(6, 1, AD7193_CH_AIN1), 923 927 AD719x_CHANNEL(7, 2, AD7193_CH_AIN2), 924 928 AD719x_CHANNEL(8, 3, AD7193_CH_AIN3),
+4
drivers/iio/adc/ad_sigma_delta.c
··· 584 584 init_completion(&sigma_delta->completion); 585 585 586 586 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 + 587 591 ret = devm_request_irq(dev, sigma_delta->spi->irq, 588 592 ad_sd_data_rdy_trig_poll, 589 593 sigma_delta->info->irq_flags | IRQF_NO_AUTOEN,
+3 -4
drivers/iio/adc/imx93_adc.c
··· 236 236 { 237 237 struct imx93_adc *adc = iio_priv(indio_dev); 238 238 struct device *dev = adc->dev; 239 - long ret; 240 - u32 vref_uv; 239 + int ret; 241 240 242 241 switch (mask) { 243 242 case IIO_CHAN_INFO_RAW: ··· 252 253 return IIO_VAL_INT; 253 254 254 255 case IIO_CHAN_INFO_SCALE: 255 - ret = vref_uv = regulator_get_voltage(adc->vref); 256 + ret = regulator_get_voltage(adc->vref); 256 257 if (ret < 0) 257 258 return ret; 258 - *val = vref_uv / 1000; 259 + *val = ret / 1000; 259 260 *val2 = 12; 260 261 return IIO_VAL_FRACTIONAL_LOG2; 261 262
+51 -2
drivers/iio/adc/mt6370-adc.c
··· 19 19 20 20 #include <dt-bindings/iio/adc/mediatek,mt6370_adc.h> 21 21 22 + #define MT6370_REG_DEV_INFO 0x100 22 23 #define MT6370_REG_CHG_CTRL3 0x113 23 24 #define MT6370_REG_CHG_CTRL7 0x117 24 25 #define MT6370_REG_CHG_ADC 0x121 ··· 28 27 #define MT6370_ADC_START_MASK BIT(0) 29 28 #define MT6370_ADC_IN_SEL_MASK GENMASK(7, 4) 30 29 #define MT6370_AICR_ICHG_MASK GENMASK(7, 2) 30 + #define MT6370_VENID_MASK GENMASK(7, 4) 31 31 32 32 #define MT6370_AICR_100_mA 0x0 33 33 #define MT6370_AICR_150_mA 0x1 ··· 49 47 #define ADC_CONV_TIME_MS 35 50 48 #define ADC_CONV_POLLING_TIME_US 1000 51 49 50 + #define MT6370_VID_RT5081 0x8 51 + #define MT6370_VID_RT5081A 0xA 52 + #define MT6370_VID_MT6370 0xE 53 + 52 54 struct mt6370_adc_data { 53 55 struct device *dev; 54 56 struct regmap *regmap; ··· 61 55 * from being read at the same time. 62 56 */ 63 57 struct mutex adc_lock; 58 + unsigned int vid; 64 59 }; 65 60 66 61 static int mt6370_adc_read_channel(struct mt6370_adc_data *priv, int chan, ··· 105 98 return ret; 106 99 } 107 100 101 + static int mt6370_adc_get_ibus_scale(struct mt6370_adc_data *priv) 102 + { 103 + switch (priv->vid) { 104 + case MT6370_VID_RT5081: 105 + case MT6370_VID_RT5081A: 106 + case MT6370_VID_MT6370: 107 + return 3350; 108 + default: 109 + return 3875; 110 + } 111 + } 112 + 113 + static int mt6370_adc_get_ibat_scale(struct mt6370_adc_data *priv) 114 + { 115 + switch (priv->vid) { 116 + case MT6370_VID_RT5081: 117 + case MT6370_VID_RT5081A: 118 + case MT6370_VID_MT6370: 119 + return 2680; 120 + default: 121 + return 3870; 122 + } 123 + } 124 + 108 125 static int mt6370_adc_read_scale(struct mt6370_adc_data *priv, 109 126 int chan, int *val1, int *val2) 110 127 { ··· 154 123 case MT6370_AICR_250_mA: 155 124 case MT6370_AICR_300_mA: 156 125 case MT6370_AICR_350_mA: 157 - *val1 = 3350; 126 + *val1 = mt6370_adc_get_ibus_scale(priv); 158 127 break; 159 128 default: 160 129 *val1 = 5000; ··· 181 150 case MT6370_ICHG_600_mA: 182 151 case MT6370_ICHG_700_mA: 183 152 case MT6370_ICHG_800_mA: 184 - *val1 = 2680; 153 + *val1 = mt6370_adc_get_ibat_scale(priv); 185 154 break; 186 155 default: 187 156 *val1 = 5000; ··· 282 251 MT6370_ADC_CHAN(TEMP_JC, IIO_TEMP, 12, BIT(IIO_CHAN_INFO_OFFSET)), 283 252 }; 284 253 254 + static int mt6370_get_vendor_info(struct mt6370_adc_data *priv) 255 + { 256 + unsigned int dev_info; 257 + int ret; 258 + 259 + ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, &dev_info); 260 + if (ret) 261 + return ret; 262 + 263 + priv->vid = FIELD_GET(MT6370_VENID_MASK, dev_info); 264 + 265 + return 0; 266 + } 267 + 285 268 static int mt6370_adc_probe(struct platform_device *pdev) 286 269 { 287 270 struct device *dev = &pdev->dev; ··· 316 271 priv->dev = dev; 317 272 priv->regmap = regmap; 318 273 mutex_init(&priv->adc_lock); 274 + 275 + ret = mt6370_get_vendor_info(priv); 276 + if (ret) 277 + return dev_err_probe(dev, ret, "Failed to get vid\n"); 319 278 320 279 ret = regmap_write(priv->regmap, MT6370_REG_CHG_ADC, 0); 321 280 if (ret)
+5 -5
drivers/iio/adc/mxs-lradc-adc.c
··· 757 757 758 758 ret = mxs_lradc_adc_trigger_init(iio); 759 759 if (ret) 760 - goto err_trig; 760 + return ret; 761 761 762 762 ret = iio_triggered_buffer_setup(iio, &iio_pollfunc_store_time, 763 763 &mxs_lradc_adc_trigger_handler, 764 764 &mxs_lradc_adc_buffer_ops); 765 765 if (ret) 766 - return ret; 766 + goto err_trig; 767 767 768 768 adc->vref_mv = mxs_lradc_adc_vref_mv[lradc->soc]; 769 769 ··· 801 801 802 802 err_dev: 803 803 mxs_lradc_adc_hw_stop(adc); 804 - mxs_lradc_adc_trigger_remove(iio); 805 - err_trig: 806 804 iio_triggered_buffer_cleanup(iio); 805 + err_trig: 806 + mxs_lradc_adc_trigger_remove(iio); 807 807 return ret; 808 808 } 809 809 ··· 814 814 815 815 iio_device_unregister(iio); 816 816 mxs_lradc_adc_hw_stop(adc); 817 - mxs_lradc_adc_trigger_remove(iio); 818 817 iio_triggered_buffer_cleanup(iio); 818 + mxs_lradc_adc_trigger_remove(iio); 819 819 820 820 return 0; 821 821 }
+5 -5
drivers/iio/adc/palmas_gpadc.c
··· 547 547 int adc_chan = chan->channel; 548 548 int ret = 0; 549 549 550 - if (adc_chan > PALMAS_ADC_CH_MAX) 550 + if (adc_chan >= PALMAS_ADC_CH_MAX) 551 551 return -EINVAL; 552 552 553 553 mutex_lock(&adc->lock); ··· 595 595 int adc_chan = chan->channel; 596 596 int ret = 0; 597 597 598 - if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 598 + if (adc_chan >= PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 599 599 return -EINVAL; 600 600 601 601 mutex_lock(&adc->lock); ··· 684 684 int adc_chan = chan->channel; 685 685 int ret; 686 686 687 - if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 687 + if (adc_chan >= PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 688 688 return -EINVAL; 689 689 690 690 mutex_lock(&adc->lock); ··· 710 710 int adc_chan = chan->channel; 711 711 int ret; 712 712 713 - if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 713 + if (adc_chan >= PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 714 714 return -EINVAL; 715 715 716 716 mutex_lock(&adc->lock); ··· 744 744 int old; 745 745 int ret; 746 746 747 - if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 747 + if (adc_chan >= PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) 748 748 return -EINVAL; 749 749 750 750 mutex_lock(&adc->lock);
+32 -29
drivers/iio/adc/stm32-adc.c
··· 2006 2006 * to get the *real* number of channels. 2007 2007 */ 2008 2008 ret = device_property_count_u32(dev, "st,adc-diff-channels"); 2009 - if (ret < 0) 2010 - return ret; 2011 - 2012 - ret /= (int)(sizeof(struct stm32_adc_diff_channel) / sizeof(u32)); 2013 - if (ret > adc_info->max_channels) { 2014 - dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n"); 2015 - return -EINVAL; 2016 - } else if (ret > 0) { 2017 - adc->num_diff = ret; 2018 - num_channels += ret; 2009 + if (ret > 0) { 2010 + ret /= (int)(sizeof(struct stm32_adc_diff_channel) / sizeof(u32)); 2011 + if (ret > adc_info->max_channels) { 2012 + dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n"); 2013 + return -EINVAL; 2014 + } else if (ret > 0) { 2015 + adc->num_diff = ret; 2016 + num_channels += ret; 2017 + } 2019 2018 } 2020 2019 2021 2020 /* Optional sample time is provided either for each, or all channels */ ··· 2036 2037 struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX]; 2037 2038 struct device *dev = &indio_dev->dev; 2038 2039 u32 num_diff = adc->num_diff; 2040 + int num_se = nchans - num_diff; 2039 2041 int size = num_diff * sizeof(*diff) / sizeof(u32); 2040 2042 int scan_index = 0, ret, i, c; 2041 2043 u32 smp = 0, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX]; ··· 2063 2063 scan_index++; 2064 2064 } 2065 2065 } 2066 - 2067 - ret = device_property_read_u32_array(dev, "st,adc-channels", chans, 2068 - nchans); 2069 - if (ret) 2070 - return ret; 2071 - 2072 - for (c = 0; c < nchans; c++) { 2073 - if (chans[c] >= adc_info->max_channels) { 2074 - dev_err(&indio_dev->dev, "Invalid channel %d\n", 2075 - chans[c]); 2076 - return -EINVAL; 2066 + if (num_se > 0) { 2067 + ret = device_property_read_u32_array(dev, "st,adc-channels", chans, num_se); 2068 + if (ret) { 2069 + dev_err(&indio_dev->dev, "Failed to get st,adc-channels %d\n", ret); 2070 + return ret; 2077 2071 } 2078 2072 2079 - /* Channel can't be configured both as single-ended & diff */ 2080 - for (i = 0; i < num_diff; i++) { 2081 - if (chans[c] == diff[i].vinp) { 2082 - dev_err(&indio_dev->dev, "channel %d misconfigured\n", chans[c]); 2073 + for (c = 0; c < num_se; c++) { 2074 + if (chans[c] >= adc_info->max_channels) { 2075 + dev_err(&indio_dev->dev, "Invalid channel %d\n", 2076 + chans[c]); 2083 2077 return -EINVAL; 2084 2078 } 2079 + 2080 + /* Channel can't be configured both as single-ended & diff */ 2081 + for (i = 0; i < num_diff; i++) { 2082 + if (chans[c] == diff[i].vinp) { 2083 + dev_err(&indio_dev->dev, "channel %d misconfigured\n", 2084 + chans[c]); 2085 + return -EINVAL; 2086 + } 2087 + } 2088 + stm32_adc_chan_init_one(indio_dev, &channels[scan_index], 2089 + chans[c], 0, scan_index, false); 2090 + scan_index++; 2085 2091 } 2086 - stm32_adc_chan_init_one(indio_dev, &channels[scan_index], 2087 - chans[c], 0, scan_index, false); 2088 - scan_index++; 2089 2092 } 2090 2093 2091 2094 if (adc->nsmps > 0) { ··· 2309 2306 2310 2307 if (legacy) 2311 2308 ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels, 2312 - num_channels); 2309 + timestamping ? num_channels - 1 : num_channels); 2313 2310 else 2314 2311 ret = stm32_adc_generic_chan_init(indio_dev, adc, channels); 2315 2312 if (ret < 0)
+1 -1
drivers/iio/addac/ad74413r.c
··· 1007 1007 1008 1008 ret = ad74413r_get_single_adc_result(indio_dev, chan->channel, 1009 1009 val); 1010 - if (ret) 1010 + if (ret < 0) 1011 1011 return ret; 1012 1012 1013 1013 ad74413r_adc_to_resistance_result(*val, val);
+1 -1
drivers/iio/dac/Makefile
··· 17 17 obj-$(CONFIG_AD5592R) += ad5592r.o 18 18 obj-$(CONFIG_AD5593R) += ad5593r.o 19 19 obj-$(CONFIG_AD5755) += ad5755.o 20 - obj-$(CONFIG_AD5755) += ad5758.o 20 + obj-$(CONFIG_AD5758) += ad5758.o 21 21 obj-$(CONFIG_AD5761) += ad5761.o 22 22 obj-$(CONFIG_AD5764) += ad5764.o 23 23 obj-$(CONFIG_AD5766) += ad5766.o
+14 -2
drivers/iio/dac/mcp4725.c
··· 47 47 struct mcp4725_data *data = iio_priv(i2c_get_clientdata( 48 48 to_i2c_client(dev))); 49 49 u8 outbuf[2]; 50 + int ret; 50 51 51 52 outbuf[0] = (data->powerdown_mode + 1) << 4; 52 53 outbuf[1] = 0; 53 54 data->powerdown = true; 54 55 55 - return i2c_master_send(data->client, outbuf, 2); 56 + ret = i2c_master_send(data->client, outbuf, 2); 57 + if (ret < 0) 58 + return ret; 59 + else if (ret != 2) 60 + return -EIO; 61 + return 0; 56 62 } 57 63 58 64 static int mcp4725_resume(struct device *dev) ··· 66 60 struct mcp4725_data *data = iio_priv(i2c_get_clientdata( 67 61 to_i2c_client(dev))); 68 62 u8 outbuf[2]; 63 + int ret; 69 64 70 65 /* restore previous DAC value */ 71 66 outbuf[0] = (data->dac_value >> 8) & 0xf; 72 67 outbuf[1] = data->dac_value & 0xff; 73 68 data->powerdown = false; 74 69 75 - return i2c_master_send(data->client, outbuf, 2); 70 + ret = i2c_master_send(data->client, outbuf, 2); 71 + if (ret < 0) 72 + return ret; 73 + else if (ret != 2) 74 + return -EIO; 75 + return 0; 76 76 } 77 77 static DEFINE_SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, 78 78 mcp4725_resume);
+5 -5
drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
··· 275 275 { 276 276 struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev); 277 277 struct device *dev = regmap_get_device(st->map); 278 + struct inv_icm42600_timestamp *ts = iio_priv(indio_dev); 278 279 279 280 pm_runtime_get_sync(dev); 281 + 282 + mutex_lock(&st->lock); 283 + inv_icm42600_timestamp_reset(ts); 284 + mutex_unlock(&st->lock); 280 285 281 286 return 0; 282 287 } ··· 380 375 struct device *dev = regmap_get_device(st->map); 381 376 unsigned int sensor; 382 377 unsigned int *watermark; 383 - struct inv_icm42600_timestamp *ts; 384 378 struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT; 385 379 unsigned int sleep_temp = 0; 386 380 unsigned int sleep_sensor = 0; ··· 389 385 if (indio_dev == st->indio_gyro) { 390 386 sensor = INV_ICM42600_SENSOR_GYRO; 391 387 watermark = &st->fifo.watermark.gyro; 392 - ts = iio_priv(st->indio_gyro); 393 388 } else if (indio_dev == st->indio_accel) { 394 389 sensor = INV_ICM42600_SENSOR_ACCEL; 395 390 watermark = &st->fifo.watermark.accel; 396 - ts = iio_priv(st->indio_accel); 397 391 } else { 398 392 return -EINVAL; 399 393 } ··· 418 416 /* if FIFO is off, turn temperature off */ 419 417 if (!st->fifo.on) 420 418 ret = inv_icm42600_set_temp_conf(st, false, &sleep_temp); 421 - 422 - inv_icm42600_timestamp_reset(ts); 423 419 424 420 out_unlock: 425 421 mutex_unlock(&st->lock);
+32 -10
drivers/iio/industrialio-gts-helper.c
··· 337 337 return ret; 338 338 } 339 339 340 + static void iio_gts_us_to_int_micro(int *time_us, int *int_micro_times, 341 + int num_times) 342 + { 343 + int i; 344 + 345 + for (i = 0; i < num_times; i++) { 346 + int_micro_times[i * 2] = time_us[i] / 1000000; 347 + int_micro_times[i * 2 + 1] = time_us[i] % 1000000; 348 + } 349 + } 350 + 340 351 /** 341 352 * iio_gts_build_avail_time_table - build table of available integration times 342 353 * @gts: Gain time scale descriptor ··· 362 351 */ 363 352 static int iio_gts_build_avail_time_table(struct iio_gts *gts) 364 353 { 365 - int *times, i, j, idx = 0; 354 + int *times, i, j, idx = 0, *int_micro_times; 366 355 367 356 if (!gts->num_itime) 368 357 return 0; ··· 389 378 } 390 379 } 391 380 } 392 - gts->avail_time_tables = times; 393 - /* 394 - * This is just to survive a unlikely corner-case where times in the 395 - * given time table were not unique. Else we could just trust the 396 - * gts->num_itime. 397 - */ 398 - gts->num_avail_time_tables = idx; 381 + 382 + /* create a list of times formatted as list of IIO_VAL_INT_PLUS_MICRO */ 383 + int_micro_times = kcalloc(idx, sizeof(int) * 2, GFP_KERNEL); 384 + if (int_micro_times) { 385 + /* 386 + * This is just to survive a unlikely corner-case where times in 387 + * the given time table were not unique. Else we could just 388 + * trust the gts->num_itime. 389 + */ 390 + gts->num_avail_time_tables = idx; 391 + iio_gts_us_to_int_micro(times, int_micro_times, idx); 392 + } 393 + 394 + gts->avail_time_tables = int_micro_times; 395 + kfree(times); 396 + 397 + if (!int_micro_times) 398 + return -ENOMEM; 399 399 400 400 return 0; 401 401 } ··· 705 683 return -EINVAL; 706 684 707 685 *vals = gts->avail_time_tables; 708 - *type = IIO_VAL_INT; 709 - *length = gts->num_avail_time_tables; 686 + *type = IIO_VAL_INT_PLUS_MICRO; 687 + *length = gts->num_avail_time_tables * 2; 710 688 711 689 return IIO_AVAIL_LIST; 712 690 }
+20 -6
drivers/iio/light/rohm-bu27034.c
··· 231 231 232 232 static const struct regmap_range bu27034_volatile_ranges[] = { 233 233 { 234 + .range_min = BU27034_REG_SYSTEM_CONTROL, 235 + .range_max = BU27034_REG_SYSTEM_CONTROL, 236 + }, { 234 237 .range_min = BU27034_REG_MODE_CONTROL4, 235 238 .range_max = BU27034_REG_MODE_CONTROL4, 236 239 }, { ··· 1170 1167 1171 1168 switch (mask) { 1172 1169 case IIO_CHAN_INFO_INT_TIME: 1173 - *val = bu27034_get_int_time(data); 1174 - if (*val < 0) 1175 - return *val; 1170 + *val = 0; 1171 + *val2 = bu27034_get_int_time(data); 1172 + if (*val2 < 0) 1173 + return *val2; 1176 1174 1177 - return IIO_VAL_INT; 1175 + return IIO_VAL_INT_PLUS_MICRO; 1178 1176 1179 1177 case IIO_CHAN_INFO_SCALE: 1180 1178 return bu27034_get_scale(data, chan->channel, val, val2); ··· 1233 1229 ret = bu27034_set_scale(data, chan->channel, val, val2); 1234 1230 break; 1235 1231 case IIO_CHAN_INFO_INT_TIME: 1236 - ret = bu27034_try_set_int_time(data, val); 1232 + if (!val) 1233 + ret = bu27034_try_set_int_time(data, val2); 1234 + else 1235 + ret = -EINVAL; 1237 1236 break; 1238 1237 default: 1239 1238 ret = -EINVAL; ··· 1275 1268 int ret, sel; 1276 1269 1277 1270 /* Reset */ 1278 - ret = regmap_update_bits(data->regmap, BU27034_REG_SYSTEM_CONTROL, 1271 + ret = regmap_write_bits(data->regmap, BU27034_REG_SYSTEM_CONTROL, 1279 1272 BU27034_MASK_SW_RESET, BU27034_MASK_SW_RESET); 1280 1273 if (ret) 1281 1274 return dev_err_probe(data->dev, ret, "Sensor reset failed\n"); 1282 1275 1283 1276 msleep(1); 1277 + 1278 + ret = regmap_reinit_cache(data->regmap, &bu27034_regmap); 1279 + if (ret) { 1280 + dev_err(data->dev, "Failed to reinit reg cache\n"); 1281 + return ret; 1282 + } 1283 + 1284 1284 /* 1285 1285 * Read integration time here to ensure it is in regmap cache. We do 1286 1286 * this to speed-up the int-time acquisition in the start of the buffer
+3
drivers/iio/light/vcnl4035.c
··· 8 8 * TODO: Proximity 9 9 */ 10 10 #include <linux/bitops.h> 11 + #include <linux/bitfield.h> 11 12 #include <linux/i2c.h> 12 13 #include <linux/module.h> 13 14 #include <linux/pm_runtime.h> ··· 43 42 #define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) 44 43 #define VCNL4035_INT_ALS_IF_H_MASK BIT(12) 45 44 #define VCNL4035_INT_ALS_IF_L_MASK BIT(13) 45 + #define VCNL4035_DEV_ID_MASK GENMASK(7, 0) 46 46 47 47 /* Default values */ 48 48 #define VCNL4035_MODE_ALS_ENABLE BIT(0) ··· 415 413 return ret; 416 414 } 417 415 416 + id = FIELD_GET(VCNL4035_DEV_ID_MASK, id); 418 417 if (id != VCNL4035_DEV_ID_VAL) { 419 418 dev_err(&data->client->dev, "Wrong id, got %x, expected %x\n", 420 419 id, VCNL4035_DEV_ID_VAL);
+3 -2
drivers/iio/magnetometer/tmag5273.c
··· 296 296 return ret; 297 297 298 298 ret = tmag5273_get_measure(data, &t, &x, &y, &z, &angle, &magnitude); 299 - if (ret) 300 - return ret; 301 299 302 300 pm_runtime_mark_last_busy(data->dev); 303 301 pm_runtime_put_autosuspend(data->dev); 302 + 303 + if (ret) 304 + return ret; 304 305 305 306 switch (chan->address) { 306 307 case TEMPERATURE:
+1 -1
include/linux/iio/iio-gts-helper.h
··· 135 135 /** 136 136 * iio_gts_find_sel_by_int_time - find selector matching integration time 137 137 * @gts: Gain time scale descriptor 138 - * @gain: HW-gain for which matching selector is searched for 138 + * @time: Integration time for which matching selector is searched for 139 139 * 140 140 * Return: a selector matching given integration time or -EINVAL if 141 141 * selector was not found.