lkml.org 
[lkml]   [2020]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH v3] iio: amplifiers: ad8366: Change devm_gpiod_get() to optional and add the missed check
Date
On Wed, 2020-06-03 at 17:26 +0800, Chuhong Yuan wrote:
> 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 bug.
>

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

> Fixes: cee211f4e5a0 ("iio: amplifiers: ad8366: Add support for the ADA4961
> DGA")
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
> Changes in v3:
> - Change devm_gpiod_get() to optional.
> - Modify description.
>
> drivers/iio/amplifiers/ad8366.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 62167b87caea..8819e8997f76 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -262,8 +262,12 @@ 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",
> + 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;
\
 
 \ /
  Last update: 2020-06-03 12:20    [W:0.074 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site