Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp146975lqj; Sat, 1 Jun 2024 11:40:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjLQ7JUHjSJN1cHWptNMVrBA+mJg50rJSmdbbczBhEwJctQZCrxfy7pML4iGDnTav/rmFflbIpy1CNjZ5eBXFFdhMFYf+X23XfBSJgOA== X-Google-Smtp-Source: AGHT+IHq/3Gwe0nSm72uo6CdJCOnBCOfDvYaiTAHPnlzAM0/85Z+6M5JiZBhayxvSTf9i/KcWuK8 X-Received: by 2002:a2e:818c:0:b0:2ea:8163:5f4f with SMTP id 38308e7fff4ca-2ea951ddf8emr49904321fa.41.1717267253171; Sat, 01 Jun 2024 11:40:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717267253; cv=pass; d=google.com; s=arc-20160816; b=snUPAZS5OOIPgeEOASOrf+tg+dVIRHfCP8wpjYkRnoeFFwy4ax/oRtiknmP2h2it5Y 7leYRONGMGvn3skwNC9ZnBy4A5mzX6hsdspJStn8xo/HZyGGfdjdMLfe4qI8xKeJgC6C Uc/tsubiE6DP3lcA0QDP+6JKOYNUhU+lTvCLMXjr20E3zaOV7CCAV7c+tBG8K+ZXbjb3 CjZOtx/6EF4RZSZKR6Glngmqnfz45B7oUtkPELx4fONVYVxNTq0I82V+w7UQKDnKQbnY wc3PaJVnHiksWqtvliryrNBEPQngPnq4M5g+AxrVSGtpoj++KTvHschIU9kKS1bodYce zogA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=q3IsRVlvtrcz4S3ltOjmB61KarhyYw2jhnqlhGyrqHo=; fh=Is8fFfeY4AnFDYwJYJg1j+TzU6mYZNIeyhTuLgmCIgE=; b=ycpQxA+5v2RTQli4GmBHpiho/knUCH+UpFWF3lPyzYK2X7SzQ7BblNHrUTIfBhDEES E7xhRxwKEa0WjYlRufA6KgKkP3ZoQCDZesLObeGs/pskVFMYbpD6RHoh8DnWJ1wB4NyE rJLUD/DOjjPqOUiUvleAAnaQ1yxlEvNtvzWeW8Nnr/wkejBRFVWOCyqernWImnX+jzk8 NKMnwye0KC246d8u3s4E+Drv1cdO/hYT3aizUpNkyn71wn1GnUF+jjg+CNmLr7ExD5MJ h+wcmMNcblOgaYjO0oJhUZEs2ulA1WxlADmTRaBSC+c0pbOSS0ikxkyr0stqOtXcZ+g3 rteQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ATN9Qb1Q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197982-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e6f0297csi233083666b.144.2024.06.01.11.40.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Jun 2024 11:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ATN9Qb1Q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197982-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D094E1F219D4 for ; Sat, 1 Jun 2024 18:40:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2369E154C0A; Sat, 1 Jun 2024 18:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ATN9Qb1Q" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40040208D4; Sat, 1 Jun 2024 18:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717267243; cv=none; b=lpz4RvXWOoH/Wt7yJ535EbaqNIJOWcZJl0IJcPegLCiYaFg0glF0gtnAJvw4O5xx6j9ET15krEbSiduTIWAGNY6Has3S6yTJAP2xcyMaTI9Fyw0HPVPZ5IBTFk+3hppoG4hE/XPV5bSOm/EBC6gmNCUeOkSC/KLGfB7VsJrXneE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717267243; c=relaxed/simple; bh=LR/c8x+xXZigA1KgG3xrmw32mIIHb4FKtgh/evN9SM4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jjqp9/c4s/ZxmRJr2kio7Nawf8idtXnWhG9Z06u5iofXcHIpqYAh8gl6CStTqCKVDF1BH/vAZLjYImNj03ahlc5fyQrT2tzdtiibKdZtHkeKNnsh5DQha0XGDs0QVzvTQ48pkL9S5EvvE8sKr6DXAxeexmVz3C4BGbeoGITGzjQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ATN9Qb1Q; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4473C116B1; Sat, 1 Jun 2024 18:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717267242; bh=LR/c8x+xXZigA1KgG3xrmw32mIIHb4FKtgh/evN9SM4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ATN9Qb1Q/SYgGwtk3wP8kvB3/y8+DRjJA8v1hmyRJ/eLdP0QxQAB44DsMT+mu4Xzk SHv3yJCzIkg7gk1LztXMe6qxxJziJsG7ZviTNApc1uDS7cKus6+D3R/uCKE8ASoCIF 3HWi4TON/z3r08sHdJsH2uW15L2Yx4tjx7zeXsz187l4hfH4RkA0/t0oxfO2PPB3m0 VnhrkcTlCq2i2TvcWLQkiZQ/aqbnXRfAaJWrV6mnt7UioOUBNEjK8gH7US+EOoXMBu 4btudvWHnlBYOtsTs8R7ILHaXf1H0yWWY8+hNP8B1cSYF4KvuD2+Rw2VH09OgEkJet osMYhweOv4pQg== Date: Sat, 1 Jun 2024 19:40:27 +0100 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: "Ceclan, Dumitru" , dumitru.ceclan@analog.com, Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , David Lechner , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/6] iio: adc: ad7173: refactor ain and vref selection Message-ID: <20240601194027.67c97d76@jic23-huawei> In-Reply-To: <5e263d5ce90d6ad187adb7d4a007ce2e79095829.camel@gmail.com> References: <20240527-ad4111-v3-0-7e9eddbbd3eb@analog.com> <20240527-ad4111-v3-3-7e9eddbbd3eb@analog.com> <71452f6882efe6a181d477914488617d28a38e2f.camel@gmail.com> <4b704b553282c0689dfef714c49ba97a33198898.camel@gmail.com> <5e263d5ce90d6ad187adb7d4a007ce2e79095829.camel@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 31 May 2024 09:10:43 +0200 Nuno S=C3=A1 wrote: > On Thu, 2024-05-30 at 17:45 +0300, Ceclan, Dumitru wrote: > > On 29/05/2024 15:49, Nuno S=C3=A1 wrote: =20 > > > On Wed, 2024-05-29 at 14:27 +0200, Nuno S=C3=A1 wrote: =20 > > > > On Mon, 2024-05-27 at 20:02 +0300, Dumitru Ceclan via B4 Relay wrot= e: =20 > > > > > From: Dumitru Ceclan =20 > >=20 > > ... > > =20 > > > > > +static int ad7173_validate_voltage_ain_inputs(struct ad7173_stat= e *st, > > > > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int ain[2]) =20 > > >=20 > > > Pass the pointer and size of it... Also, it should be made 'const' > > > =20 > >=20 > > I'm learning here: what is the purpose of passing the size of it? > > This is a specific case where the size will always be 2 > > =20 >=20 > Basically readability... Yes, in this case it will be a stretch to assume= we'll ever > have anything bigger than 2 (so the scalability argument is not so applic= able) so I'm > ok if you don't pass the size. It's just I really dislike (as a practice)= to have > raw/magic numbers in the code. In here, it won't be that bad as by the co= ntext, one > can easily understand the meaning of 2. Nevertheless, I would, still, at = the very > least consider to either use a #define or a better name for the iterator = (anything > more meaningful than 'i' so that it looks more understandable than 'i < 2= ') >=20 I'm late to the game, but I'd just split it into two parameters. Code is shorter as well. static int ad7173_validate_voltage_ain_inputs(struct ad7173_state *st, unsigned int ain0, unsigned int ain1) { if (ain0 >=3D st->info->num_inputs || ain1 >=3D st->info->num_inputs) return dev_err_probe(&st->sd.spi->dev, -EINVAL, "Input pin number out of range for pair (%d %d).\n", ain0, ain1); return 0; } > - Nuno S=C3=A1=20 > > =20 >=20