* [PATCH v2] iio: amplifiers: ad8366: Add the missed check for devm_gpiod_get()
@ 2020-05-28 6:40 Chuhong Yuan
2020-05-28 9:42 ` Ardelean, Alexandru
0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2020-05-28 6:40 UTC (permalink / raw)
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Hartmut Knaack, Peter Meerwald-Stadler, Paul Cercueil,
Alexandru Ardelean, linux-iio, linux-kernel, Chuhong Yuan
ad8366_probe() forgets to check the return value of devm_gpiod_get().
Add the missed check to fix it.
Fixes: cee211f4e5a0 ("iio: amplifiers: ad8366: Add support for the ADA4961 DGA")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
Changes in v2:
- Add fixes tag.
drivers/iio/amplifiers/ad8366.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 62167b87caea..b996823c8d51 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -264,6 +264,10 @@ static int ad8366_probe(struct spi_device *spi)
case ID_HMC1119:
st->reset_gpio = devm_gpiod_get(&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;
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] iio: amplifiers: ad8366: Add the missed check for devm_gpiod_get()
2020-05-28 6:40 [PATCH v2] iio: amplifiers: ad8366: Add the missed check for devm_gpiod_get() Chuhong Yuan
@ 2020-05-28 9:42 ` Ardelean, Alexandru
0 siblings, 0 replies; 2+ messages in thread
From: Ardelean, Alexandru @ 2020-05-28 9:42 UTC (permalink / raw)
To: hslester96
Cc: pmeerw, linux-iio, lars, linux-kernel, paul.cercueil, Hennerich,
Michael, knaack.h, jic23
On Thu, 2020-05-28 at 14:40 +0800, Chuhong Yuan wrote:
> [External]
>
> ad8366_probe() forgets to check the return value of devm_gpiod_get().
> Add the missed check to fix it.
>
> Fixes: cee211f4e5a0 ("iio: amplifiers: ad8366: Add support for the
> ADA4961 DGA")
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
> Changes in v2:
> - Add fixes tag.
>
> drivers/iio/amplifiers/ad8366.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c
> b/drivers/iio/amplifiers/ad8366.c
> index 62167b87caea..b996823c8d51 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -264,6 +264,10 @@ static int ad8366_probe(struct spi_device *spi)
> case ID_HMC1119:
> st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
> GPIOD_OUT_HIGH);
this is semi-intentional i guess;
in the sense that if there is no GPIO, nothing happens;
maybe convert this to devm_gpiod_get_optional()
otherwise, if there is no reset GPIO, this can fail the probe; and the GPIO
is not optional;
rest of the code looks fine (with the devm_gpiod_get_optional()
modification)
> + 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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-28 9:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 6:40 [PATCH v2] iio: amplifiers: ad8366: Add the missed check for devm_gpiod_get() Chuhong Yuan
2020-05-28 9:42 ` Ardelean, Alexandru
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).