Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp948288lqj; Mon, 3 Jun 2024 06:05:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhApEDOstfWY/6In+Iiqrr3NCjUc3jujk+F6TFsHTA9i0G6Qx48PFUEA32kCR/5fGtJ4Je+tXB9vxAHKsnpqis+o/d74wqq3YdP5d1mw== X-Google-Smtp-Source: AGHT+IHdbAoFoihJzyYlFJ5C2XsehYw8mCFqjdTWNlu4ZQrcUH4WVcB/naT71zD8wOqeGzvphu87 X-Received: by 2002:a05:6a20:9184:b0:1a3:b642:5fc3 with SMTP id adf61e73a8af0-1b26f253adamr12061254637.41.1717419927224; Mon, 03 Jun 2024 06:05:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717419927; cv=pass; d=google.com; s=arc-20160816; b=pypaZVwA6doQo2XqApm5O4sDIh+nA0k8MWFNItnUoH3qzljs0rzc/ZiCrMFbiwU5Rh aW+RrfL8keVdk7+YmbZlR9Gc6ML/BT8oNqJWWkrGr1q76iEM4C0t5hYy0XG53xCGjsaW otM0nm5/L8xbULF1DU4nl/zehMBu7DZP1kNTkEh8Hf8KK59f6glOu2FrU7TfFWZ9LfMI DLVbjbCuJwKl0ucx1puT5ax/o5uXt/z3LQethqqFDMEWQkoAOKfRYWWQVUOJORPCMrHk 9D5IGQFnlAlyb0/YFpK7BkcChy0wn07/ssWwXGpQA1uZHobzZ0fqsmGDzzcuIl2NXOmK 3xgQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=IIyV9sL6Yz42R1gBXDzy0b0ZnJFQDq+9KiMNnkN2uWM=; fh=SNQOGcZ05cGCSx62CcCakC2Eu2AiynfZzAx8VPhTqVU=; b=jkIT3/uheu2pmTA+JVg3rdD/idgcyU+8nFP4NNnSesYsH1c+8oESBKmHw6efgJAN7t Yr/3tUNOcUK6T0p8wjSAY5Re1DZC2uTk22RqI1VwTxmXc1BE5zuxzJa42FeattddAU/+ CJxEfcehFHy3Wv2iXD+Sh5IN33LxMkjeNULWu09ARuF2pzCnMlE2E491kOXFe15FRIro p/vJCwj5R8xR+sO3W3pZnffjyRrzoytVAVaH77o1tA3iS/OpiB4uJwvRlolJjCwR+CeR JZd4nYMT418CD2CREcfeKBUiEpA6wC9HuNhUP77oxvYg07FWlmio1J3uCOEOeek/+3oN PPyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FYI6bKqL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-199160-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35c181cd4si6496518a12.698.2024.06.03.06.05.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:05:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199160-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FYI6bKqL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-199160-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 125DF28656B for ; Mon, 3 Jun 2024 13:01:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 508B11EEE0; Mon, 3 Jun 2024 13:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FYI6bKqL" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D68DC12D766; Mon, 3 Jun 2024 13:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419627; cv=none; b=ic1U5ZJl2XQO6JkxIUkpJ+MK6TIe9WhSgo3WceMoneDnYeV+pOx64A/X6uJPdoaAI1Uc2ulIDQHxZ5y3+X71Y2XNvnLF/pIGmwHIEX9Tg+SNjrqhuesrBj3ztFIUMbxOxG6AgcDfpt8tCJHpFkPQpiDbDFZAslN1E7yxuqVTOw0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419627; c=relaxed/simple; bh=EFDXzbET0oDEK5hJ72ljh6kZ1Ef9iy+G5uzyhrhtjCE=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=gDNvXCws1vqOMZDyxLHoRvNuJwvD4FPnalRFXt7yyEs220IW+cIIyF0CtMB8kOkYM+qI2djPrv9e8G5kpk9xbvbv94SB6Ou2/5kiqvp2eIzURYf9SW3Iv72hY+7q1zoaoz+GQFZgJgIQE7x4SQSeQkl6mwRCgO5ZnGiocssOwDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FYI6bKqL; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a68e7538cfaso188090766b.0; Mon, 03 Jun 2024 06:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717419623; x=1718024423; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=IIyV9sL6Yz42R1gBXDzy0b0ZnJFQDq+9KiMNnkN2uWM=; b=FYI6bKqLm0UW6/ooemUwVyDWttMNoKQYdMYq3SL+xXy6cURlsZF2fw2jUA1YVeEKgn hAnlYes2iMznRSB5d5l4JVTBeAp1f8vGtVPEUopN8oQt8I7pH3fzLZ5FX3lvXKWvYgaF lfhEAttEfog0dBwoclHMJ2mDNLYB1QlZTWO8rDGMbgfbfILoVFk6jHshwCRh0e2E1Cp6 rXpnkISq5VUn/eKRQTRkSSBbeM3DDVkd2ofooX56N54JBT0eTtxeptiWRdq4SGH0tTdx 3MdcWmj3SYyV6CPY2QiD454O1UjjUdi88kAyBE7nAvXWcuwfjKfM+WTDo1KB4BiIWFwN nv5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717419623; x=1718024423; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=IIyV9sL6Yz42R1gBXDzy0b0ZnJFQDq+9KiMNnkN2uWM=; b=K299TehGzdwHjcevsIpZ/cW4lWvfC+a4NBqNahcHiC5f4oI03kSiniCU2i5Jr4ok7g u6t5oYmpPifnPim3otkkgJb9H9Kxqx7Qe3SMpvOSL3h0GKNJDCd6V3zKDsssDnsCOfD3 9ph64C0/+VyaXo7/CwaoOxLCLAc20UdC7DI3ftB0NOyq48GaYjR3Hcj1PkiS+bjnOIHv h48DoQMAYlJU6PAtI9XySZxK7YrvSEiORuVc3xuTJe1T7VXbS/PgCyNX7sGo19oSN8OY HKUteVrFSDlb7sscOYOaQPTWrWFqgbayrzfSnfbTsT2/5mBvOhk76O1al1h6YAKozsAV nxZg== X-Forwarded-Encrypted: i=1; AJvYcCV/veD7xx7NWT/ZSpDaTpjt3NSn3KDYWuAGhPdN1aOgBf4NFj2sRzlSfIwkylvsdUM3kzMyQ3c4e6VOhXuS9OR0l4HD1ZRYRngzFlSWFLNqBB6ojizWeskmJk6/bJ1HbLntLswZQHC/suGJ9WrN5dJdH+9+kMII3iib/PJ4804EltUwQA== X-Gm-Message-State: AOJu0YwPBMuC4Vz2b87LohazEapPp/6fg1RUfj8Mi/f8yamiERkZ14VF E5PQGUYCOrTBotz5L1tL+JbSV/VL9DLQKIn/u5Ef6Opg+m3AGuovCJ+6FZMR X-Received: by 2002:a17:906:37d2:b0:a68:c14d:2686 with SMTP id a640c23a62f3a-a68c14d26ccmr375812666b.25.1717419622938; Mon, 03 Jun 2024 06:00:22 -0700 (PDT) Received: from ?IPv6:2001:a61:35f9:9001:40df:88bb:5090:7ab6? ([2001:a61:35f9:9001:40df:88bb:5090:7ab6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab85e8dsm479749266b.164.2024.06.03.06.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:00:22 -0700 (PDT) Message-ID: Subject: Re: [PATCH v4 3/6] iio: adc: ad7173: refactor ain and vref selection From: Nuno =?ISO-8859-1?Q?S=E1?= To: Jonathan Cameron , Dumitru Ceclan via B4 Relay Cc: 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, Dumitru Ceclan Date: Mon, 03 Jun 2024 15:00:21 +0200 In-Reply-To: <20240601194925.23123071@jic23-huawei> References: <20240531-ad4111-v4-0-64607301c057@analog.com> <20240531-ad4111-v4-3-64607301c057@analog.com> <20240601194925.23123071@jic23-huawei> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.1 (3.52.1-1.fc40) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Sat, 2024-06-01 at 19:49 +0100, Jonathan Cameron wrote: > On Fri, 31 May 2024 22:42:29 +0300 > Dumitru Ceclan via B4 Relay wrote: >=20 > > From: Dumitru Ceclan > >=20 > > Move validation of analog inputs and reference voltage selection to > > separate functions to reduce the size of the channel config parsing > > function and improve readability. > > Add defines for the number of analog inputs in a channel. > >=20 > > Reviewed-by: David Lechner > > Signed-off-by: Dumitru Ceclan > > --- > > =C2=A0drivers/iio/adc/ad7173.c | 71 ++++++++++++++++++++++++++++++++++-= ------------- > > =C2=A01 file changed, 50 insertions(+), 21 deletions(-) > >=20 > > diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c > > index 6e249628bc64..a20831d99aa5 100644 > > --- a/drivers/iio/adc/ad7173.c > > +++ b/drivers/iio/adc/ad7173.c > > @@ -60,6 +60,7 @@ > > =C2=A0#define AD7173_CH_SETUP_AINPOS_MASK GENMASK(9, 5) > > =C2=A0#define AD7173_CH_SETUP_AINNEG_MASK GENMASK(4, 0) > > =C2=A0 > > +#define AD7173_NO_AINS_PER_CHANNEL 2 > > =C2=A0#define AD7173_CH_ADDRESS(pos, neg) \ > > =C2=A0 (FIELD_PREP(AD7173_CH_SETUP_AINPOS_MASK, pos) | \ > > =C2=A0 FIELD_PREP(AD7173_CH_SETUP_AINNEG_MASK, neg)) > > @@ -623,6 +624,7 @@ static int ad7173_setup(struct iio_dev *indio_dev) > > =C2=A0static unsigned int ad7173_get_ref_voltage_milli(struct ad7173_st= ate *st, > > =C2=A0 u8 reference_select) > > =C2=A0{ > > + struct device *dev =3D &st->sd.spi->dev; > > =C2=A0 int vref; > > =C2=A0 > > =C2=A0 switch (reference_select) { > > @@ -646,9 +648,11 @@ static unsigned int ad7173_get_ref_voltage_milli(s= truct > > ad7173_state *st, > > =C2=A0 return -EINVAL; > > =C2=A0 } > > =C2=A0 > > - if (vref < 0) > > + if (vref < 0) { > > + dev_err(dev, "Cannot use reference %u. Error:%d\n", > > + reference_select, vref); > > =C2=A0 return vref; > > - > > + } > > =C2=A0 return vref / (MICRO / MILLI); > > =C2=A0} > > =C2=A0 > > @@ -905,13 +909,50 @@ static int ad7173_register_clk_provider(struct ii= o_dev > > *indio_dev) > > =C2=A0 =C2=A0=C2=A0 &st->int_clk_hw); > > =C2=A0} > > =C2=A0 > > +static int ad7173_validate_voltage_ain_inputs(struct ad7173_state *st, > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const unsigned int > > ain[AD7173_NO_AINS_PER_CHANNEL]) > I was late to the game in replying to previous thread. >=20 > This is neater without the loop and with 2 parameters.=C2=A0 Anyhow see r= eply to v3. >=20 Yeps, even more given that we're passing/copying the complete array which a= lways fells awkward to me :) - Nuno S=C3=A1