iio: adc: fsl-imx25-gcq: initialize regulators as needed
authorAlexandru Ardelean <aardelean@deviqon.com>
Fri, 25 Jun 2021 07:43:25 +0000 (10:43 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 19 Oct 2021 07:27:34 +0000 (08:27 +0100)
commitc5fd034a2ac99117f67f9ab7653912af33f9106e
tree629fcc267f110a82bd89f4d0183e5a0fab9f6a0e
parent1b7da2fa18f723a821c49aa67d4ba9603a386c0a
iio: adc: fsl-imx25-gcq: initialize regulators as needed

The driver tries to initialize all possible regulators from the DT, then
match the external regulators with each channel and then release all unused
regulators.

We can change the logic a bit to initialize regulators only when at least
one channel needs them.

This change creates a mx25_gcq_ext_regulator_setup() function that is
called only for the external regulators. If there's already a reference to
an external regulator, the function will just exit early with no error.

This way, the driver doesn't need to keep any track of these regulators
during init.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210625074325.9237-1-aardelean@deviqon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/fsl-imx25-gcq.c