From patchwork Tue Nov 21 10:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 167618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp521115vqb; Tue, 21 Nov 2023 02:19:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGS4ORNifg5IgvYWUdoa/OkhTF3TGKsc0AZN9qamku/NWlsNpTrVcZ+KwPuO5j7bzy7UTyn X-Received: by 2002:a17:903:22c7:b0:1cf:5c99:75f8 with SMTP id y7-20020a17090322c700b001cf5c9975f8mr7678630plg.65.1700561967401; Tue, 21 Nov 2023 02:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700561967; cv=none; d=google.com; s=arc-20160816; b=LCr+PAbJuLhaU8BXtOFUfCBtvuvIvYbqv7kTaZ+SQ1sBm+UXSM7wt4jRZ/MipwxLc+ RapoRzHIxGEGLjn9O14F2o29TYezvAtpN9Y+chiW74fmAIFcQrMl8wlc1SC1s8C6/HwF gq/C5EefYw7bow7NihYApsiPnBz9ZmbvFs46FyI/rrGtMr+DieaNTj9M0BmFA0wHR6wY 0PLPVG3x9ZnaMUrz5DQCnfAksQXUSCfFnw/4iyu8jxA/K045vjLw6sfvovLbACdc+f/x 0Ldp+igGN6izmPUFJdkycJ9W9ACY6T8sY7+oixGP2DrNRgseA7GaSpJBlv0jAkt3CFQa jYPw== 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 Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p7-20020a170902a40700b001ca30930778si9429046plq.71.2023.11.21.02.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:19:27 -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 A6086810438D; Tue, 21 Nov 2023 02:17:48 -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 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:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783168465503530568 X-GMAIL-MSGID: 1783168465503530568 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;