Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp275428rdf; Tue, 21 Nov 2023 02:19:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7vDo1ZbFljJ7hqGPgq+QQkr9ssHObJkzz5IeblmkYDEcTBS0NTcNR24rKbVFzxLwA2KkU X-Received: by 2002:a05:6a21:8cc7:b0:187:1ea7:9509 with SMTP id ta7-20020a056a218cc700b001871ea79509mr13228140pzb.32.1700561970244; Tue, 21 Nov 2023 02:19:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700561970; cv=none; d=google.com; s=arc-20160816; b=KE20sVOVguJTxaY8rxifP3yXEQlah1anJRwXfXzhaCit20daocY7Za8uysAWFN0xa3 TMay7Aog1nnUnftfHWE4NVyDwEII0YIzO59yEMXK9bz3BG7Il4LaKkv7noV94RXbTdZY SIPmbEN6atiFz/h+x26n7LIjpmja7bnD6OBQQZqrX3IVvf/XwhHhXwWCIQn8EOvKAEuQ JC7QcWdfBZ7x5UOq6pPX3cCUGsdJgX4og0Xaa1eaFQDW+HickL3mRUIHbNl9frgjcjhF 6Q9zrE9VBWbg0G000MFDMCiMQIm/k/hz7DGatZCiyyHtc64xhpsvQwTYpaWyTS64UCyq YpyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=DAZY5AJ+GBHEyNx/dy9x+RErJZiZi/jB6WP5lrFGW7Y=; fh=phDggtdq/mZScnogaJFJfeRDE2XPpZpUuxL35p15uks=; b=p7uz+VMbeht5c0nrtZ7eG+9sAnju6KrGrpQLOiRwym4yC1k8y2G5JtE/JK9JycimKZ B6xvjUYTAfMUm0uRbkH++QASf+4UXGXdJhoVY3cqKUCVKA5PztqVQV9K8Z0D5to65ghf dNwH6GJtPNc62yv83gnbYck5cFJcsrVsm0BBmHz56+z3gcPd+CsowXxCzAlAbCGXFfkJ hcVntWZe3rxkWWlCCbBRFF65lhSry72qSnIYhIq6SrjjCySZiHXM61004sCZ9m/957sY VKnLL6FlRXQBnnrUte/CHIpv7X1GTXEf86+USdY4LYxHYqonvC1oxTw2qZKR6ABtjEFc SVIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qWgIDHcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id lk4-20020a17090b33c400b00277453e82fesi10658691pjb.87.2023.11.21.02.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:19:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qWgIDHcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DEADE81043B4; Tue, 21 Nov 2023 02:17:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232493AbjKUKRs (ORCPT + 99 others); Tue, 21 Nov 2023 05:17:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232964AbjKUKRY (ORCPT ); Tue, 21 Nov 2023 05:17:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10031113 for ; Tue, 21 Nov 2023 02:17:21 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPS id 65C59C43215; Tue, 21 Nov 2023 10:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700561839; bh=qSUa7Hi/hUvGOoV6T8t+VfM63v3j7nIpVAXf0Nwefts=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qWgIDHcjtrnHnJCZozZC23X8yKhhvdi6PscYnSnqGN/hur4B5WMyBBAgV9hbRKEHl Q5X15wT0LX9tPbiAun3N0ifbMEt+pKH+ztuPEdUESZGPk0WrwNsJ39eCLaFq4lJFpO gcBVv/nXhkcEQJt7RxSUJcIKJH0dwXazuVsqWMnqCoOP4YRJzE5Mx7oTAiRBL1Q14e mOECvk9dPv1Iy41EndovdhNow/5t8UDqGwDHmwY7PkkmgjIxc42OShjd7AVvcO97Zp 5gfPdvexpN36clBpRCL9MZb8fE90mzGe8xrqjmhw1qXxQqhEqrAZuEAKIvhYBdB+TR gh6/HQUOz5aEQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 554F2C61D88; Tue, 21 Nov 2023 10:17:19 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Tue, 21 Nov 2023 11:20:18 +0100 Subject: [PATCH 05/12] iio: adc: ad9467: don't ignore error codes MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231121-dev-iio-backend-v1-5-6a3d542eba35@analog.com> References: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> In-Reply-To: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org Cc: Olivier MOYSAN , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nuno Sa X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700562016; l=2285; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=p+reK//8NVmJckTKVuZ5PeMlMhxvLT/SuRjMD0wgKfo=; b=R49EuewoiHYxiFgzjwcP3nIvMmY3PaNku9HMivMl6qBa1cAQ4vL1PO2YimCWCUzwwgQil7p41 rK7JWGwGhYhAXTFw/8uQ5/zSJbi1frMDouMhKua7NwtA37UYKhmdp5O X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:17:52 -0800 (PST) From: Nuno Sa Make sure functions that return errors are not ignored. Fixes: ad6797120238 ("iio: adc: ad9467: add support AD9467 ADC") Signed-off-by: Nuno Sa --- drivers/iio/adc/ad9467.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c index 368ea57be117..04474dbfa631 100644 --- a/drivers/iio/adc/ad9467.c +++ b/drivers/iio/adc/ad9467.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -160,11 +161,12 @@ static int ad9467_reg_access(struct adi_axi_adc_conv *conv, unsigned int reg, struct spi_device *spi = st->spi; int ret; - if (readval == NULL) { + if (!readval) { ret = ad9467_spi_write(spi, reg, writeval); - ad9467_spi_write(spi, AN877_ADC_REG_TRANSFER, - AN877_ADC_TRANSFER_SYNC); - return ret; + if (ret) + return ret; + return ad9467_spi_write(spi, AN877_ADC_REG_TRANSFER, + AN877_ADC_TRANSFER_SYNC); } ret = ad9467_spi_read(spi, reg); @@ -274,6 +276,8 @@ static int ad9467_get_scale(struct adi_axi_adc_conv *conv, int *val, int *val2) unsigned int i, vref_val; vref_val = ad9467_spi_read(st->spi, AN877_ADC_REG_VREF); + if (vref_val < 0) + return vref_val; vref_val &= info1->vref_mask; @@ -296,6 +300,7 @@ static int ad9467_set_scale(struct adi_axi_adc_conv *conv, int val, int val2) struct ad9467_state *st = adi_axi_adc_conv_priv(conv); unsigned int scale_val[2]; unsigned int i; + int ret; if (val != 0) return -EINVAL; @@ -305,11 +310,13 @@ static int ad9467_set_scale(struct adi_axi_adc_conv *conv, int val, int val2) if (scale_val[0] != val || scale_val[1] != val2) continue; - ad9467_spi_write(st->spi, AN877_ADC_REG_VREF, - info->scale_table[i][1]); - ad9467_spi_write(st->spi, AN877_ADC_REG_TRANSFER, - AN877_ADC_TRANSFER_SYNC); - return 0; + ret = ad9467_spi_write(st->spi, AN877_ADC_REG_VREF, + info->scale_table[i][1]); + if (ret < 0) + return ret; + + return ad9467_spi_write(st->spi, AN877_ADC_REG_TRANSFER, + AN877_ADC_TRANSFER_SYNC); } return -EINVAL; -- 2.42.1