From patchwork Sun Feb 11 17:42:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 199495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2033415dyd; Sun, 11 Feb 2024 09:46:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUc92FrUB0sd4OqGp1U/gk2qqLNoxIq5rAnrFAL7nnjFb/9TI8B7FJRXNzb2VWCQjBocuh5C0Ik7UruQoMWdIyntCS7pw== X-Google-Smtp-Source: AGHT+IGhGf24R5Eo07WX3JFHa+JRo1ztWxHtkc8HU7dz7WerRSn89H3MVqB6NyGHcyMqAbSnkEOX X-Received: by 2002:a17:902:b589:b0:1da:1daa:e2bd with SMTP id a9-20020a170902b58900b001da1daae2bdmr4942856pls.19.1707673584141; Sun, 11 Feb 2024 09:46:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673584; cv=pass; d=google.com; s=arc-20160816; b=zgj0LDCnnxoqf1D/KO59uX++eNchT1WGMZAy9vutqW7ffas2BxFvgxFfW6Hy79HMNs lG0yycmSNbwSRLNiKviqxM3EAC50EushF4I7Ea3NPcKmEdTxzdR2vieeIDRP/LkkqqGf BCj8uJfvljkV33/w38odTiqSEhZXFB3UI2x3i3IRHUjbK1hfgXqhNgla70cQCDaBWcYa uN9jZ95BpDtCzshJLUgBv6hxFSeF8SmqYvvDT51ISDl8FErB8bChBm7a/7XYP/sAk31k vQuG599yYjTrIKk0wY8y++8ZpnbRCGtAW4pRssK2Ac1KsoPfKUCGwI8PBLMAcHWALqKG gXDA== 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=oZnbVRUfZe8hqk9BCac8OmWV6jnzfnVNPXTHm7C304I=; fh=ATIzgBMCAVrcGwBXArv9v3/8NvNJkiZuRVh3k1HPhHk=; b=yB50WHKj9mpdt8UxisAkQsU1bi4PhPlwKAeHTMoKJF0c9YYyVqD5nLI1RV0YQUKt+w JJrZyQmGxqusIS0CXtM0t70c3EKpvyvgAG5ZzDy0VukoYehrIeaIiBurql737MyQ2rEK lUrVt7lj/3myWzNB7fIeJTfgnO8OERR5PctW62cFWSXGv6cbTGwyapgOn8+HMLZ4yXV6 zLSYSOvEqN+CN2TL/bOj0BFInn8/4orXbnjfkXd6zt+/gFPSmW0zyY7qt4zLP89qMTO1 F79/nv2/jaXHEcsKMYgYrLg1OyJFa8Y0Zi4394CJbgCD1jN6kbTkPnXdnZYnXGwjYqbI gNwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N6JB8Lsa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60890-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWGY7I4gdrwMjZKvwCKRl/m5jEzAnp11CbQFCqiqZ3WJ6P3fPu6jU6a9cVzhtzsl46hXL6zGb/mBOBi/F3htvJjytAxNg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id mb3-20020a170903098300b001da2c896119si908964plb.432.2024.02.11.09.46.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:46:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N6JB8Lsa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60890-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60890-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6A22EB222D7 for ; Sun, 11 Feb 2024 17:44:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7079A5EE6D; Sun, 11 Feb 2024 17:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N6JB8Lsa" 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 AADBA5E3AF; Sun, 11 Feb 2024 17:43:29 +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=1707673409; cv=none; b=D3nnasuC+7pHxiFfZmf+koHs8tUYVQACQ8mGQ5GIhigd3NZd4aXe/DpKoino/RM8xVoFkrkRzqGtBao5W74Xy8d7yJWrvOZH2p/tvwrWIIlhiovxf04wODIxDTYowt/OToWwiJr6NlN8gK5Xd5Sjw3hDnd3ZxYqabunZ8RYylbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673409; c=relaxed/simple; bh=wN0leKygyGGEcV5J2AcNqnFx2iI5WbKZIEWRuroojKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CA2uF1PEWCWU1F0HTju6smASHYyLz5DUpjGywLefCeHLFkVmtUVqyCtKw8dH1/0GsdzIducJeLnhfgB7yfpHaRHZdnVwujQ9aMFZF/RWNtLpTc4L9u/tniEo1vNCweKw+oh6TkbGk81xIFmFESL2FoJT5WLwAsd2sr9/PIj2Fb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N6JB8Lsa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 837F5C433C7; Sun, 11 Feb 2024 17:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707673409; bh=wN0leKygyGGEcV5J2AcNqnFx2iI5WbKZIEWRuroojKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N6JB8LsaAUSXkJFJHZG1xyAfSxLIAYPo3qlV+tAxOQ1UZqKIHDPIIuHqGNzTvvmnH OgCYG5YsIZA8Lfw/5Zr64SQ8BEKEpstcrDKq3UnVw7HcS277MVjWb4zlLz+rxzyZE8 +aZM73JONaqjIh4l0RJLdgxbXVDwAncyLnB0SuDzK0bBTT3ID3Lo8zd99XKSetxhA7 IMRN7QWZIPLfnvnSLuAKyAo3Aw6+GH02HgWtlvGlp1tAUzOg1gX8j8jt3Ml0LkAAri 9wARM5lHXoDB3YEfeiOktQL4Lw/YAKfGep8jo4EP4HP+Nc6i6m1zvgs5OgZMRsN5J/ B/ezXcEPZrstQ== 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 5/8] iio: adc: rcar-gyroadc: use for_each_available_child_node_scoped() Date: Sun, 11 Feb 2024 17:42:33 +0000 Message-ID: <20240211174237.182947-6-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: 1790625536617329864 X-GMAIL-MSGID: 1790625536617329864 From: Jonathan Cameron Using automated cleanup to replace of_node_put() handling allows for a simplfied flow by enabling direct returns on errors. Non available child nodes should never have been considered; that is ones where status != okay and was defined. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rcar-gyroadc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index d524f2e8e927..15a21d2860e7 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -318,7 +318,6 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) struct rcar_gyroadc *priv = iio_priv(indio_dev); struct device *dev = priv->dev; struct device_node *np = dev->of_node; - struct device_node *child; struct regulator *vref; unsigned int reg; unsigned int adcmode = -1, childmode; @@ -326,7 +325,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) unsigned int num_channels; int ret, first = 1; - for_each_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { of_id = of_match_node(rcar_gyroadc_child_match, child); if (!of_id) { dev_err(dev, "Ignoring unsupported ADC \"%pOFn\".", @@ -352,7 +351,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3); break; default: - goto err_e_inval; + return -EINVAL; } /* @@ -369,7 +368,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) dev_err(dev, "Failed to get child reg property of ADC \"%pOFn\".\n", child); - goto err_of_node_put; + return ret; } /* Channel number is too high. */ @@ -377,7 +376,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) dev_err(dev, "Only %i channels supported with %pOFn, but reg = <%i>.\n", num_channels, child, reg); - goto err_e_inval; + return -EINVAL; } } @@ -386,7 +385,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) dev_err(dev, "Channel %i uses different ADC mode than the rest.\n", reg); - goto err_e_inval; + return -EINVAL; } /* Channel is valid, grab the regulator. */ @@ -396,8 +395,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) if (IS_ERR(vref)) { dev_dbg(dev, "Channel %i 'vref' supply not connected.\n", reg); - ret = PTR_ERR(vref); - goto err_of_node_put; + return PTR_ERR(vref); } priv->vref[reg] = vref; @@ -422,7 +420,6 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) * we can stop parsing here. */ if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) { - of_node_put(child); break; } } @@ -433,12 +430,6 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) } return 0; - -err_e_inval: - ret = -EINVAL; -err_of_node_put: - of_node_put(child); - return ret; } static void rcar_gyroadc_deinit_supplies(struct iio_dev *indio_dev)