First set of IIO fixes in the 4.12 cycle.

Matt finally set up the lightning storm he needed to test the as3935.

* core
  - Fix a null pointer deference in iio_trigger_write_current when changing
  from a non existent trigger to another non existent trigger.
* a3935
  - Recalibrate the RCO after resume.
  - Fix interrupt mask so that we actually get some interrupts.
  - Use iio_trigger_poll_chained as we aren't in interrupt context.
* am335x
  - Fix wrong allocation size provided for private data to iio_device_alloc.
* bcm_iproc
  - Swapped primary and secondary isr handlers.
* ltr501
  - Fix swapped als/ps register fields when enabling interrupts
* max9611
  - Wrong scale factor for the shunt_resistor attribute.
* sun4-gpadc
  - Module autoloading fixes by adding the device table declarations.
  - Fix parent device being used in devm functions.
iio: adc: sun4i-gpadc-iio: fix parent device being used in devm function

For the sake of DT binding stability, this IIO driver is a child of an
MFD driver for Allwinner A10, A13 and A31 because there already exists a
DT binding for this IP. The MFD driver has a DT node but the IIO driver
does not.

The IIO device registers the temperature sensor in the thermal framework
using the DT node of the parent, the MFD device, so the thermal
framework could match the phandle to the MFD device in the DT and the
struct device used to register in the thermal framework.

devm_thermal_zone_of_sensor_register was previously used to register the
thermal sensor with the parent struct device of the IIO device,
representing the MFD device. By doing so, we registered actually the
parent in the devm routine and not the actual IIO device.

This lead to the devm unregister function not being called when the IIO
module driver is removed. It resulted in the thermal framework still
polling the get_temp function of the IIO module while the device doesn't
exist anymore, thus generated a kernel panic.

Use the non-devm function instead and do the unregister manually in the
remove function.

Fixes: d1caa9905538 ("iio: adc: add support for Allwinner SoCs ADC")

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Reported-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 file changed