From patchwork Sun Jan 14 17:20:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13519185 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 B4CB37472; Sun, 14 Jan 2024 17:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pe5lJGA0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3AA8C43390; Sun, 14 Jan 2024 17:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705252861; bh=Sjp6tSD+gYOla0bsf2bUAXw2BNF3WegJcnJrNI68Sg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pe5lJGA0MHsCaVe75xHnkhiLtubd5honP+i3wFwGF5qmRgJ9PwzX38+/fxbABZSwr leGpIy1gllWDdq6wWZZsuGdCTmCrpKCUF+OeIkFr5jwrz8n9nrLRzjKENg9QULJHHE BQ/nWSGxfCMO5lCnqciZFJeQbQfsHtkftbcvosCgrAfez3jMDcdu4yCwdPhS0L2vN8 Ls1Dmta+QLf9cauOAdOceiJBsj7YKKf6fEi1UNjlXISZt6sab26vgoZuxUAt/uwrqP SbNN5F+kKQfsm2LftrumjdO0RK462uf+eln1QBGxciv361Zqi6YnuwmwZHW+KRCAEI m+pnz+hl6g+QA== 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: [PATCH 05/13] iio: adc: rzg2l_adc: Use __free(fwnode_handle) to replace fwnode_handle_put() calls Date: Sun, 14 Jan 2024 17:20:01 +0000 Message-ID: <20240114172009.179893-6-jic23@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240114172009.179893-1-jic23@kernel.org> References: <20240114172009.179893-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 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. Cc: Lad Prabhakar Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rzg2l_adc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 0921ff2d9b3a..08af54824f25 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -302,7 +302,7 @@ static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id) static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l_adc *adc) { struct iio_chan_spec *chan_array; - struct fwnode_handle *fwnode; + struct fwnode_handle *fwnode __free(fwnode_handle) = NULL; struct rzg2l_adc_data *data; unsigned int channel; int num_channels; @@ -332,15 +332,11 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l i = 0; device_for_each_child_node(&pdev->dev, fwnode) { ret = fwnode_property_read_u32(fwnode, "reg", &channel); - if (ret) { - fwnode_handle_put(fwnode); + if (ret) return ret; - } - if (channel >= RZG2L_ADC_MAX_CHANNELS) { - fwnode_handle_put(fwnode); + if (channel >= RZG2L_ADC_MAX_CHANNELS) return -EINVAL; - } chan_array[i].type = IIO_VOLTAGE; chan_array[i].indexed = 1;