Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	linux-iio@vger.kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	David Lechner <dlechner@baylibre.com>,
	Trevor Gamblin <tgamblin@baylibre.com>,
	Nuno Sa <nuno.sa@analog.com>
Subject: Re: [PATCH v4 09/10] iio: adc: ad7124: Add error reporting during probe
Date: Sat, 30 Nov 2024 18:56:49 +0000	[thread overview]
Message-ID: <20241130185649.2e2d68db@jic23-huawei> (raw)
In-Reply-To: <20241127145929.679408-21-u.kleine-koenig@baylibre.com>

On Wed, 27 Nov 2024 15:59:38 +0100
Uwe Kleine-König <u.kleine-koenig@baylibre.com> wrote:

> A driver that silently fails to probe is annoying and hard to debug. So
> add messages in the error paths of the probe function.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Probably worth calling out in this patch description that you also
replace some dev_err() calls with dev_err_probe()

One comment inline.

Thanks,

Jonathan

> @@ -1007,36 +1008,42 @@ static int ad7124_probe(struct spi_device *spi)
>  
>  		ret = regulator_enable(st->vref[i]);
>  		if (ret)
> -			return ret;
> +			return dev_err_probe(dev, ret, "Failed to enable regulator #%d\n", i);
>  
>  		ret = devm_add_action_or_reset(&spi->dev, ad7124_reg_disable,
>  					       st->vref[i]);
>  		if (ret)
> -			return ret;
> +			return dev_err_probe(dev, ret, "Failed to register disable handler for regulator #%d\n", i);
>  	}
>  
>  	st->mclk = devm_clk_get_enabled(&spi->dev, "mclk");
>  	if (IS_ERR(st->mclk))
> -		return PTR_ERR(st->mclk);
> +		return dev_err_probe(dev, PTR_ERR(st->mclk), "Failed to get mclk\n");
>  
>  	ret = ad7124_soft_reset(st);
>  	if (ret < 0)
> +		/* ad7124_soft_reset() already emitted an error message */
I'd not bother adding these already emitted comments.
The only time we'd care is if someone else comes along and adds them. Hopefully we'd
catch that anyway in review, but even if don't it wouldn't matter a lot.
>  		return ret;
>  
>  	ret = ad7124_check_chip_id(st);
>  	if (ret)
> +		/* ad7124_check_chip_id() already emitted an error message */
>  		return ret;
>  
>  	ret = ad7124_setup(st);
>  	if (ret < 0)
> +		/* ad7124_setup() already emitted an error message */
>  		return ret;
>  
>  	ret = devm_ad_sd_setup_buffer_and_trigger(&spi->dev, indio_dev);
>  	if (ret < 0)
> -		return ret;
> +		return dev_err_probe(dev, ret, "Failed to setup triggers\n");
>  
> -	return devm_iio_device_register(&spi->dev, indio_dev);
> +	ret = devm_iio_device_register(&spi->dev, indio_dev);
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "Failed to register iio device\n");
>  
> +	return 0;
>  }
>  
>  static const struct of_device_id ad7124_of_match[] = {


  reply	other threads:[~2024-11-30 18:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27 14:59 [PATCH v4 00/10] iio: adc: ad7124: Various fixes Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 01/10] iio: adc: ad7124: Don't create more channels than the driver can handle Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 02/10] iio: adc: ad7124: Refuse invalid input specifiers Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 03/10] dt-bindings: iio: adc: adi,ad7{124,173,192,780}: Allow specifications of a gpio for irq line Uwe Kleine-König
2024-11-27 15:12   ` Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 04/10] iio: adc: ad_sigma_delta: Add support for reading irq status using a GPIO Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 05/10] iio: adc: ad_sigma_delta: Handle CS assertion as intended in ad_sd_read_reg_raw() Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 06/10] iio: adc: ad_sigma_delta: Fix a race condition Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 07/10] iio: adc: ad_sigma_delta: Store information about reset sequence length Uwe Kleine-König
2024-11-27 14:59 ` [PATCH v4 08/10] iio: adc: ad_sigma_delta: Check for previous ready signals Uwe Kleine-König
2024-11-30 18:53   ` Jonathan Cameron
2024-11-27 14:59 ` [PATCH v4 09/10] iio: adc: ad7124: Add error reporting during probe Uwe Kleine-König
2024-11-30 18:56   ` Jonathan Cameron [this message]
2024-11-27 14:59 ` [PATCH v4 10/10] iio: adc: ad7124: Implement temperature measurement Uwe Kleine-König
2024-11-30 18:59   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241130185649.2e2d68db@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=tgamblin@baylibre.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox