diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2014-04-30 17:05:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-05-03 06:14:01 -0400 |
commit | 82a5803c782417754bdebb8dfa34edc62c0d8bbc (patch) | |
tree | 6a4313bfd68288928201061539f0052777b57eb3 /drivers/iio | |
parent | fd8122d12858132aa9684f2b979107a1f4bba139 (diff) |
staging: iio: ad799x: remove some unneeded IS_ERR() checks
My static checker is upset that we check IS_ERR(t->reg) when we know it
is not an ERR_PTR.
Checking for IS_ERR() twice is often a sign of confusion and buggy code.
In this case, if the call to "ret = regulator_enable(st->vref);" fails,
then we call "regulator_disable(st->vref);" and that's a mistake because
"st->vref" is not enabled.
I fixed these problems and Hartmut Knaack pointed out a couple unneeded
IS_ERR() checks in ad799x_remove() so I have removed those as well.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/ad799x.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 16a8b14b1921..39b4cb48d738 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c | |||
@@ -717,7 +717,7 @@ static int ad799x_probe(struct i2c_client *client, | |||
717 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | 717 | ret = iio_triggered_buffer_setup(indio_dev, NULL, |
718 | &ad799x_trigger_handler, NULL); | 718 | &ad799x_trigger_handler, NULL); |
719 | if (ret) | 719 | if (ret) |
720 | goto error_disable_reg; | 720 | goto error_disable_vref; |
721 | 721 | ||
722 | if (client->irq > 0) { | 722 | if (client->irq > 0) { |
723 | ret = devm_request_threaded_irq(&client->dev, | 723 | ret = devm_request_threaded_irq(&client->dev, |
@@ -739,11 +739,10 @@ static int ad799x_probe(struct i2c_client *client, | |||
739 | 739 | ||
740 | error_cleanup_ring: | 740 | error_cleanup_ring: |
741 | iio_triggered_buffer_cleanup(indio_dev); | 741 | iio_triggered_buffer_cleanup(indio_dev); |
742 | error_disable_vref: | ||
743 | regulator_disable(st->vref); | ||
742 | error_disable_reg: | 744 | error_disable_reg: |
743 | if (!IS_ERR(st->vref)) | 745 | regulator_disable(st->reg); |
744 | regulator_disable(st->vref); | ||
745 | if (!IS_ERR(st->reg)) | ||
746 | regulator_disable(st->reg); | ||
747 | 746 | ||
748 | return ret; | 747 | return ret; |
749 | } | 748 | } |
@@ -756,10 +755,8 @@ static int ad799x_remove(struct i2c_client *client) | |||
756 | iio_device_unregister(indio_dev); | 755 | iio_device_unregister(indio_dev); |
757 | 756 | ||
758 | iio_triggered_buffer_cleanup(indio_dev); | 757 | iio_triggered_buffer_cleanup(indio_dev); |
759 | if (!IS_ERR(st->vref)) | 758 | regulator_disable(st->vref); |
760 | regulator_disable(st->vref); | 759 | regulator_disable(st->reg); |
761 | if (!IS_ERR(st->reg)) | ||
762 | regulator_disable(st->reg); | ||
763 | kfree(st->rx_buf); | 760 | kfree(st->rx_buf); |
764 | 761 | ||
765 | return 0; | 762 | return 0; |