From patchwork Sun Feb 11 17:42:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 199493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2032928dyd; Sun, 11 Feb 2024 09:45:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXgqzu55n5Xk2+C13Rd44cHgmtWrUZ93dW8an5F2kBzSfvAIt+fTcQ1TtA3n2OGRnAj7a6 X-Received: by 2002:a05:6a21:3489:b0:19e:b6c6:8f15 with SMTP id yo9-20020a056a21348900b0019eb6c68f15mr7220025pzb.25.1707673501984; Sun, 11 Feb 2024 09:45:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673501; cv=pass; d=google.com; s=arc-20160816; b=aRU0sz0WYkT8mnSM2rYsj/ngDWlMECobrrT62nYaJupBoHlvSPgXl7elB8+Wf8Ofah DMasqr6U34lkoPonxf8qnUbnSOY5BVCHrIQ53Ue3IhM4YTFq9aaz6yWyeBiWWZHw1aT8 +y4vgxye9uqjdb1L1UkyVMMCXFQ2CLgV2sLCxvblv0IOBlWl/3Sev0VLMcw/MCOCIB4d uSHYU7BKkv+hjnCU+WuuFm/06lcesl3ZeivooK+3X8cUVu6iBFwyx3/6G/3mRkmbIUV/ DlnALeiNQGFNQOBYF3ou7E40YHUYuvCdgAaAMCviH1BhKsEuiwSFSrQgtERsrAz5sbRy owsQ== 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 :date:subject:cc:to:from:dkim-signature; bh=t9/DrgjTOa891oxA8pdeZr5UKfA4224wTmrSkwOcfj4=; fh=zfcXrm7l5pzvUMT1ioHMh+MilsiUhACIFHa1fvMMho4=; b=k7+45cfp1YfyjfiabcebRVdcYgkphitOcS3SH531Yze+JkCL944/88H2Sxb83Xoxbk r3KPbceSNurJJG3lDSmnBljg9kfl3AObEMzhJ+PrzarOF9xZIFSatZT6Q2WvJxcrOId0 BOhDFafX+DFdNiY2pv10HkP1YceASLbrGn+sqQn3e8Sk9R+f2NMsfvB46hnrqllq/nTa bh0fD7+IKfTTdwRXt+tze5zlcgHKe5nvlZCv+FbnYFh+ZlpfI1Bc0cfTu1l6pSdaZmU2 yQJ5VkdD6EW9KjG347HXGrbKklj37tc2Ip1Keb8wNlIUbGUN+SKDBhzb271KsT1IlHGx EVnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ej3YfNCT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60891-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXTU23XWYlDCW4+wXGgKSWI/MWZVMfXd+G4QZc9HYsbLo7OCyPCC6BpOwPb+LTVqPt7u5TJO0Xko5Y6DkwaL+P+rUDjRw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id cj12-20020a056a00298c00b006e0a46b72a2si3040280pfb.148.2024.02.11.09.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:45:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60891-ouuuleilei=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=Ej3YfNCT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60891-ouuuleilei=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 BE2D428102B for ; Sun, 11 Feb 2024 17:45:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 551D55F460; Sun, 11 Feb 2024 17:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ej3YfNCT" 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 8CB745D488; Sun, 11 Feb 2024 17:43:34 +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=1707673414; cv=none; b=SIj5UzeUr7bkHNpmAaDTQGzA+tUdislDUjslGTlUo8y/nrNS40tFFLI7F+oXviWthNLGhpOFY1VlH9wy0af9YiTU5TroNGWv4F/44nyuuz+SUBZh1ynjN3YSIHe1Fb9tWC/bNcZM8y6+1fIKDDcZuFNWm/Af4uwT9wEbQHNOo70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673414; c=relaxed/simple; bh=7bhniuqSD2L2Qes7Q2zW21qyQGYtas6Yezol52kECBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S9VNiNKu6zG+XmalyDu5ryBwx/ex6WzdAeKC9q0U6I/G6h20IiKTF2Z+Vj5NxOueX2RsFG8yImOeUfv6hU3QpWvxNHUDSM5ZviGfw/KIBEgnml2rIM/ueCn7U1srejEtEXk6ROxPgST9lZIrQ8ZXI+EoZQbIZ+RyvkVwBHcJds8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ej3YfNCT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA7FC433C7; Sun, 11 Feb 2024 17:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707673414; bh=7bhniuqSD2L2Qes7Q2zW21qyQGYtas6Yezol52kECBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ej3YfNCTsrNyhgyrJSjWQfqpVOb/sXA8AliwEeRJTObFTGZIAdWK9nKPRZQmXOJa3 DcxZAKQY9ko4IgGCn2UFYDhXFGFvtobi05jy1z6QkrNV9bnQxphA/ZGJIraBQiq2wH 1AwHxdFnY21L3kJe2z5KTRf/zRlUfqLt8kdOqV6W5E+WuQCTfmBfxgIJrZ1jKRK63f c+mrIOjOYxrUM54NqkSBgLil+IbqaVKKXlggGGLzYx9UVP8iEW0mfz5euTGRk9Ld/l moxJVf1KPZ2k4GQCsuxgTt56fvfiJahSpwsu3BSvQn+FNMCMLbKGQqi+W0Y4NO+78u Cst08PfMKSOHQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Nicolas Palix , Sumera Priyadarsini , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron Subject: [PATCH 6/8] iio: adc: ad7124: Use for_each_available_child_of_node_scoped() Date: Sun, 11 Feb 2024 17:42:34 +0000 Message-ID: <20240211174237.182947-7-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211174237.182947-1-jic23@kernel.org> References: <20240211174237.182947-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790625449919492455 X-GMAIL-MSGID: 1790625449919492455 From: Jonathan Cameron Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7124.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index b9b206fcd748..67ccdad752c5 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -813,7 +813,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, struct ad7124_state *st = iio_priv(indio_dev); struct ad7124_channel_config *cfg; struct ad7124_channel *channels; - struct device_node *child; struct iio_chan_spec *chan; unsigned int ain[2], channel = 0, tmp; int ret; @@ -838,24 +837,21 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, indio_dev->num_channels = st->num_channels; st->channels = channels; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { cfg = &st->channels[channel].cfg; ret = of_property_read_u32(child, "reg", &channel); if (ret) - goto err; + return ret; - if (channel >= indio_dev->num_channels) { - dev_err(indio_dev->dev.parent, - "Channel index >= number of channels\n"); - ret = -EINVAL; - goto err; - } + if (channel >= indio_dev->num_channels) + return dev_err_probe(indio_dev->dev.parent, -EINVAL, + "Channel index >= number of channels\n"); ret = of_property_read_u32_array(child, "diff-channels", ain, 2); if (ret) - goto err; + return ret; st->channels[channel].nr = channel; st->channels[channel].ain = AD7124_CHANNEL_AINP(ain[0]) | @@ -880,10 +876,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, } return 0; -err: - of_node_put(child); - - return ret; } static int ad7124_setup(struct ad7124_state *st)