linux/drivers/iio/adc
Evan Green db23d88756 iio: adc: qcom-spmi-adc5: Initialize prescale properly
adc5_get_dt_data uses a local, prop, feeds it to adc5_get_dt_channel_data,
and then puts the result into adc->chan_props. The problem is
adc5_get_dt_channel_data may not initialize that structure fully, so a
garbage value is used for prescale if the optional "qcom,pre-scaling" is
not defined in DT. adc5_read_raw then uses this as an array index,
generating a crash that looks like this:

[    6.683186] Unable to handle kernel paging request at virtual address ffffff90e78c7964
Call trace:
qcom_vadc_scale_code_voltage_factor+0x74/0x104
qcom_vadc_scale_hw_calib_die_temp+0x20/0x60
qcom_adc5_hw_scale+0x78/0xa4
adc5_read_raw+0x3d0/0x65c
iio_channel_read+0x240/0x30c
iio_read_channel_processed+0x10c/0x150
qpnp_tm_get_temp+0xc0/0x40c
of_thermal_get_temp+0x7c/0x98
thermal_zone_get_temp+0xac/0xd8
thermal_zone_device_update+0xc0/0x38c
qpnp_tm_probe+0x624/0x81c
platform_drv_probe+0xe4/0x11c
really_probe+0x188/0x3fc
driver_probe_device+0xb8/0x188
__device_attach_driver+0x114/0x180
bus_for_each_drv+0xd8/0x118
__device_attach+0x180/0x27c
device_initial_probe+0x20/0x2c
bus_probe_device+0x78/0x124
deferred_probe_work_func+0xfc/0x138
process_one_work+0x3d8/0x8b0
process_scheduled_works+0x48/0x6c
worker_thread+0x488/0x7cc
kthread+0x24c/0x264
ret_from_fork+0x10/0x18

Unfortunately, when I went to add the initializer for this and tried to
boot it, my machine shut down immediately, complaining that it was
hotter than the sun. It appears that adc5_chans_pmic and adc5_chans_rev2
were initializing prescale_index as if it were directly a divisor,
rather than the index into adc5_prescale_ratios that it is.

Fix the uninitialized value, and change the static initialization to use
indices into adc5_prescale_ratios.

Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-12 17:45:30 +00:00
..
ad799x.c drivers: iio: Update MODULE AUTHOR email address 2018-08-19 17:23:39 +01:00
ad7124.c iio: adc: Add ad7124 support 2018-11-17 16:41:09 +00:00
ad7266.c
ad7291.c
ad7298.c drivers: iio: Update MODULE AUTHOR email address 2018-08-19 17:23:39 +01:00
ad7476.c drivers: iio: Update MODULE AUTHOR email address 2018-08-19 17:23:39 +01:00
ad7766.c
ad7791.c iio: adc: ad7791: implement IIO_CHAN_INFO_SAMP_FREQ 2018-03-17 20:47:21 +00:00
ad7793.c drivers: iio: Update MODULE AUTHOR email address 2018-08-19 17:23:39 +01:00
ad7887.c drivers: iio: Update MODULE AUTHOR email address 2018-08-19 17:23:39 +01:00
ad7923.c drivers: iio: Update MODULE AUTHOR email address 2018-08-19 17:23:39 +01:00
ad7949.c iio:adc:ad7949: Add AD7949 ADC driver family 2018-11-03 09:44:34 +00:00
ad_sigma_delta.c iio: ad_sigma_delta: Allow to provide custom data register address 2018-11-17 16:30:00 +00:00
aspeed_adc.c iio: adc: aspeed: Fix error handling path 2018-01-14 11:01:13 +00:00
at91_adc.c iio: adc: at91: fix wrong channel number in triggered buffer mode 2018-09-29 12:30:24 +01:00
at91-sama5d2_adc.c iio: adc: at91-sama5d2_adc: fix up casting in at91_adc_read_info_raw() 2018-07-23 19:18:12 +01:00
axp20x_adc.c iio: adc: axp20x_adc: remove !! in favor of ternary condition 2018-02-24 12:19:45 +00:00
axp288_adc.c iio: Add macro to populate struct iio_map array 2017-12-02 13:28:21 +00:00
bcm_iproc_adc.c
berlin2-adc.c
cc10001_adc.c
cpcap-adc.c iio: adc: cpcap: fix incorrect validation 2017-12-02 11:15:13 +00:00
da9150-gpadc.c
dln2-adc.c
envelope-detector.c iio: envelope-detector: switch to SPDX license identifier 2018-08-20 19:27:05 +01:00
ep93xx_adc.c iio: ep93xx: remove redundant return value check of platform_get_resource() 2018-01-30 18:33:20 +00:00
exynos_adc.c iio: adc: exynos-adc: Add S5PV210 variant 2018-12-12 17:15:05 +00:00
fsl-imx25-gcq.c iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs() 2018-09-22 10:19:51 +01:00
hi8435.c
hx711.c iio: hx711: add delay until DOUT is ready 2018-07-15 09:36:38 +01:00
imx7d_adc.c iio: adc: fix spelling mistake: "Freeacale" -> "Freescale" 2018-05-22 18:17:57 +01:00
ina2xx-adc.c iio: adc: ina2xx: add in early -EINVAL returns in case statements 2018-10-21 15:43:11 +01:00
Kconfig iio: adc: Allow selection of Exynos ADC on S5PV210 2018-12-12 17:19:32 +00:00
lp8788_adc.c
lpc18xx_adc.c
lpc32xx_adc.c
ltc2471.c
ltc2485.c
ltc2497.c
Makefile iio: adc: Add ad7124 support 2018-11-17 16:41:09 +00:00
max1027.c treewide: devm_kmalloc() -> devm_kmalloc_array() 2018-06-12 16:19:22 -07:00
max1118.c
max1363.c iio: adc: max1363: merge calls to of_match_device and of_device_get_match_data 2018-07-08 10:35:17 +01:00
max9611.c iio: adc: max9611: convert to SPDX identifiers 2018-11-16 18:32:27 +00:00
max11100.c iio: adc: max11100: convert to SPDX identifiers 2018-11-16 18:32:27 +00:00
mcp320x.c
mcp3422.c
mcp3911.c iio: adc: add support for mcp3911 2018-08-19 20:02:48 +01:00
men_z188_adc.c
meson_saradc.c iio: adc: meson-saradc: fix internal clock names 2018-11-25 10:41:36 +00:00
mt6577_auxadc.c
mxs-lradc-adc.c
nau7802.c
palmas_gpadc.c
qcom-pm8xxx-xoadc.c iio: Convert to using %pOFn instead of device_node.name 2018-09-02 18:54:31 +01:00
qcom-spmi-adc5.c iio: adc: qcom-spmi-adc5: Initialize prescale properly 2018-12-12 17:45:30 +00:00
qcom-spmi-iadc.c
qcom-spmi-vadc.c
qcom-vadc-common.c iio: adc: Add QCOM SPMI PMIC5 ADC driver 2018-08-18 18:11:43 +01:00
qcom-vadc-common.h iio: adc: Add QCOM SPMI PMIC5 ADC driver 2018-08-18 18:11:43 +01:00
rcar-gyroadc.c iio: adc: rcar-gyroadc: convert to SPDX identifiers 2018-11-16 18:32:28 +00:00
rockchip_saradc.c
sc27xx_adc.c iio: adc: sc27xx: Add ADC data conversion timeout 2018-11-16 18:32:32 +00:00
sd_adc_modulator.c IIO: ADC: add sigma delta modulator support 2018-01-10 10:30:09 +00:00
spear_adc.c
stm32-adc-core.c iio: adc: stm32-adc: add power management support 2018-11-25 13:15:24 +00:00
stm32-adc-core.h iio: stm32: Adopt SPDX identifier 2018-01-08 16:03:41 +01:00
stm32-adc.c iio: adc: stm32-adc: switch off running adc when going to low power 2018-11-25 13:16:38 +00:00
stm32-dfsdm-adc.c Staging/IIO patches for 4.18-rc1 2018-06-09 10:32:39 -07:00
stm32-dfsdm-core.c iio: adc: stm32-dfsdm: Add support for stm32mp1 2018-05-12 10:22:17 +01:00
stm32-dfsdm.h IIO: ADC: add stm32 DFSDM core support 2018-01-10 10:30:11 +00:00
stx104.c iio: stx104: Implement get_multiple callback 2018-03-17 16:21:27 +00:00
sun4i-gpadc-iio.c iio: adc: sun4i-gpadc: use of_device_get_match_data 2017-10-21 18:48:00 +01:00
ti_am335x_adc.c iio: adc: ti_am335x_adc: Disable ADC during suspend unconditionally 2018-10-09 11:28:26 +01:00
ti-adc081c.c
ti-adc084s021.c
ti-adc108s102.c
ti-adc128s052.c iio: adc128s052: use SPDX-License-Identifier 2018-11-03 09:44:33 +00:00
ti-adc161s626.c iio: add SPDX identifier for various drivers 2018-02-18 11:55:19 +00:00
ti-adc0832.c
ti-adc12138.c iio: adc: adc12138: make array ch_to_mux static, makes object code smaller 2017-10-21 17:56:09 +01:00
ti-ads1015.c
ti-ads7950.c iio: adc: ti-ads7950: use SPI_CS_WORD to reduce CPU usage 2018-09-22 10:09:47 +01:00
ti-ads8688.c iio: adc: ti-ads8688: add trigger and buffer support 2018-05-12 12:00:30 +01:00
ti-tlc4541.c
twl4030-madc.c
twl6030-gpadc.c treewide: devm_kzalloc() -> devm_kcalloc() 2018-06-12 16:19:22 -07:00
vf610_adc.c
viperboard_adc.c
xilinx-xadc-core.c iio: adc: xilinx: Move request_irq before enabling interrupts 2018-07-29 13:30:35 +01:00
xilinx-xadc-events.c
xilinx-xadc.h iio: adc: xilinx: Remove platform_get_irq from xadc_remove function 2018-07-29 12:52:21 +01:00