From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-f193.google.com ([209.85.160.193]:37314 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbeJZJUU (ORCPT ); Fri, 26 Oct 2018 05:20:20 -0400 Received: by mail-qt1-f193.google.com with SMTP id d14-v6so12209723qto.4 for ; Thu, 25 Oct 2018 17:45:30 -0700 (PDT) From: Matheus Tavares To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH 2/6] staging:iio:ad2s90: Make probe handle spi_setup failure Date: Thu, 25 Oct 2018 21:45:08 -0300 Message-Id: <20181026004512.31012-3-matheus.bernardino@usp.br> In-Reply-To: <20181026004512.31012-1-matheus.bernardino@usp.br> References: <20181026004512.31012-1-matheus.bernardino@usp.br> Sender: linux-iio-owner@vger.kernel.org List-Id: linux-iio@vger.kernel.org Previously, ad2s90_probe ignored the return code from spi_setup, not handling its possible failure. This patch makes ad2s90_probe check if the code is an error code and, if so, do the following: - Call dev_err with an appropriate error message. - Return the spi_setup's error code, aborting the execution of the rest of the function. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 11fac9f90148..d6a42e3f1bd8 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -88,7 +88,12 @@ static int ad2s90_probe(struct spi_device *spi) /* need 600ns between CS and the first falling edge of SCLK */ spi->max_speed_hz = 830000; spi->mode = SPI_MODE_3; - spi_setup(spi); + ret = spi_setup(spi); + + if (ret < 0) { + dev_err(&spi->dev, "spi_setup failed!\n"); + return ret; + } return 0; } -- 2.18.0