From patchwork Mon Jan 1 17:26:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 759232 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 AEC298F57; Mon, 1 Jan 2024 17:27:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MChxfWoX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AAFEC433C7; Mon, 1 Jan 2024 17:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704130055; bh=77tTrrVfmsUBTrWwC6V0+Xdf77c6pc7aTaAov6cMClg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MChxfWoX0C8mViGHXRHOuDGrUiwsmWLGjjasCiu6lQY5EDXSIRjvawkqB+Pg+ViWg L0YBPNdLk+3tuq0ArC/L1bqMtOe/4fKk6uSZqQhFdrNR2UaXzZWwpuOl/2eyrElICu l2bgpJIP2aTDDhBZzg2GwLv5EETGQIIIY8IebMjO2C+eFnL1Uh921ZjGix2zEskWS+ rd89/36KziskVS8/gAcl2Pg+ZE0aUGIpU1pcswvXrIYxzWZCoixibVpnJY+KWrk6cj Zqi9g079prUTwi7qGR0gZ0M9aYwqodp3rIVAF0Aqx6UqjWZRnAqUjPMLT6s8q1nn+3 AmveDCg4jG3zQ== 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 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 , Jonathan Cameron Subject: [RFC PATCH 09/13] iio: addac: ad74413r: Use __free(fwnode_handle) to replace fwnode_handle_put() calls Date: Mon, 1 Jan 2024 17:26:07 +0000 Message-ID: <20240101172611.694830-10-jic23@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101172611.694830-1-jic23@kernel.org> References: <20240101172611.694830-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This use of the new cleanup.h scope based freeing infrastructure allows us to exit directly from error conditions within the fwnode_for_each_available_child_node(dev, child) loop. On normal exit from that loop no fwnode_handle reference will be held and the child pointer will be NULL thus making the automatically run fwnode_handle_put() a noop. Signed-off-by: Jonathan Cameron Cc: Rasmus Villemoes --- drivers/iio/addac/ad74413r.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c index 7af3e4b8fe3b..ec9a466e118d 100644 --- a/drivers/iio/addac/ad74413r.c +++ b/drivers/iio/addac/ad74413r.c @@ -1255,21 +1255,16 @@ static int ad74413r_parse_channel_config(struct iio_dev *indio_dev, static int ad74413r_parse_channel_configs(struct iio_dev *indio_dev) { struct ad74413r_state *st = iio_priv(indio_dev); - struct fwnode_handle *channel_node = NULL; + struct fwnode_handle *channel_node __free(fwnode_handle) = NULL; int ret; fwnode_for_each_available_child_node(dev_fwnode(st->dev), channel_node) { ret = ad74413r_parse_channel_config(indio_dev, channel_node); if (ret) - goto put_channel_node; + return ret; } return 0; - -put_channel_node: - fwnode_handle_put(channel_node); - - return ret; } static int ad74413r_setup_channels(struct iio_dev *indio_dev)