Commit fbe84bd4 authored by Crt Mori's avatar Crt Mori Committed by Jonathan Cameron

iio: devm_regulator_get_optional never returns NULL

This patch is inspired by a comment of Jonathan Cameron on patch of
Linus Walleij commit aeb55fff ("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.
Suggested-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarCrt Mori <cmo@melexis.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 67516074
......@@ -481,7 +481,7 @@ static int ad7266_probe(struct spi_device *spi)
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;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment