From patchwork Sat Feb 24 12:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13570402 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 9B0B518021 for ; Sat, 24 Feb 2024 12:33:09 +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=1708777989; cv=none; b=q3mIj7mEf55LRZy72cur+4egd0WcdcDveeG90XUziimmIdA6kDSKOPRJSXLMhRg0UG+/GqHoE/rXzCZah+dqtIYQ5tIUAT3ISNyAS78t+jNS+92ubJi7JIjIw3fpMU7rwTxovwnlRUZ+Bjl1jvM9ASnJX+R7bFS55mOp8KKCmCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708777989; c=relaxed/simple; bh=7C5/bV8FIlY7Lha11lXdJR+AQbt/4ZZdKI46DPQNgkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kaVKO9jmMx8zKXGUJTTyGeem28GHp46P1JJVcC+83NCMhO2VMN6ZMeRR0HWdGjniRUJ2nSanUxrIjsZiI6KyuBQ9fvGIaV7T09us5QlUdJvnZoiVZ+8CryLzuXzn3+jPCki+f99xn1Yl0efAw3sMXmH5Wgubamb0LKgjofzpOHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CEANi+lA; 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="CEANi+lA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C752AC43390; Sat, 24 Feb 2024 12:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708777989; bh=7C5/bV8FIlY7Lha11lXdJR+AQbt/4ZZdKI46DPQNgkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CEANi+lA0hb7+hlW43PdA+a72NL5oT2MmA/PMZQKO9RYvWO/w6LroR2JlUPf80zoY q6a3nlKEJLsX46CfhfpYVWtdvN/3I9ydATL/qw3xX5ITkK+z3VDPodnTbh60Ms9PfP zYPwD9nAW+mN0jJ+5H8UEwvN9mcfUHpQKGXn/5OgOPHKmbMTTiUGZfKZdG0+NdB7SA UOxDijPBrt3fLDmMBoshZnQdWxYq7kC7sjz8U+5eGcsyfm1wYgRaIICMbj4eFEKIfE 3R3h9E5uWb7cllPfSR1MpdpPrjL/8f+6UaCox8IrGOQoo9dEGnEbLrbdOnCVX1Nq1a ViBDB0mDduQbg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Cosmin Tanislav , Mihail Chindris , Rasmus Villemoes , Tomislav Denis , Marek Vasut , Olivier Moysan , Fabrice Gasnier , Lad Prabhakar , Dmitry Baryshkov , Marijn Suijten , Marius Cristea , Ibrahim Tilki , Jonathan Cameron Subject: [PATCH v5 7/9] iio: adc: ti-ads131e08: Use device_for_each_child_node_scoped() Date: Sat, 24 Feb 2024 12:32:13 +0000 Message-ID: <20240224123215.161469-8-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240224123215.161469-1-jic23@kernel.org> References: <20240224123215.161469-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)