From patchwork Sat Mar 30 18:53:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13611657 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 6DD613D0D2 for ; Sat, 30 Mar 2024 18:54:03 +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=1711824843; cv=none; b=izErZUV7dM0jNxR/lXBbcYkhpLiCc9yeU9M0kZzfWplKuYoyNwgKVgek/Pm3wQ8OZQdyCaHzldeSQgVlaiejmWIdlQTU5mgPSR3M4raPlCztRq0qc0TXEUfRsZtEJMdUJgsGsDz002rcFXR1lRTQxrnxBiUWS9VYb+qML6E5XSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711824843; c=relaxed/simple; bh=bG+TeFde3DyITfgrg0EFAq3aPgezHodRADkhJV7nv3c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VezzQaEci+2VXHgl2JG5KwmTIGfgW+NPLrD+UTPGtGbcp5kq94l2uKPDi6C1wWtmHplBeMEh/KZc2rzVRHT19QlZl+LhsvaWsfm60Hf8MSWOr2CwYtQLd1DrOEJhvbx7c8YsNdqZgrWkCGrHFDdsnspTUMmq3kTgvsAQ+/XMx2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dea63eox; 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="Dea63eox" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93C62C433F1; Sat, 30 Mar 2024 18:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711824843; bh=bG+TeFde3DyITfgrg0EFAq3aPgezHodRADkhJV7nv3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dea63eoxYo5tNDPyNC0FXIEzYu0ETvTcYUQLfIt4XtAhTqB4+fZ2/Rozkr3baquyO 9XOHkOEYuC2v6dULvKQWuKAN7w5ipLRZsyg1Kmgn8hyPt0GSf9VHj5nuuzDkqX0BUW CHmbh23DqqyLPSYWDVumYPER3u2YDLUbzkW+gDO/l8I+Wofei6Mswh7P4MvReO69ZJ +TSqYbbnxJ0MgTJwG1+Q9UAEAVOI7xaAUttEsdg7+4k1tfHayLpBbIHV3amn/MQKhn Dx0KNecQHpOEAAw3AQPOwDQdoeMPdH0+pjujnEODfqekcGuZpkclRKW6IZU+vK7Eyd EGdsEkJbuXbQA== 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 v6 8/8] iio: dac: ad5770r: Use device_for_each_child_node_scoped() Date: Sat, 30 Mar 2024 18:53:05 +0000 Message-ID: <20240330185305.1319844-9-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240330185305.1319844-1-jic23@kernel.org> References: <20240330185305.1319844-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: Nuno Sá Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sa --- drivers/iio/dac/ad5770r.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/iio/dac/ad5770r.c b/drivers/iio/dac/ad5770r.c index f66d67402e43..c360ebf5297a 100644 --- a/drivers/iio/dac/ad5770r.c +++ b/drivers/iio/dac/ad5770r.c @@ -515,39 +515,32 @@ static int ad5770r_channel_config(struct ad5770r_state *st) { int ret, tmp[2], min, max; unsigned int num; - struct fwnode_handle *child; num = device_get_child_node_count(&st->spi->dev); if (num != AD5770R_MAX_CHANNELS) return -EINVAL; - device_for_each_child_node(&st->spi->dev, child) { + device_for_each_child_node_scoped(&st->spi->dev, child) { ret = fwnode_property_read_u32(child, "reg", &num); if (ret) - goto err_child_out; - if (num >= AD5770R_MAX_CHANNELS) { - ret = -EINVAL; - goto err_child_out; - } + return ret; + if (num >= AD5770R_MAX_CHANNELS) + return -EINVAL; ret = fwnode_property_read_u32_array(child, "adi,range-microamp", tmp, 2); if (ret) - goto err_child_out; + return ret; min = tmp[0] / 1000; max = tmp[1] / 1000; ret = ad5770r_store_output_range(st, min, max, num); if (ret) - goto err_child_out; + return ret; } return 0; - -err_child_out: - fwnode_handle_put(child); - return ret; } static int ad5770r_init(struct ad5770r_state *st)