Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1626797rdb; Sat, 10 Feb 2024 09:43:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+r/TTSqYLO8IxvhLapfzP985DHJ7dk+kuTzuGwJebiUk4sf/IrCGqjoi2iP+9/BtB17ppd5fiYLSqaugDvunDPc8AkCKzGu6G6McMmg== X-Google-Smtp-Source: AGHT+IGsJAUBSPk7VO4JlF0wxMzuZd01YvaMPaeXjElNex2rjs1YXRaXZ5ZvxcjbOhM/MWeBtI/w X-Received: by 2002:a05:6a20:c6ca:b0:19c:ae59:1602 with SMTP id gw10-20020a056a20c6ca00b0019cae591602mr3657329pzb.53.1707586980837; Sat, 10 Feb 2024 09:43:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707586980; cv=pass; d=google.com; s=arc-20160816; b=A85oBwzqr9AF7KXws0gkCimBP3LDDc6Qj6WoWTyeM3LYffDwxtZV/njuu09D66gEez e+CtI7o9wpXZbLgbVVVgiBnS1cxDBRa9tHNTp4+UjoCHNcGXfLSBDqrkH6GKdBIH+Ebh Z1J/Otx/Ilm8jOEWpGmXhmSeA7dSp/4LoAAWrqrSomYrmCJjtTxN+gnFEENYKhDeSphb hJ4uSihUuXQBwVsAFRzcNfmw9yR1hWayfpn5RhxKJ9pzaOsZBHHjs3EzguqtRHyz+6yu xsoW5FAinq8V7FW59H2vgGjNnjubt7oQBuy0GmTxy95gpfjBWYrb0SymblKAQt7muESI qYWg== 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=8wMy825YSzds8SW6y0gVuEatpC90cs+Uj6jWwEbCxs0=; fh=nIXsI+GAvvdtTsLDWCM4zG8IvGw+DaEOVmaQdRxleKY=; b=QJvMYpr7aRa8EVROtjitfVzvujIUljlzSSxYTXimEU/QwUxQ1hmzPqYB6+yj4+gNpA TSG8dcvWOucKqc87c8WHEHnJ5UX9l6BLj4hXG69Z5j2vqWlhq0cbzZVz1qH9RQPxESoP 84921XSDeKjafnvRhLsV3iUCosP+qVRixvSO14lOpdXD/QysQojBUZMESJCne6Fcrrai Db6aGqm7IzEBLxNeCDVsvYCN/tS2Zg9WTmohU2H+ra0dCsUuWhA73YX7a2RUjTfvV71r 2mL5t7tU2DWCuQSlz6EbpcaSkIBPdoGclM6nsMFK1zxyY6UkfOuZx29Au9c23gS/7ff3 iyxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rmYEOHFO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUfwNub7qwpVdtgZgkYRBAPUIzU6J+UqQ3pcWFaZV0oAEyymB9nQ2W/pnMQ+4O07HWFYHtJQqTtMYZAi9DCj7+yqYCrnZdiK41+T/2rqg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l22-20020a637016000000b005dc4190c756si3797981pgc.866.2024.02.10.09.43.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 09:43:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60501-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=@kernel.org header.s=k20201202 header.b=rmYEOHFO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60501-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60501-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 799EF28561B for ; Sat, 10 Feb 2024 17:43:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 867A65D472; Sat, 10 Feb 2024 17:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rmYEOHFO" 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 A7F06259B; Sat, 10 Feb 2024 17:42:52 +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=1707586972; cv=none; b=ZvlC/6xRH7QufIMQXYw6JV2hgADpPv98sPSfnEibAXBc9D2S+wY6XUnq07JHakT9fV0/04E/KNkOJJAr0hW6jXBOkZoaGdG73uEWsCOP5LNMZfh0zrPEZsTWi0J/ssTkJ6xaElXfzvvyPCDYMPSSXMkMl5a5JxzPrgYuAv3t3QE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707586972; c=relaxed/simple; bh=F7oZGvL/sYlmHwJCPXB6gJfnpzBuQezPqvGmSOPj4EM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YXI1m8oqFzIDPmNxXTbVwELqSaca/DZ6HI/TrORj8J3DVopLbxp227qBLHk1sfJQSP5P1Lyq9DH+lZv8EHSgcl0W8Y69UNbtaoGFYNwKEyWCgDopbDWcC8EH5kkNLE2cv65Tk1WAqeTeYQXEv2+6PW5v1+oD9tQN+xRyfBu0Yps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rmYEOHFO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4122FC433F1; Sat, 10 Feb 2024 17:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707586972; bh=F7oZGvL/sYlmHwJCPXB6gJfnpzBuQezPqvGmSOPj4EM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rmYEOHFOVRqGkeSpWH6e8VuEnRkkRmWlgWmLNEK2SCX4EgIddG/nLVlAtI+IuGiMQ LblpJtZB2uSWl00OyetkIxjziGXxIpWs6As/0QZyY2JzYIN9ev8PXGa9IMYs+c9fJh m6HPIuB72+83Q13wCT2AFxkPfqMrvypqvVCU4x8gFBHk4N/wDsPOCf8GOUHFqCoFp5 vIDBEm/tjZNgiIJ64HW1RCIE4q1knH0UYBCSAoCcORoUXEo5DK9w7kcS5o9EDsZbMs LQdffJVs+PZ0LpVteHahXZ3LcBwfIF1Oo+9dUyodHJ6UVmKxKFAEH/tOljcwWusdXf x/gCALHZpjceQ== Date: Sat, 10 Feb 2024 17:42:39 +0000 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: David Lechner , linux-iio@vger.kernel.org, Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nuno =?UTF-8?B?U8Oh?= , Liam Girdwood , Mark Brown , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] iio: adc: ad7944: add driver for AD7944/AD7985/AD7986 Message-ID: <20240210174239.550c5d64@jic23-huawei> In-Reply-To: <06a2a5618058909df52b685f461e668b259ff42a.camel@gmail.com> References: <20240206-ad7944-mainline-v1-0-bf115fa9474f@baylibre.com> <20240206-ad7944-mainline-v1-2-bf115fa9474f@baylibre.com> <5fd17b66eab1989b9cfb874445c18480a2282809.camel@gmail.com> <06a2a5618058909df52b685f461e668b259ff42a.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 > > > =20 > > > > +=C2=A0=C2=A0=C2=A0=C2=A0 if (chan->scan_type.sign =3D=3D 's') > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 *val =3D sign_extend32(*val, chan->scan_type.realbits - 1); > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0 return IIO_VAL_INT; > > > > +} > > > > + > > > > +static int ad7944_read_raw(struct iio_dev *indio_dev, > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 co= nst struct iio_chan_spec *chan, > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 in= t *val, int *val2, long info) > > > > +{ > > > > +=C2=A0=C2=A0=C2=A0=C2=A0 struct ad7944_adc *adc =3D iio_priv(indio= _dev); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0 int ret; > > > > + > > > > +=C2=A0=C2=A0=C2=A0=C2=A0 switch (info) { > > > > +=C2=A0=C2=A0=C2=A0=C2=A0 case IIO_CHAN_INFO_RAW: > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 ret =3D iio_device_claim_direct_mode(indio_dev); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 if (ret) > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret; > > > > + =20 > > >=20 > > > I'm not totally sure but I think Jonathan already merged his series f= or the > > > cleanup stuff for the claim direct mode. Maybe take a look and use it= ? Not a > > > big > > > win in here but I guess we could still reduce some LOC. =20 > >=20 > > Yes, if it is merged already, happy to make use of it here. It is in my tree, but I'd rather maintain some separation between patch sets (incase I need to pull it out again for some reason). Given the saving here is minor, we can just follow up with a patch making the conversion after both are in place. > > =20 > > > =20 > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 ret =3D ad7944_single_conversion(adc, chan, val); > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 iio_device_release_direct_mode(indio_dev);