From patchwork Sun Feb 11 19:25:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13552582 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 81E1733CD2; Sun, 11 Feb 2024 19:27:27 +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=1707679647; cv=none; b=txuQRDKQVjnyng0BGHX0aW2+CQxhqaykVUmvkx+rqmmQlqyctxhQNvpGTNXpWMvmaD1kTzsGN3v/nxwNZzEzd5mRHxmqVDLuppkMFejNa1Z1LanSi5zcYn3D6hDhaeB4tKq6BOR+jR3pRwlsur1V59Tcp5eUOX2t80OnwJpJqd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707679647; c=relaxed/simple; bh=k4Sbe42YicpnKE/blrFSxYSkJ4X6IsERAAaxczqUlwo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RxxOUpmfb6uLN+u8dZKcqJ0eicwZDJqJLDKoBlQsB8DpFuTN3AeKlRnpp5nPuXeZgqtlggbr6ced1aTmQERbK/Y0RjF29bZPQ6kEwrYBuIJroMKOMowgO0T4PPV2eDStVwPDino8Za/qTUPQU15lduq+0dd4GWRLCmU4R2/Hai0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oxN+30P8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oxN+30P8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D6FBC43601; Sun, 11 Feb 2024 19:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707679647; bh=k4Sbe42YicpnKE/blrFSxYSkJ4X6IsERAAaxczqUlwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oxN+30P8yLZ7A1k8VcKgYKl5l8KVTi7BjXeVjfpv99gK0pPcsHJ54RYTJ7s6dfLJ7 I7JMKtXDgntKb0tEdkCd3WYk8HvD4WgDIstnWxCOFk0GOlPG8Yi0A/0YzOTrueXtw6 GnCE/Hr4vVYgb3m/v9ZGF4j9O4PhqFVc0bXXPiSpUsschNwhQnIzq6W3baPlbBN3iV 3Me4e0mq+UMbdgOx+Fp2LjbkNzVdnPSmH8OfF2+H6Zy3VO1DFOIRMuQweoe6rfFSyf mh24BDr0Nl5rSwoD2YgTFD2q9DvGGJceaBg90gDBZzvpHdn3G8WRIWdpLO2i2q7QyM Tx7qOre/RhkBQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , Daniel Scally , Heikki Krogerus , Sakari Ailus , Julia Lawall Cc: =?utf-8?q?Nuno_S=C3=A1?= , Cosmin Tanislav , Mihail Chindris , Rasmus Villemoes , Tomislav Denis , Marek Vasut , Olivier Moysan , Fabrice Gasnier , Lad Prabhakar , Dmitry Baryshkov , Marijn Suijten , Marius Cristea , Ibrahim Tilki , Peter Zijlstra , Jonathan Cameron Subject: [PATCH v2 10/14] iio: adc: ti-ads131e08: Use device_for_each_child_node_scoped() Date: Sun, 11 Feb 2024 19:25:36 +0000 Message-ID: <20240211192540.340682-11-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211192540.340682-1-jic23@kernel.org> References: <20240211192540.340682-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Switching to the _scoped() version removes the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. In this case that's all in error paths. Cc: Tomislav Denis Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads131e08.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c index fcfc46254313..f653654f7c5d 100644 --- a/drivers/iio/adc/ti-ads131e08.c +++ b/drivers/iio/adc/ti-ads131e08.c @@ -694,7 +694,6 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev) struct ads131e08_channel_config *channel_config; struct device *dev = &st->spi->dev; struct iio_chan_spec *channels; - struct fwnode_handle *node; unsigned int channel, tmp; int num_channels, i, ret; @@ -736,10 +735,10 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev) return -ENOMEM; i = 0; - device_for_each_child_node(dev, node) { + device_for_each_child_node_scoped(dev, node) { ret = fwnode_property_read_u32(node, "reg", &channel); if (ret) - goto err_child_out; + return ret; ret = fwnode_property_read_u32(node, "ti,gain", &tmp); if (ret) { @@ -747,7 +746,7 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev) } else { ret = ads131e08_pga_gain_to_field_value(st, tmp); if (ret < 0) - goto err_child_out; + return ret; channel_config[i].pga_gain = tmp; } @@ -758,7 +757,7 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev) } else { ret = ads131e08_validate_channel_mux(st, tmp); if (ret) - goto err_child_out; + return ret; channel_config[i].mux = tmp; } @@ -784,10 +783,6 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev) st->channel_config = channel_config; return 0; - -err_child_out: - fwnode_handle_put(node); - return ret; } static void ads131e08_regulator_disable(void *data)