[PATCH v3 4/6] iio: adc: ti-ads7950: simplify check for spi_setup() failures

Dmitry Torokhov posted 6 patches 1 month ago
There is a newer version of this series
[PATCH v3 4/6] iio: adc: ti-ads7950: simplify check for spi_setup() failures
Posted by Dmitry Torokhov 1 month ago
spi_setup() specifies that it returns 0 on success or negative error on
failure. Therefore we can simply check for the return code being 0 or
not.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/iio/adc/ti-ads7950.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
index 1515089dd759..273c35e03185 100644
--- a/drivers/iio/adc/ti-ads7950.c
+++ b/drivers/iio/adc/ti-ads7950.c
@@ -527,7 +527,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
 	spi->bits_per_word = 16;
 	spi->mode |= SPI_CS_WORD;
 	ret = spi_setup(spi);
-	if (ret < 0) {
+	if (ret) {
 		dev_err(&spi->dev, "Error in spi setup\n");
 		return ret;
 	}

-- 
2.53.0.473.g4a7958ca14-goog
Re: [PATCH v3 4/6] iio: adc: ti-ads7950: simplify check for spi_setup() failures
Posted by David Lechner 1 month ago
On 3/5/26 1:21 PM, Dmitry Torokhov wrote:
> spi_setup() specifies that it returns 0 on success or negative error on
> failure. Therefore we can simply check for the return code being 0 or
> not.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
Reviewed-by: David Lechner <dlechner@baylibre.com>
Re: [PATCH v3 4/6] iio: adc: ti-ads7950: simplify check for spi_setup() failures
Posted by Jonathan Cameron 1 month ago
On Thu, 05 Mar 2026 11:21:55 -0800
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> spi_setup() specifies that it returns 0 on success or negative error on
> failure. Therefore we can simply check for the return code being 0 or
> not.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/iio/adc/ti-ads7950.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c
> index 1515089dd759..273c35e03185 100644
> --- a/drivers/iio/adc/ti-ads7950.c
> +++ b/drivers/iio/adc/ti-ads7950.c
> @@ -527,7 +527,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
>  	spi->bits_per_word = 16;
>  	spi->mode |= SPI_CS_WORD;
>  	ret = spi_setup(spi);
> -	if (ret < 0) {
Given it doesn't really fit better in patch 6 than it does here
maybe drag the
	if (ret)
		return dev_err_probe();
here instead just to avoid tiny it of churn around brackets.

Not important though.

> +	if (ret) {
>  		dev_err(&spi->dev, "Error in spi setup\n");
>  		return ret;
>  	}
>