From patchwork Mon Jan 1 17:26:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13508673 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 7FC978BEA; Mon, 1 Jan 2024 17:27:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H9P4U4Sn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B4D2C433CC; Mon, 1 Jan 2024 17:27:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704130047; bh=7/zi23CJfGpbi1J0CbGJ5wZcilJ4HNwCb9MhJ/UyG+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H9P4U4Sng4+Y9BQvauM8pjlHhKxKw3QyqRjy/qvO9Is27KJvHVZC87GUyRjy+yqP+ hM2TCKJkuXWJEmz4GUfj+LttDlind32Cm+eEUxqSckjtGrXE5tR5MF3xbG3AY0accQ 61sdh5/AzBB4U/d1ug8qYmSCiHH/U2SKBzdyG7M1TUEKk7bUnPxDI3e4aJOqhOIMc6 dTtXUCCzY69bybWzHOkD39basDEP58zbPSAQbJf84QLOetdrNB58WwInnEw4mm/ORR JtxJR3sYSZdRSntXKCG4dWnC/2OhPN7k8ZijzrjicYQedI0fefXiwcWF4ClnWf6P+4 nm8NnbJzsboeg== 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 08/13] iio: adc: ti-ads131e08: Use __free(fwnode_handle) to replace fwnode_handle_put() calls Date: Mon, 1 Jan 2024 17:26:06 +0000 Message-ID: <20240101172611.694830-9-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 device_for_each_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: Tomislav Denis --- drivers/iio/adc/ti-ads131e08.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c index fcfc46254313..fb1ab0b9a9db 100644 --- a/drivers/iio/adc/ti-ads131e08.c +++ b/drivers/iio/adc/ti-ads131e08.c @@ -694,7 +694,7 @@ 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; + struct fwnode_handle *node __free(fwnode_handle) = NULL; unsigned int channel, tmp; int num_channels, i, ret; @@ -739,7 +739,7 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev) device_for_each_child_node(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 +747,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 +758,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 +784,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)