Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1190384pxu; Fri, 27 Nov 2020 01:43:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzZSQ2ABilWjisD9U2UY1BMYjfCFYmUmwY1Uf2AohmpA9iPq31jzfat3LkL1VCctTyl4Ko X-Received: by 2002:a17:906:1282:: with SMTP id k2mr6514576ejb.554.1606470201665; Fri, 27 Nov 2020 01:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606470201; cv=none; d=google.com; s=arc-20160816; b=nR3XrCDjM61rqY71OJ3FZ7e1+SiLnjdN9FMCrj6p5hTS/cEYiJPwLuDy95q4EUHx3g qoefuF9O5sdtn8LNrtkBbXE38KYI+3zuUhsBwy5oJKuw4/qZLU6usYFnTzet+jWIHhDL q+SEhIVKl8AQUgocW/FIoKkRXD3fGQ7nv8FnK9NDQn2JgB5u1GxqyHXL++BAc0m92ekF caAYiizbzsIWUAPpvUVCQ3O9D2ENZ6lzILjT8ZdvJF/8lQPRWe8gPWufeszcPtD4RERt oZr4+WBY4TEJlNv8L6DMkXrRvnlugeZNyNJ9iIvgihE15jtCwNRteCyvI25Jsp3w3MZR 7UyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BB6/FLh8rMrBdQkyzqti7Ar1Y0fQ9b8NmI2jTF42w8s=; b=YYkUZfMbeTxwID4vZD1Od4/JeNlcRuXWVwuAKM8tzjStkUjh06VF1iSyKPbhxB5jfs rcvsnYt17K9Nqw6kaEXplrAalXrswwBO+xM7/E1LC60cY/zDKKGEGIuo1Ieos9QIkS3C jce8P6yBf8LPJ8umrzM5ufAl7KNH/pI2KPkvSz61mEmEEt6Hw84DtmkZjtUxec/RNWTK waQe2dAX1hT7mo6stAY/LtUSNvdNqakAHjlzjW8JXED+iUWUU7uU9qyYXe29Rx6eGuMY 545jx3trGsFKKL0IsK9owcI7Ol+0SBO00m8tEESboqz4/UX5PGt9jyiJTCrv7s35PGwz jspg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si4595526edx.188.2020.11.27.01.42.59; Fri, 27 Nov 2020 01:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728911AbgK0Jkz (ORCPT + 99 others); Fri, 27 Nov 2020 04:40:55 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:54760 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728865AbgK0Jky (ORCPT ); Fri, 27 Nov 2020 04:40:54 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0AR9PN7S032714; Fri, 27 Nov 2020 04:40:51 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 34y08varpm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Nov 2020 04:40:51 -0500 Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 0AR9eorh046023 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Fri, 27 Nov 2020 04:40:50 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Fri, 27 Nov 2020 04:40:48 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Fri, 27 Nov 2020 04:40:48 -0500 Received: from saturn.ad.analog.com ([10.48.65.109]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 0AR9ej6n019064; Fri, 27 Nov 2020 04:40:47 -0500 From: Alexandru Ardelean To: , CC: , , Alexandru Ardelean Subject: [PATCH 2/2] iio: adc: ad7298: check regulator for null in ad7298_get_ref_voltage() Date: Fri, 27 Nov 2020 11:40:38 +0200 Message-ID: <20201127094038.91714-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201127094038.91714-1-alexandru.ardelean@analog.com> References: <20201127094038.91714-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-27_05:2020-11-26,2020-11-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 adultscore=0 mlxlogscore=983 clxscore=1015 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011270058 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'st->ext_ref' & 'st->reg' are both non-zero/non-null at the same time, so logically the code isn't broken. But it is more correct to check that 'st->reg' is non-null, since we make sure that the regulator is NULL (in probe) in case one isn't defined. Cc: Colin Ian King Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7298.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index ecdb01bd5b2f..689ecd5dd563 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -214,7 +214,7 @@ static int ad7298_get_ref_voltage(struct ad7298_state *st) { int vref; - if (st->ext_ref) { + if (st->reg) { vref = regulator_get_voltage(st->reg); if (vref < 0) return vref; -- 2.27.0