2023-06-14 07:50:02

by Markus Burri

[permalink] [raw]
Subject: [PATCH v3] iio: ado: ad7192: Add error check and more debug log

Print read and expected device ID as debug warning.
Add error check for ad_sd_init() result.

Signed-off-by: Markus Burri <[email protected]>
---
drivers/iio/adc/ad7192.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
index d71977b..220c3b7 100644
--- a/drivers/iio/adc/ad7192.c
+++ b/drivers/iio/adc/ad7192.c
@@ -403,8 +403,8 @@ static int ad7192_setup(struct ad7192_state *st, struct device_node *np)
id &= AD7192_ID_MASK;

if (id != st->chip_info->chip_id)
- dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n",
- id);
+ dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X != 0x%X)\n",
+ id, st->chip_info->chip_id);

st->mode = AD7192_MODE_SEL(AD7192_MODE_IDLE) |
AD7192_MODE_CLKSRC(st->clock_sel) |
@@ -1049,7 +1049,9 @@ static int ad7192_probe(struct spi_device *spi)
else
indio_dev->info = &ad7192_info;

- ad_sd_init(&st->sd, indio_dev, spi, &ad7192_sigma_delta_info);
+ ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7192_sigma_delta_info);
+ if (ret)
+ return ret;

ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
if (ret)
--
2.39.2



2023-06-17 18:46:16

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v3] iio: ado: ad7192: Add error check and more debug log

On Wed, 14 Jun 2023 09:30:33 +0200
Markus Burri <[email protected]> wrote:

> Print read and expected device ID as debug warning.
> Add error check for ad_sd_init() result.
>
> Signed-off-by: Markus Burri <[email protected]>
Hi Markus,

I've applied this to the togreg branch of iio.git which is initially pushed out
as testing for 0-day to see if it can find anything we missed.

A few things wrong process wise that I fixed.
1) Nuno had given a tag on v2. You should have added that to your v3 rather
than relying on the maintainer happening to remember it (which I only did
because of 2.
2) The patch title still has 'ado' not 'adi'

So stuff to keep in mind for next time!

Jonathan

> ---
> drivers/iio/adc/ad7192.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
> index d71977b..220c3b7 100644
> --- a/drivers/iio/adc/ad7192.c
> +++ b/drivers/iio/adc/ad7192.c
> @@ -403,8 +403,8 @@ static int ad7192_setup(struct ad7192_state *st, struct device_node *np)
> id &= AD7192_ID_MASK;
>
> if (id != st->chip_info->chip_id)
> - dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X)\n",
> - id);
> + dev_warn(&st->sd.spi->dev, "device ID query failed (0x%X != 0x%X)\n",
> + id, st->chip_info->chip_id);
>
> st->mode = AD7192_MODE_SEL(AD7192_MODE_IDLE) |
> AD7192_MODE_CLKSRC(st->clock_sel) |
> @@ -1049,7 +1049,9 @@ static int ad7192_probe(struct spi_device *spi)
> else
> indio_dev->info = &ad7192_info;
>
> - ad_sd_init(&st->sd, indio_dev, spi, &ad7192_sigma_delta_info);
> + ret = ad_sd_init(&st->sd, indio_dev, spi, &ad7192_sigma_delta_info);
> + if (ret)
> + return ret;
>
> ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
> if (ret)