iio: fetch and enable regulators unconditionally
Subsystems (2)
PATCH v2 1/2 iio: fetch and enable regulators unconditionally
This patch is inspired by a comment of Jonathan Cameron on patch of
Linus Walleij commit aeb55fff3891834e07a3144159a7298a19696af8 ("iio: st_sensors: fetch and enable regulators unconditionally").
The explanation for this change is same as in that patch:
"Supplies are *not* optional (optional means that the supply is optional in the electrical sense, not the software sense) so we need to get the and enable them at all times.
If the device tree or board file does not define suitable regulators for the component, it will be substituted by a dummy regulator, or, if regulators are disabled altogether, by stubs. There is no need to use the IS_ERR_OR_NULL() check that is considered harmful.
--- drivers/iio/pressure/ms5611_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/pressure/ms5611_core.c +2 -4
@@ -416,8 +416,7 @@ static int ms5611_init(struct iio_dev *indio_dev)return 0 ; err_regulator_disable: -if (!IS_ERR_OR_NULL (st->vdd)) -regulator_disable (st->vdd); +regulator_disable (st->vdd);return ret; }
@@ -425,8 +424,7 @@ static void ms5611_fini(const struct iio_dev *indio_dev) {const struct ms5611_state *st =iio_priv (indio_dev); -if (!IS_ERR_OR_NULL (st->vdd)) -regulator_disable (st->vdd); +regulator_disable (st->vdd); } int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
Signature · 1 line
2.9.3
PATCH v2 2/2 iio: devm_regulator_get_optional never returns NULL
This patch is inspired by a comment of Jonathan Cameron on patch of Linus Walleij commit aeb55fff3891834e07a3144159a7298a19696af8 ("iio:st_sensors: fetch and enable regulators unconditionally"). Because changes made in this patch are actually reference generators they should be using devm_regulator_get_optional, but if they do not explicitly set the reference to NULL they should not be using IS_ERR_OR_NULL, but simple IS_ERR check.
--- drivers/iio/adc/ad7266.c | 4 ++-- drivers/iio/adc/ti-ads8688.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/iio/adc/ad7266.c +2 -2
@@ -481,7 +481,7 @@ error_free_gpios:if (!st->fixed_addr)gpio_free_array (st->gpios,ARRAY_SIZE (st->gpios)); error_disable_reg: -if (!IS_ERR_OR_NULL (st->reg)) +if (!IS_ERR (st->reg))regulator_disable (st->reg);return ret;
@@ -496,7 +496,7 @@ static int ad7266_remove(struct spi_device *spi)iio_triggered_buffer_cleanup (indio_dev);if (!st->fixed_addr)gpio_free_array (st->gpios,ARRAY_SIZE (st->gpios)); -if (!IS_ERR_OR_NULL (st->reg)) +if (!IS_ERR (st->reg))regulator_disable (st->reg);return 0 ;
drivers/iio/adc/ti-ads8688.c +2 -2
@@ -438,7 +438,7 @@ static int ads8688_probe(struct spi_device *spi)return 0 ; error_out: -if (!IS_ERR_OR_NULL (st->reg)) +if (!IS_ERR (st->reg))regulator_disable (st->reg);return ret;
@@ -451,7 +451,7 @@ static int ads8688_remove(struct spi_device *spi)iio_device_unregister (indio_dev); -if (!IS_ERR_OR_NULL (st->reg)) +if (!IS_ERR (st->reg))regulator_disable (st->reg);return 0 ;
Signature · 1 line
2.9.3
Re: [PATCH v2 2/2] iio: devm_regulator_get_optional never returns NULL
Quoted 10 lines · Crt Mori
This patch is inspired by a comment of Jonathan Cameron on patch of Linus Walleij commit
aeb55fff3891834e07a3144159a7298a19696af8("iio:st_sensors: fetch and enable regulators unconditionally"). Because changes made in this patch are actually reference generators they should be usingdevm_regulator_get_optional, but if they do not explicitly set the reference to NULL they should not be usingIS_ERR_OR_NULL, but simpleIS_ERRcheck.Suggested-by Lars-Peter Clausen <[email protected]>Signed-off-by Crt Mori <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v2 2/2] iio: devm_regulator_get_optional never returns NULL
In reply to Crt MoriQuoted 10 lines · Crt Mori
This patch is inspired by a comment of Jonathan Cameron on patch of Linus Walleij commit
aeb55fff3891834e07a3144159a7298a19696af8("iio:st_sensors: fetch and enable regulators unconditionally"). Because changes made in this patch are actually reference generators they should be usingdevm_regulator_get_optional, but if they do not explicitly set the reference to NULL they should not be usingIS_ERR_OR_NULL, but simpleIS_ERRcheck.Suggested-by Lars-Peter Clausen <[email protected]>Signed-off-by Crt Mori <[email protected]>
Looks good, thanks.
Jonathan Cameron
maintainerRe: [PATCH v2 2/2] iio: devm_regulator_get_optional never returns NULL
Quoted 9 lines · Lars-Peter Clausen
Quoted 8 lines · Crt Mori
This patch is inspired by a comment of Jonathan Cameron on patch of Linus Walleij commit
aeb55fff3891834e07a3144159a7298a19696af8("iio:st_sensors: fetch and enable regulators unconditionally"). Because changes made in this patch are actually reference generators they should be usingdevm_regulator_get_optional, but if they do not explicitly set the reference to NULL they should not be usingIS_ERR_OR_NULL, but simpleIS_ERRcheck.
Quoted 6 lines
Quoted 2 lines
Suggested-by Lars-Peter Clausen <[email protected]>Signed-off-by Crt Mori <[email protected]>Looks good, thanks.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 7 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 8 lines · Crt Mori
This patch is inspired by a comment of Jonathan Cameron on patch of
Linus Walleij commitaeb55fff3891834e07a3144159a7298a19696af8("iio:st_sensors: fetch and enable regulators unconditionally").The explanation for this change is same as in that patch:
"Supplies are *not* optional (optional means that the supply is optional in the electrical sense, not the software sense) so we need to get the and enable them at all times.
Quoted 8 lines
If the device tree or board file does not define suitable regulators for the component, it will be substituted by a dummy regulator, or, if regulators are disabled altogether, by stubs. There is no need to use the
IS_ERR_OR_NULL()check that is considered harmful.Reported-by Linus Wallerij <[email protected]>Suggested-by Jonathan Cameron <[email protected]>Signed-off-by Crt Mori <[email protected]>
Applied to the togreg branch of iio.git. Initially pushed out as testing for the autobuilders to do their magic.
Thanks,
Jonathan
Quoted 29 lines
--- drivers/iio/pressure/ms5611_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/iio/pressure/ms5611_core.c +2
-4@@ -416,8 +416,7 @@ static int ms5611_init(struct iio_dev *indio_dev)return 0 ; err_regulator_disable: -if (!IS_ERR_OR_NULL (st->vdd)) -regulator_disable (st->vdd); +regulator_disable (st->vdd);return ret; }@@ -425,8 +424,7 @@ static void ms5611_fini(const struct iio_dev *indio_dev) {const struct ms5611_state *st =iio_priv (indio_dev); -if (!IS_ERR_OR_NULL (st->vdd)) -regulator_disable (st->vdd); +regulator_disable (st->vdd); } int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,