From patchwork Tue Jun 28 15:16:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 12898463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 516FAC43334 for ; Tue, 28 Jun 2022 15:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v+wmC2nXHEKLxo6ibZdi3rCTVzUl5aEAqvlKNZpqhzU=; b=g2fknEyybSkSno cgvaKp/T/rcTfltuRoUz8G//u5jqcj4EjZh2Jn09/8JVJJQf6dT342M6LMCy2M4cV5Jo+3ogPe6/g GvDP9W2OrAltjVCICUm/fBrTerbreYQkcMUnx6660w7xSracPypmBxbgdQgDUrvib3m1WXb0gZkOE ZN6EeCMTFS9j+CZxFbiSOHqe1b35j6WN/wUjBSsSrIIuRm0gPOxpe6uPH4kcGuDOcjt5siTfjqrVR CjiBDPCeFGFOqoQIuBD1hINVjWGlZqWO1ZPMC1RQtZu8+EvwuXIPmGAOiLGrcPnETdcekd9cBZKrg FG0lKzwtCjcdw8VJmNOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6Cv4-006pxt-SW; Tue, 28 Jun 2022 15:14:27 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6Cuz-006pvE-Lk for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2022 15:14:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656429261; x=1687965261; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NNq6gdlQsaf7ue8ni5xZBhwoM33UgV11nIU8tW4lZbk=; b=PkekcCTFpe7tji3MezUchPhm1bX9beiFlJRQNxD5DLWSjo0CjIuvC8wk 5oLkOIdhmwJe/oxEQ5Ng/jskH/3Tx6IVowOdO2Ph9HWOkdIQ8mrNPxlcv owlRWMGVgJgBJdMYushwbvSedof3Ig58EY3+O3eKSYELgxrKKjSW+ROSm 6jKbcYa+Wg/b4zcNiD9s8f1bIud+/InGbBd5Gfo5TM4O3B/Cvfl++SKDV 5E+MJuZuBhsg9XfEsCV9lOp3wVcLwSJpAgCh/D6DbY/6JLICT4RBBtrQm ggQRr3Es3D0ss6k/n7UGExhTqIHVOP7YQPRckQMuGvaLBEv9nv3Iu51rN g==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="170219090" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 08:14:19 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 08:14:19 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 08:14:16 -0700 From: Claudiu Beznea To: , , , , , , , CC: , , , Subject: [PATCH v2 02/19] iio: adc: at91-sama5d2_adc: check return status for pressure and touch Date: Tue, 28 Jun 2022 18:16:14 +0300 Message-ID: <20220628151631.3116454-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220628151631.3116454-1-claudiu.beznea@microchip.com> References: <20220628151631.3116454-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220628_081421_807707_9A371C69 X-CRM114-Status: GOOD ( 11.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Check return status of at91_adc_read_position() and at91_adc_read_pressure() in at91_adc_read_info_raw(). Fixes: 6794e23fa3fe ("iio: adc: at91-sama5d2_adc: add support for oversampling resolution") Signed-off-by: Claudiu Beznea --- drivers/iio/adc/at91-sama5d2_adc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 32b6f157b803..c3301c749164 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1544,8 +1544,10 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, *val = tmp_val; mutex_unlock(&st->lock); iio_device_release_direct_mode(indio_dev); + if (ret > 0) + ret = at91_adc_adjust_val_osr(st, val); - return at91_adc_adjust_val_osr(st, val); + return ret; } if (chan->type == IIO_PRESSURE) { ret = iio_device_claim_direct_mode(indio_dev); @@ -1558,8 +1560,10 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev, *val = tmp_val; mutex_unlock(&st->lock); iio_device_release_direct_mode(indio_dev); + if (ret > 0) + ret = at91_adc_adjust_val_osr(st, val); - return at91_adc_adjust_val_osr(st, val); + return ret; } /* in this case we have a voltage channel */