Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp841334rbb; Sun, 25 Feb 2024 06:28:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/Hmk8ssUvm5Nkt77R2PjfnPcLsIadkJ7mJDH3ItAQ4GSNDUA2G6eFNT82atxKg8B3FFTwQdsOI/2iJeXQ6IBiIQSebDp+6O0P6qwPLg== X-Google-Smtp-Source: AGHT+IFGB3Q/btfokcpvAzckeGBUHGrM32dp8bceKnLyygg5vJFE5cfeZLZP/6LGplKQZ6mdxQiI X-Received: by 2002:a17:906:260d:b0:a3e:d2ea:ff5e with SMTP id h13-20020a170906260d00b00a3ed2eaff5emr3439571ejc.58.1708871331034; Sun, 25 Feb 2024 06:28:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708871331; cv=pass; d=google.com; s=arc-20160816; b=rPMFItXZTovhV4xVxcf7NIWei4WOG8XNwJSVyuy8fjsSh2j/IDKE/I6DASmBcGY9aR lX9xQ+qOXlQ8H9dfd5bnG1G0LrvCREUwNxmHiqxpp4bF+1hjRqRtBbVFDw+HYPSq+R2w BFBXUuWdQ63clpB0nAAIGXQQ80TMK/ZW+NnUHaWQaDT7H/M6viMEUGYFwOp+4R+9+foq 861VLBH3ERA8gHKSVajYJlBRq0HQ60gl6jer6ykqd6H2YXPmiyrZWs565JwQwiSLDB4Q ejkoR3+n8a/55DyWkXxOhLB3Np/9sNNzh9EQ7vRsukfDO6jD6dWebQ8M2KKUl/+nBkwd gpkQ== 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=yrG5adLrW+jnciAACbwy0oBs7XJnJ9GbNUbU8vn5lD8=; fh=PiZ5V/4sGLDov5cF6A5wY5iqIfZAXRefEy8l5uZe2FU=; b=h9aJs0s5CHmCc+tyc0e2ZSwm+LRDoh5AHyhbBpwkJdRuBq6lBVIZoBXxyZQFKTwgJf wDiqGzL7XAKbEoLnvcybuOZzX1AGguHJjdGxQxDtZ7bipA7PLszkPwxjtZJaecHIbR0v U1i6WRUNzeckJiBNV6i6cGycqTrIokHPIeMAQAe2PifqG4B713U9Ie+xXRhB9qvtm9h/ rnmz1VeuiUhua7Q8G96CXVB17pTV0llOk9MtEy5zpwM/xxnqEyp0oqGnbyBTI0Y/mo1/ iTvVPLFbilC+rVUjvMO1xlF2ZZrk9yQxDvPvNTjxPusy5fBAqfLSzUGNVdQugEF6DoOj mvFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=re8r5oJN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80101-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 h13-20020a1709063c0d00b00a3f851fc3f3si1273194ejg.504.2024.02.25.06.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 06:28:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80101-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=re8r5oJN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80101-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 9FEFE1F2152D for ; Sun, 25 Feb 2024 14:28:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B73E317732; Sun, 25 Feb 2024 14:27:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="re8r5oJN" 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 D3F28175BC; Sun, 25 Feb 2024 14:27:50 +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=1708871270; cv=none; b=V/wvoRqQFmDx5AObb9c4qyzNQRqfO8R21AgaOr/u47+sYOtoZuX0Ab6cz8uhU++7nLImGzVMzUVC9LXEhOh1TQ6Whv3nRIbriyw4nG2OXdyaU9vJNRTy+wZVSukzQNm/8P9jtg0651Xj2BxIPUNFrlzbbeJM5f78ty9QVteWhWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871270; c=relaxed/simple; bh=FqXiRDMNp8tTGWD6g9YkejKEc8q+OEjl8zHNs3d6IoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t+Znc4WrOrXb+TpUt4VmTXVoPwRTivwW5hJo9iFzd2QeaPn7QEFgGVnLvu9PCXqHEyyYHtP3fGXtzQ9+Bwzjki8J69v+XJ1zI9WQZn7Mt64+/SdRHKKL7XtOY2yUoUHHyA6kCgDlZFs58VJ0cxkn4BUBmTCIA5meTSCYf5hTTwU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=re8r5oJN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FF42C433F1; Sun, 25 Feb 2024 14:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708871270; bh=FqXiRDMNp8tTGWD6g9YkejKEc8q+OEjl8zHNs3d6IoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=re8r5oJNr4bsZl9Uw7G61ebplfEtdtt99hYivWytcHnU04kO99xj0WMHxrr6reaFv nmDN0hWSpVR3FW+1A3imLl4aL7lI9OdFIWZPtsPVQnqcZj7eELmv7RbgONjjUeKeW8 oHNIA7iaFJErWJHuRbNk36FTkOw2KSA3ROxaY9dpMXjtfzs1v6HkU9BCdMt/cCLIXH vcr2/C3NipA+0mWwJDzi83LhQl6qrR5e8vZ5Yh5fuJkbnOILEAdiqAY3ZdfTgeJveu Bxgz2JkCa10NJrvF+vbUUh7WMNj+5n5mSBvLe4OBmWMmdTuDefB8qyQT9MOYpY57mv eRdrY2HvYL8cw== From: Jonathan Cameron To: devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Andy Shevchenko , Greg Kroah-Hartman , marek.vasut@gmail.com, Jonathan Cameron Subject: [RESEND PATCH v2 4/4] iio: adc: rcar-gyroadc: use for_each_available_child_node_scoped() Date: Sun, 25 Feb 2024 14:27:14 +0000 Message-ID: <20240225142714.286440-5-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240225142714.286440-1-jic23@kernel.org> References: <20240225142714.286440-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) -- 2.44.0