Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp190369lqb; Thu, 14 Mar 2024 08:41:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBsgWRFZ0158yfSuRyxIVok6vQ9Eu0fGaMgiqxrlugmZ8V8jDQfLf3eTF+smPIZGszNjnKa4CeJ8OlnbJbTHm59uB2DLPDSiEk62pFnw== X-Google-Smtp-Source: AGHT+IFgmQ2QurgljwlW+rmMx0mm4CRHMTdJrXDGaU4uipEqpTsnNJe3uDpT8jgnmWWDSYluUWvC X-Received: by 2002:a17:902:ecc9:b0:1de:ddc6:2781 with SMTP id a9-20020a170902ecc900b001deddc62781mr1261902plh.5.1710430917868; Thu, 14 Mar 2024 08:41:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710430917; cv=pass; d=google.com; s=arc-20160816; b=DwwtnJtJ6dY2Sglb0B+C8jcDmDELyHRyuIOBwe5Kq9hlcijJYAAyKqWAW2U8zyyUoz DMh5dZWYzCg4S29SiN6Wm0QqzaF03IwWFGb68LXyRsjR7VhG01c+5Hb+TBFZ/N6gabeo gE24x8nmgvvqDNTQvo0eOjhkuqrAM8UTObYLZDIUVjmWCizjt6Z5evSaI7ehvt1z0csU ND3xboXdcVNKQyexu8DC0e6/jRO4Kh2O/NCHl06+CHimJfC5Orzld1WManN8Q6np8fOp DHHphsato/8NEY+p0zsH/nyTOyrs8+7q6Ai5R3hfwbqUKeWdm9zA6pgyOfgQm46qEXUp fIQA== 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=1Oc68pyfbnp2Xaal57dU7rz/JYkU0XpE3d33SAcnwjg=; fh=Iu/6sD8gnBc8YN0N/0YqfRxY7k25r8GCIsERqlW28qc=; b=BfLcmUGdzvKkhoC6WuDuVAtmK9+ak9C4U88ZCyA84IwVZ7l1FxhsR/GlTzgs4j0NSX LSqOXqK/SvGIAMKx/maHbIgYE5QTJPp+y6YdWC0EFzlHL+NOENps1hvrcXBD3JPFgg6m sHoKtW8wGzk/4Y047aynEooY2UQcWYAZzDNwxfRv/svBYwEoX73TPlM6KtR9fbFcH9Bj Mp7uT/PCj0S0WhhbgukKpkIcXdDbThjLU/corcYp+qifW/glXU0S8bVNaxDmfLduiM5H J5ACS6HW0wzO1cQ+YrNdseKzOyAbJzPXpbJIsTlxy/zHOxldMxkU6tC+GFk+zawz96x9 srkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d4lUgtH2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103522-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n6-20020a170902d2c600b001dedfba7897si920830plc.97.2024.03.14.08.41.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 08:41:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d4lUgtH2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103522-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8951D284D11 for ; Thu, 14 Mar 2024 15:41:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5891371B52; Thu, 14 Mar 2024 15:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d4lUgtH2" 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 813B371723; Thu, 14 Mar 2024 15:41:51 +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=1710430911; cv=none; b=UBPW0sDAAnmWTzT1NB96vn12qQBCv/9waCjFLUc312MNSGa1UrpocPpq8q4cZoiSUBnKff3NMpSpqZFsewAeP+7LA3Hvh/qBeiQU5YdUiiBi2aisYMHV8SvfTa1Gcja3dJXT01Pea3jMSdSm4APp/CAXUDYAukCHxO/1AFqrUIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710430911; c=relaxed/simple; bh=eUVCx3NdID6p/BA28jS+KfLIL/YiKtdyVU65SQqdyP4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=raenhc1SNJWoptdrkgl5g7y+XuEQQ2LFgvdB97MQIdRQP4Uko5LiUArlPbjZ6t8Ak+CjlZ+3cqlI10ZWGIvDMCJrPzELmDrUiUw8DHeA4LjIMRRZs9RusyLYiJLUz+iP86bR6QDSgxA1x0dmWyzYjmak2PRU7s1d8MimIWgxIkc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d4lUgtH2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8297C433C7; Thu, 14 Mar 2024 15:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710430911; bh=eUVCx3NdID6p/BA28jS+KfLIL/YiKtdyVU65SQqdyP4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=d4lUgtH2H7p8HGTKr2Vre3wTxWY3ug1n2ud4wFKUe3aGfZNrtU1C9j+NQGQD+aYzv nINVHcmPT2/rG26sWiqBfK8BiEMiPANgjxrgDTf5yDTbdzOiaZDumQe7Kf75C/EfOp 24Qtv82XKL34t1VBC8XfCzus3dlb/NOYz4mJCHw1FhoKCOz+hM71gAMHthPEoWGZhP 9tlU8LdJf3IgFy3aoSx2XpXS8pM7Y90+LcYUd3V0RrkUJxt8XVBHYxiXOOmkFDXmCf jDHXje5Bu8/rZyeo9s24l/yD1Ss9U1QazBk6PDheDkG8O+Jht0ONwkMLOS1A1BWucs Dm7er3uFJsjpA== Date: Thu, 14 Mar 2024 15:41:37 +0000 From: Jonathan Cameron To: David Lechner Cc: Nuno =?UTF-8?B?U8Oh?= , Michael Hennerich , Nuno =?UTF-8?B?U8Oh?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: adc: ad7944: Add support for "3-wire mode" Message-ID: <20240314154137.2fdf82ba@jic23-huawei> In-Reply-To: References: <20240311-mainline-ad7944-3-wire-mode-v1-1-8e8199efa1f7@baylibre.com> <8ee551edeff9c4c959a4dbda53d1a2a26a9bb62c.camel@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; 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 Tue, 12 Mar 2024 09:13:56 -0500 David Lechner wrote: > On Tue, Mar 12, 2024 at 4:08=E2=80=AFAM Nuno S=C3=A1 wrote: > > > > On Mon, 2024-03-11 at 16:26 -0500, David Lechner wrote: =20 >=20 > ... >=20 > > > /* > > > * ad7944_4wire_mode_conversion - Perform a 4-wire mode conversion a= nd acquisition > > > * @adc: The ADC device structure > > > @@ -167,9 +246,22 @@ static int ad7944_single_conversion(struct ad794= 4_adc *adc, > > > { > > > int ret; > > > > > > - ret =3D ad7944_4wire_mode_conversion(adc, chan); > > > - if (ret) > > > - return ret; > > > + switch (adc->spi_mode) { > > > + case AD7944_SPI_MODE_DEFAULT: > > > + ret =3D ad7944_4wire_mode_conversion(adc, chan); > > > + if (ret) > > > + return ret; > > > + > > > + break; > > > + case AD7944_SPI_MODE_SINGLE: > > > + ret =3D ad7944_3wire_cs_mode_conversion(adc, chan); > > > + if (ret) > > > + return ret; > > > + > > > + break; > > > + case AD7944_SPI_MODE_CHAIN: > > > + return -EOPNOTSUPP; =20 > > > > This mode is not really supported for now and in theory we can't really= have > > adc->spi_mode =3D AD7944_SPI_MODE_CHAIN, right? So, I would just make t= his the > > 'default' branch and not care about chain mode (implementing it when ad= ding it). =20 >=20 > The compiler was happy with this, but yeah, default: is probably safer. >=20 > ... >=20 > > > + if (!adc->cnv && adc->spi_mode =3D=3D AD7944_SPI_MODE_DEFAULT) > > > + return dev_err_probe(&spi->dev, -EINVAL, "CNV GPIO is > > > required\n"); > > > + else if (adc->cnv && adc->spi_mode !=3D AD7944_SPI_MODE_DEFAULT) > > > + return dev_err_probe(&spi->dev, -EINVAL, > > > + "CNV GPIO in single and chain mode= is not > > > currently supported\n"); > > > + =20 > > > > Redundant else... =20 >=20 > yup >=20 > > =20 > > > adc->turbo =3D devm_gpiod_get_optional(dev, "turbo", GPIOD_OUT_= LOW); > > > if (IS_ERR(adc->turbo)) > > > return dev_err_probe(dev, PTR_ERR(adc->turbo), > > > @@ -369,6 +486,10 @@ static int ad7944_probe(struct spi_device *spi) > > > return dev_err_probe(dev, -EINVAL, > > > "cannot have both turbo-gpios and adi,always-tu= rbo\n"); > > > > > > + if (adc->spi_mode =3D=3D AD7944_SPI_MODE_CHAIN && adc->always_t= urbo) > > > + return dev_err_probe(dev, -EINVAL, > > > + "cannot have both chain mode and always turbo\n= "); > > > + =20 > > > > > > I'm fine in having this now but shouldn't we only have the above when w= e do support > > chain mode? A bit odd having it when we don't even allow chain mode. > > =20 >=20 > Yeah, we could wait to add this. It seemed like something easy to > overlook though if we don't add chain mode right away, so I just went > ahead and added it now. Seems reasonable - maybe just mention it in the patch description. Other than the tidying up Nuno pointed out looks good to me, so I'll pick up v2 once posted. Jonathan