Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp362649lqh; Sat, 4 May 2024 04:38:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsgPRpSTvXSk8d62Zjc7cEFCkQzcQw3a98xSj8omh37iCZD5sysSvAzzaISl/rnFT7iepApcdk4WdzCxzYAgGMko/xvwZmMKnJLa2MSg== X-Google-Smtp-Source: AGHT+IHzEthwFWKsXsdCI0PaGThlnWA7XrLtDKZxVnDQOkgpSCVxvWwjA1w4S3eRqJVSqlhvFUrg X-Received: by 2002:a17:907:7d94:b0:a59:5693:d709 with SMTP id oz20-20020a1709077d9400b00a595693d709mr7778388ejc.30.1714822730565; Sat, 04 May 2024 04:38:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714822730; cv=pass; d=google.com; s=arc-20160816; b=AbUXFPfPJrZskbmWYBzErd2q3W97qhLoDu4GFZ6Bq5Do+G9y2FOjZ0vdCy1oKXVA+5 cP0bSbUwIAN9F7jiLFdQfKcv63VnTXFNhBf+ktvqnPhRhiTO1756MFgCW9GnmrfOkNFL QkeUaSQH1Wl4z5go/n0OQQRpv1Ww42COsMahSx77cf0WB1WOP26/KzlfspIhnkPuWh6A h3/WV2Aa/E6tPN2qTDxlrhttcYSsdn7X8AyHWTbAPN3jCNYCPNVlDGylL7WnbVrwPJ2Z Jz9mc+fyqnROnZ2SvKedZo49hi1PMFyrByUvC+ZTHn1YcUgikr4RlTxNdY0RzYWxhkGb 1ByA== 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=sxVvsBwcIvvMjSyXKkDQDX9D6ZSjPcyYgtscpYvj2q4=; fh=ApYjKaDYRAe6RYXiLQaow0ZP8M4kVUXlKaCVBn8N1PE=; b=KNY4gNT5X5cDlO08Z4KJBJJSiCLC75WFy2PL89N9OSsbXAietfQXv2sw4mtqVuGIFk h/33bGCvLV+elxuNL0/UuqF7N7Ww2clARqoNtPntnZNNdNlmI/vtdu/1qjMI9Zzs7mPT MZ0LRD/NIbzDre8vVx5bWViAPgpEXjMvC1WWAC5ZG3XCUmX/DOZ+/nzWC68BRCD4wqmR 6gbWoTniVzTETgudhmEAZM9PhI2HYGRg4cBenBogiRUPIncr3Y2MqLOlgxU1xvprNKDx aakIWR8AOz4puiyQYnDExLbbVFOMHFtMKYt9tskjoHXr1FRb70otbEuzknhs8C5Xg3sM bK8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JM2JSS4g; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168610-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 nc33-20020a1709071c2100b00a5976d46417si1314700ejc.871.2024.05.04.04.38.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 04:38:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168610-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=JM2JSS4g; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168610-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168610-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 4CCDC1F21F9C for ; Sat, 4 May 2024 11:38:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 037AD1CAA6; Sat, 4 May 2024 11:38:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JM2JSS4g" 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 1FAC61C69E; Sat, 4 May 2024 11:38:35 +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=1714822716; cv=none; b=KtVB655sJxwBInme1k6EBN7NAn2eQF2BTv8b0RlzS9xOP4l/1rqWAn2I3Z0JyJ4X198gLg9mkYDr9CsjT9U5f1d65XpOlmEQq17DxqBAS8bvyVL3eQkNCA3UwFmoQTTkxyS4PSO6/WDh/E4KenO8hASmhSCuZ/ss5Hr++LuwlGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714822716; c=relaxed/simple; bh=gvDIBLSUbzVrRNJpbCt/aVyrFjWfo6ElSSBarhcm6v4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hyZH9xa4OjwQKTXZGCpTOrwnPdvIwgTMxqJklfU2R8BE2QeLjsAVwYxKjUkLmyFg9C1pFEejyS+lEcRf1hkBlJmumtZUNr0hVQk+upJ7FKo1QC310/YELTaAVSeBj0EqdeXQXnc5wmoROXlG8URYTP4jwK/0ivjvxcp/5mK9aw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JM2JSS4g; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9055CC2BBFC; Sat, 4 May 2024 11:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714822715; bh=gvDIBLSUbzVrRNJpbCt/aVyrFjWfo6ElSSBarhcm6v4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JM2JSS4gN9GwcKnlltlTCF3Fe0zhp2iwY2U7kMntuh3tIpjhfex4Xyh5Y1/Uh0Bn/ Un8EZsqpjsZ+CDNLrf/NdDHtt/gf6/UFI+vA+4iLW+6ZjIuiE7nxK0wqZsHUw23NMn HxtRxbXT4qKak++yuyJ2x1HBt3b63S9yePN1KopIDAHHwvw99VFXq6QuBZTNhstP30 jqW/Hwb0JKfMYS5l4Q6YJeH9lQz0wKG4k4VuwK00kVbjxeF+Cojn/9kzLw43YlFD8s J+l7ucAsWo5ujGGUr/irGqlje6eGcJNUZIslj2rjZinub8xk5JpnFt4GuAgBnTg8rW 6WeINCs8+Ko7A== Date: Sat, 4 May 2024 12:38:24 +0100 From: Jonathan Cameron To: Jorge Harrisonn Cc: lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, laisnuto@usp.br Subject: Re: [PATCH 2/2] iio: adc: ad7923: using claim_direct_scoped for code simplification Message-ID: <20240504123824.3cbf28c5@jic23-huawei> In-Reply-To: <20240501215724.26655-3-jorge.harrisonn@usp.br> References: <20240501215724.26655-1-jorge.harrisonn@usp.br> <20240501215724.26655-3-jorge.harrisonn@usp.br> 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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 1 May 2024 18:57:24 -0300 Jorge Harrisonn wrote: > Using iio_device_claim_direct_scoped instead of calling `iio_device > _claim_direct_modeand later callingiio_device_release_direct_mode` > > This should make code cleaner and error handling easier > > Co-authored-by: Lais Nuto > Signed-off-by: Lais Nuto > Signed-off-by: Jorge Harrisonn Hi Jorge, Lais, Comments inline. > --- > drivers/iio/adc/ad7923.c | 30 ++++++++++++++---------------- > 1 file changed, 14 insertions(+), 16 deletions(-) > > diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c > index 9d6bf6d0927a..a646521b2ef3 100644 > --- a/drivers/iio/adc/ad7923.c > +++ b/drivers/iio/adc/ad7923.c > @@ -260,22 +260,20 @@ static int ad7923_read_raw(struct iio_dev *indio_dev, > > switch (m) { > case IIO_CHAN_INFO_RAW: > - ret = iio_device_claim_direct_mode(indio_dev); > - if (ret) > - return ret; > - ret = ad7923_scan_direct(st, chan->address); > - iio_device_release_direct_mode(indio_dev); > - > - if (ret < 0) > - return ret; > - > - if (chan->address == EXTRACT(ret, 12, 4)) > - *val = EXTRACT(ret, chan->scan_type.shift, > - chan->scan_type.realbits); > - else > - return -EIO; > - > - return IIO_VAL_INT; > + iio_device_claim_direct_scoped(return -EBUSY, indio_dev) { Lots of stray white space + why this indent for the line above? > + ret = ad7923_scan_direct(st, chan->address); > + No blank line here as the check should be clearly associated with the line above. > + if (ret < 0) > + return ret; > + > + if (chan->address == EXTRACT(ret, 12, 4)) > + *val = EXTRACT(ret, 0, 12); > + else > + return -EIO; Flip this logic if (chan->address != EXTRACT(ret, 12, 4)) return -EIO; *val = EXTRACT(ret, 0, 12); However, better to also change the cases where the masks is fixed at compile time to use the standard FIELD_GET() and provide appropriate mask defines. That change would be a separate patch, so up to you whether you want to do that as an addition for v2. > + > + return IIO_VAL_INT; > + } > + unreachable(); > case IIO_CHAN_INFO_SCALE: > ret = ad7923_get_range(st); > if (ret < 0)