From patchwork Sun Feb 11 19:25:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 772064 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 F32BF5D498; Sun, 11 Feb 2024 19:27:20 +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=1707679641; cv=none; b=NVTVbx7DrkUk8c+PHGwl1NqNlhyjOswmBfBrm0B8o82OLeu58ZAMvNqoZehywQZxzQyer92OPYde9fQSsdU9nOtwM3AECQUJKl1HeDgI2tb8ODoS8SXVYSAHExI+mmUO9EoOkrB/hd2VT5Xz96yyJsDvv4NyGDywj9S024RFui4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707679641; c=relaxed/simple; bh=DC6dz+YHtXRBeaRwOAmhjAqY7WW7vUz9C+A/xNQEKws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DL7f6hVjcp3b07HyhRgrV/XAQ3rE4hoYLdSvyg5QzmcFgbMvRGy2kACo52yjwCWyC78heKPZaQVdB9B1a68l5ob15Z4t0n4UMgAQN2EqFucJOKbeQLaJPLwcp4ndxeB83Vx0dNhjHvxW47IM14iAmvywXGLQzhlHhbBJk6xRVeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ryvhOpxn; 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="ryvhOpxn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 542EBC433F1; Sun, 11 Feb 2024 19:27:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707679640; bh=DC6dz+YHtXRBeaRwOAmhjAqY7WW7vUz9C+A/xNQEKws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ryvhOpxnI68NUH317PvMqW/x4yJMbjKNot+pkiYBAyoWy42FnDiLbTa6rG/37srhH SWjj1AJDmMyEd3Q/bkkhf2ecS6TQ/a/RxxiZ0ZOUfyxtnES17YfX2DO5ZlYyzymVtV cnHJqdUX0GSJ8Bo5JmYWfnQTtbF81szSUQFcz9OQK//wmdJxv1TZc9bj51PTiAgHlB X8eb/9S/zCcbWzJjxZZ//gXoctsSGsIJPwdhHJBnGrnymYIEfJrYigXkawWenb53xL PJb81Q9RKb5Sr/TV02ZD/PgH6IWF5CqXj5KRAexbjQfsD2+mg+j+Wb9hSeMh4MxrIN OjiIR69Yiznkw== 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 , Julia Lawall 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 , Peter Zijlstra , Jonathan Cameron Subject: [PATCH v2 09/14] iio: adc: ti-ads1015: Use device_for_each_child_node_scoped() Date: Sun, 11 Feb 2024 19:25:35 +0000 Message-ID: <20240211192540.340682-10-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211192540.340682-1-jic23@kernel.org> References: <20240211192540.340682-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 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: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads1015.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 6ae967e4d8fa..d3363d02f292 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -902,10 +902,9 @@ 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; int i = -1; - device_for_each_child_node(dev, node) { + device_for_each_child_node_scoped(dev, node) { u32 pval; unsigned int channel; unsigned int pga = ADS1015_DEFAULT_PGA; @@ -927,7 +926,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 +934,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; } }