diff options
author | Chuhong Yuan <hslester96@gmail.com> | 2020-06-03 12:26:10 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2020-06-14 13:49:55 +0300 |
commit | 9ca39411f9a9c833727750431da8dfd96ff80005 (patch) | |
tree | 1e2f57fd2723646b6d94e890ae649be6b92b93cb /drivers/iio/amplifiers/ad8366.c | |
parent | df16c33a4028159d1ba8a7061c9fa950b58d1a61 (diff) | |
download | linux-9ca39411f9a9c833727750431da8dfd96ff80005.tar.xz |
iio: amplifiers: ad8366: Change devm_gpiod_get() to optional and add the missed check
Since if there is no GPIO, nothing happens, replace devm_gpiod_get()
with devm_gpiod_get_optional().
Also add IS_ERR() to fix the missing-check warning.
Fixes: cee211f4e5a0 ("iio: amplifiers: ad8366: Add support for the ADA4961 DGA")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/amplifiers/ad8366.c')
-rw-r--r-- | drivers/iio/amplifiers/ad8366.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 62167b87caea..8345ba65d41d 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -262,8 +262,11 @@ static int ad8366_probe(struct spi_device *spi) case ID_ADA4961: case ID_ADL5240: case ID_HMC1119: - st->reset_gpio = devm_gpiod_get(&spi->dev, "reset", - GPIOD_OUT_HIGH); + st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(st->reset_gpio)) { + ret = PTR_ERR(st->reset_gpio); + goto error_disable_reg; + } indio_dev->channels = ada4961_channels; indio_dev->num_channels = ARRAY_SIZE(ada4961_channels); break; |