Skip to contentSkip to conversation

adc: correctly check return value

PATCH In review Insu Yun 2 participants 2 messages Oct 19, 2015

Subsystems (2)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 adc: correctly check return value

Since devm_regulator_get returns address or error, not NULL, it needs to be checked with IS_ERR, not IS_ERR_OR_NULL.

---
 drivers/iio/adc/ad7266.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7266.c +1 -1
index 70f78c3..26cd54b 100644
@@ -397,7 +397,7 @@ static int ad7266_probe(struct spi_device *spi)
 	st = iio_priv(indio_dev);
 
 	st->reg = devm_regulator_get(&spi->dev, "vref");
-	if (!IS_ERR_OR_NULL(st->reg)) {
+	if (!IS_ERR(st->reg)) {
 		ret = regulator_enable(st->reg);
 		if (ret)
 			return ret;
Signature · 1 line
1.9.1
#1 lore raw

Insu Yun schrieb am 19.10.2015 um 18:08:

Quoted 3 lines

Since devm_regulator_get returns address or error, not NULL, it needs to be checked with IS_ERR, not IS_ERR_OR_NULL.

Actually, it does return NULL, if regulator support is disabled (see [1]).

[1]http://lxr.free-electrons.com/source/include/linux/regulator/consumer.h#L286

Quoted 19 lines
---
 drivers/iio/adc/ad7266.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7266.c +1 -1
index 70f78c3..26cd54b 100644
@@ -397,7 +397,7 @@ static int ad7266_probe(struct spi_device *spi)
 	st = iio_priv(indio_dev);
 
 	st->reg = devm_regulator_get(&spi->dev, "vref");
-	if (!IS_ERR_OR_NULL(st->reg)) {
+	if (!IS_ERR(st->reg)) {
 		ret = regulator_enable(st->reg);
 		if (ret)
 			return ret;