linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	 Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	 Hans de Goede <hdegoede@redhat.com>,
	Chen-Yu Tsai <wens@csie.org>,
	 Jernej Skrabec <jernej.skrabec@gmail.com>,
	 Samuel Holland <samuel@sholland.org>,
	 Florian Fainelli <florian.fainelli@broadcom.com>,
	 Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,  linux-sunxi@lists.linux.dev,
	linux-rpi-kernel@lists.infradead.org,
	 Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH 04/10] Input: twl6040-vibra - use cleanup facility for device_node
Date: Thu, 10 Oct 2024 23:25:54 +0200	[thread overview]
Message-ID: <20241010-input_automate_of_node_put-v1-4-ebc62138fbf8@gmail.com> (raw)
In-Reply-To: <20241010-input_automate_of_node_put-v1-0-ebc62138fbf8@gmail.com>

Use the '__free(device_node)' macro to simplify the code and error
handling. This makes the error handling more robust by ensuring that the
device node is always freed.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/input/misc/twl6040-vibra.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 78f0b63e5c20..afed9af65bf9 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -229,14 +229,13 @@ static DEFINE_SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops,
 static int twl6040_vibra_probe(struct platform_device *pdev)
 {
 	struct device *twl6040_core_dev = pdev->dev.parent;
-	struct device_node *twl6040_core_node;
 	struct vibra_info *info;
 	int vddvibl_uV = 0;
 	int vddvibr_uV = 0;
 	int error;
 
-	twl6040_core_node = of_get_child_by_name(twl6040_core_dev->of_node,
-						 "vibra");
+	struct device_node *twl6040_core_node __free(device_node) =
+		of_get_child_by_name(twl6040_core_dev->of_node, "vibra");
 	if (!twl6040_core_node) {
 		dev_err(&pdev->dev, "parent of node is missing?\n");
 		return -EINVAL;
@@ -244,7 +243,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info) {
-		of_node_put(twl6040_core_node);
 		dev_err(&pdev->dev, "couldn't allocate memory\n");
 		return -ENOMEM;
 	}
@@ -264,8 +262,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev)
 	of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", &vddvibl_uV);
 	of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", &vddvibr_uV);
 
-	of_node_put(twl6040_core_node);
-
 	if ((!info->vibldrv_res && !info->viblmotor_res) ||
 	    (!info->vibrdrv_res && !info->vibrmotor_res)) {
 		dev_err(info->dev, "invalid vibra driver/motor resistance\n");

-- 
2.43.0


  parent reply	other threads:[~2024-10-10 21:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 21:25 [PATCH 00/10] input: automate of_node_put() calls for device_node Javier Carrasco
2024-10-10 21:25 ` [PATCH 01/10] Input: cap11xx - switch to for_each_child_of_node_scoped Javier Carrasco
2024-10-20  3:59   ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 02/10] Input: mtk-pmic-keys " Javier Carrasco
2024-10-20  4:00   ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 03/10] Input: sun4i-lradc-keys " Javier Carrasco
2024-10-11 10:36   ` Andre Przywara
2024-10-20  4:02   ` Dmitry Torokhov
2024-10-10 21:25 ` Javier Carrasco [this message]
2024-10-20  4:09   ` [PATCH 04/10] Input: twl6040-vibra - use cleanup facility for device_node Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 05/10] Input: twl4030-vibra " Javier Carrasco
2024-10-20  4:09   ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 06/10] Input: sparcspkr " Javier Carrasco
2024-10-10 21:43   ` Al Viro
2024-10-10 22:01     ` Javier Carrasco
2024-10-10 22:09       ` Javier Carrasco
2024-10-10 22:22         ` Al Viro
2024-10-10 22:28           ` Javier Carrasco
2024-10-10 21:25 ` [PATCH 07/10] Input: 88pm860x " Javier Carrasco
2024-10-20  4:19   ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 08/10] Input: i8042 " Javier Carrasco
2024-10-20  4:19   ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 09/10] Input: raspberrypi-ts " Javier Carrasco
2024-10-20  4:20   ` Dmitry Torokhov
2024-10-10 21:26 ` [PATCH 10/10] Input: ts4800-ts " Javier Carrasco
2024-10-20  4:20   ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241010-input_automate_of_node_put-v1-4-ebc62138fbf8@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hdegoede@redhat.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=matthias.bgg@gmail.com \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).