From patchwork Sun Jan 14 17:20:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13519187 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 6C0B26AA6; Sun, 14 Jan 2024 17:21:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gGMaHnMj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AF2AC433C7; Sun, 14 Jan 2024 17:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705252871; bh=vdePzhBx0RGC98TujogxrD1IJhQR1sBrDbStR0jyBPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGMaHnMjUaFpU/4rJVDTzW7mdIp3CJgfzuIwr9lF+S4eDkxEChhPhEWp4+wpU8zSX bRAMPYxpTKwbOgBDUHbEIPM/u9AL4THrV66q7FNs5w5L6lgq0svj2w42iVdjQhGzeU TVbqmW+2muJx5Ppm2terDJTwDV/xIsptdrD73dz5pOSDIHct5uVyYtwA7H0CrtljE0 g7Vf1ze+R/V2EfaOi44BYyv+ZBM1w0uujY7dLJbXt14CVyZie1LVBwla15AX85W9Po pq5NB2Kw83VfYCEpKQ/haxkp82Lv/QzuzrCC0tXXom8gtmCYBlj2zOYdr5T28CInFs 9q2/UBWoNEsng== 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 07/13] iio: adc: ti-ads1015: Use __free(fwnode_handle) to replace fwnode_handle_put() calls Date: Sun, 14 Jan 2024 17:20:03 +0000 Message-ID: <20240114172009.179893-8-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: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads1015.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 6ae967e4d8fa..b3a8a5b2c013 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -902,7 +902,7 @@ static int ads1015_client_get_channels_config(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ads1015_data *data = iio_priv(indio_dev); struct device *dev = &client->dev; - struct fwnode_handle *node; + struct fwnode_handle *node __free(fwnode_handle) = NULL; int i = -1; device_for_each_child_node(dev, node) { @@ -927,7 +927,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client) pga = pval; if (pga > 5) { dev_err(dev, "invalid gain on %pfw\n", node); - fwnode_handle_put(node); return -EINVAL; } } @@ -936,7 +935,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client) data_rate = pval; if (data_rate > 7) { dev_err(dev, "invalid data_rate on %pfw\n", node); - fwnode_handle_put(node); return -EINVAL; } }