From patchwork Fri May 10 07:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kousik Sanagavarapu X-Patchwork-Id: 13660971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3ED63C25B10 for ; Fri, 10 May 2024 07:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RuZe18lDciQQECyVWhfv2Rv+UIfytx8PJQDOtyCt+U8=; b=sUBfCNvUZPK28T ETS/M60yAXX6a8pU3sDdsqIufqruXYlCecmG+CG7BuUK2UE+SnDT4CEwC6yDEKFwqWhvrnHLc0XSk rfQiT6P6KMK3LGab/NdaxwZO05BBXBJOS/RX6emS+2pz5jO1k/WU+kz1r0bcmWnYSlGZwpb22U6rx 47whP2W0VAI9QYnVKJ4RCkKnr66HVkU/HTjmyNcusBORZHYYTn5kMKaoIqd5uZoWxM+MPfHB7m/bM d/T77Y1UZEfpUelWf4yjprX85A49BQiGQk1uyfpcdxP7tDx3AZ429XxGZyCyq9PwxxvihBSwp0cq7 JtmYSnX/tx7MDcx/fX4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5KT5-00000004Kt1-1A8p; Fri, 10 May 2024 07:14:59 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5KT1-00000004KrB-1hyx for linux-arm-kernel@lists.infradead.org; Fri, 10 May 2024 07:14:56 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6edc61d0ff6so1523068b3a.2 for ; Fri, 10 May 2024 00:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715325293; x=1715930093; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pKl1sJKw/UsKDzy8KNhNK1sYyMGjgorHopo+1odx4UQ=; b=O+gSei1S2Cuc0IE/laoX/Zj05RsvaTRJVYLKP1ugMMsLZlxzPWjpOVsbu1zbWLIlHt C/7WhI7HeoV6LdQTgzj8Im0pM0x2kuHI53OE1BhW+dgazUZrrkShg4dlXIgpn76I7xCO uB98CsySBmTjdAluYrXKLl5mnxZr18tPcgOOc2Q9uLoRpihVGRUtsqzvgeukjElsMmph TYPPqgHoJO6vRAo8Yi+2oJmhSVpjLTRwCjSlteTvlaFSHONCU58vNOYjCBLfBGdhx1lQ gPZsHMczBrqlgqFPDuWF+vrmBGKXDzTp+fe6hsav+Qy8DUzgYnqoF+EQwV4JZpxTO715 OmxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715325293; x=1715930093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pKl1sJKw/UsKDzy8KNhNK1sYyMGjgorHopo+1odx4UQ=; b=EiNIUP3a9MD/UyrzBoOEkIRrqk3fsGUzJy1wAqYIv/JIhKho1qYRZ2Lm5tyWLKX4ZX 6QsLEgQsbRiREEgAoyB00hq+rzQUdywNFBz2aY+ospMfR82VKDmiGwV0RbU7c/Jxu0Z8 PRokUl+Ejj3DLqQPtmxFhcMNTPr2mP0Wlqcwfje6/SD+7G6SZSXekTK/mCO5hZsZwe9T Wvb6E6pn9jNjg50p/+lu3AsakxVgh01Ls29r0T1C2tdQwD51bNURTIv2tWfJC5Qih6YI gdG8QanBmVSvYSSmOAvHmStjLGoheU4gQGgQFloW83TkFBYLuJ3RxhYohUmgy4OlQewn fCJg== X-Forwarded-Encrypted: i=1; AJvYcCXMLKvxplPY6bdovjMIuBWnOTvo0Cgps2tm+RagwcBaGt7VJr4XfQEWEUaFkXtDvgM2qLGcRiYe2DorHalnH8O/7G2PvN7LaY+hWfeYjfKEWY9Pb8Q= X-Gm-Message-State: AOJu0YyXNpLJLFahFlzNn2d/Qhzi1Q/NzOBVacLji0ZCaFRfvH1MXzqq SIFiMJCBkFrHgwSrSMbpVxBC3jbi4UBVnE4fmY7ct5XSPQDcz8fa X-Google-Smtp-Source: AGHT+IFLklw0VPt+U78fsumXcfh6TZru62wWQcHPZt+ZTPkp5rl/p4PAe0H9zRH2ix3RbFqgeJpgHg== X-Received: by 2002:a05:6a00:1911:b0:6f4:1799:c70c with SMTP id d2e1a72fcca58-6f4e02aa518mr1645479b3a.9.1715325293048; Fri, 10 May 2024 00:14:53 -0700 (PDT) Received: from kousik.local ([2405:201:c01a:90f4:8de5:a651:7145:5260]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2a37sm2344475b3a.161.2024.05.10.00.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 00:14:52 -0700 (PDT) From: Kousik Sanagavarapu To: Nishanth Menon , Santosh Shilimkar , Julia Lawall Cc: Shuah Khan , Javier Carrasco , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kousik Sanagavarapu Subject: [PATCH 1/3] soc: ti: pruss: do device_node auto cleanup Date: Fri, 10 May 2024 12:43:22 +0530 Message-ID: <20240510071432.62913-2-five231003@gmail.com> X-Mailer: git-send-email 2.45.0.rc1.8.ge326e52010 In-Reply-To: <20240510071432.62913-1-five231003@gmail.com> References: <20240510071432.62913-1-five231003@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240510_001455_543507_A03398AE X-CRM114-Status: GOOD ( 18.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scope based cleanup instead of manual of_node_put() calls, hence simplifying the handling of error paths at various places. Suggested-by: Julia Lawall Signed-off-by: Kousik Sanagavarapu --- drivers/soc/ti/pruss.c | 48 ++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c index 24a42e0b645c..8f238d59eca9 100644 --- a/drivers/soc/ti/pruss.c +++ b/drivers/soc/ti/pruss.c @@ -381,13 +381,13 @@ static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux, static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) { const struct pruss_private_data *data; - struct device_node *clks_np; struct device *dev = pruss->dev; int ret = 0; data = of_device_get_match_data(dev); - clks_np = of_get_child_by_name(cfg_node, "clocks"); + struct device_node *clks_np __free(device_node) = + of_get_child_by_name(cfg_node, "clocks"); if (!clks_np) { dev_err(dev, "%pOF is missing its 'clocks' node\n", cfg_node); return -ENODEV; @@ -398,7 +398,7 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) "coreclk-mux", clks_np); if (ret) { dev_err(dev, "failed to setup coreclk-mux\n"); - goto put_clks_node; + return ret; } } @@ -406,13 +406,10 @@ static int pruss_clk_init(struct pruss *pruss, struct device_node *cfg_node) clks_np); if (ret) { dev_err(dev, "failed to setup iepclk-mux\n"); - goto put_clks_node; + return ret; } -put_clks_node: - of_node_put(clks_np); - - return ret; + return 0; } static struct regmap_config regmap_conf = { @@ -424,26 +421,22 @@ static struct regmap_config regmap_conf = { static int pruss_cfg_of_init(struct device *dev, struct pruss *pruss) { struct device_node *np = dev_of_node(dev); - struct device_node *child; + struct device_node *child __free(device_node) = + of_get_child_by_name(np, "cfg"); struct resource res; int ret; - child = of_get_child_by_name(np, "cfg"); if (!child) { dev_err(dev, "%pOF is missing its 'cfg' node\n", child); return -ENODEV; } - if (of_address_to_resource(child, 0, &res)) { - ret = -ENOMEM; - goto node_put; - } + if (of_address_to_resource(child, 0, &res)) + return -ENOMEM; pruss->cfg_base = devm_ioremap(dev, res.start, resource_size(&res)); - if (!pruss->cfg_base) { - ret = -ENOMEM; - goto node_put; - } + if (!pruss->cfg_base) + return -ENOMEM; regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child, (u64)res.start); @@ -455,16 +448,13 @@ static int pruss_cfg_of_init(struct device *dev, struct pruss *pruss) if (IS_ERR(pruss->cfg_regmap)) { dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n", PTR_ERR(pruss->cfg_regmap)); - ret = PTR_ERR(pruss->cfg_regmap); - goto node_put; + return PTR_ERR(pruss->cfg_regmap); } ret = pruss_clk_init(pruss, child); if (ret) dev_err(dev, "pruss_clk_init failed, ret = %d\n", ret); -node_put: - of_node_put(child); return ret; } @@ -472,7 +462,6 @@ static int pruss_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(dev); - struct device_node *child; struct pruss *pruss; struct resource res; int ret, i, index; @@ -494,7 +483,8 @@ static int pruss_probe(struct platform_device *pdev) pruss->dev = dev; mutex_init(&pruss->lock); - child = of_get_child_by_name(np, "memories"); + struct device_node *child __free(device_node) = + of_get_child_by_name(np, "memories"); if (!child) { dev_err(dev, "%pOF is missing its 'memories' node\n", child); return -ENODEV; @@ -510,22 +500,17 @@ static int pruss_probe(struct platform_device *pdev) index = of_property_match_string(child, "reg-names", mem_names[i]); - if (index < 0) { - of_node_put(child); + if (index < 0) return index; - } - if (of_address_to_resource(child, index, &res)) { - of_node_put(child); + if (of_address_to_resource(child, index, &res)) return -EINVAL; - } pruss->mem_regions[i].va = devm_ioremap(dev, res.start, resource_size(&res)); if (!pruss->mem_regions[i].va) { dev_err(dev, "failed to parse and map memory resource %d %s\n", i, mem_names[i]); - of_node_put(child); return -ENOMEM; } pruss->mem_regions[i].pa = res.start; @@ -535,7 +520,6 @@ static int pruss_probe(struct platform_device *pdev) mem_names[i], &pruss->mem_regions[i].pa, pruss->mem_regions[i].size, pruss->mem_regions[i].va); } - of_node_put(child); platform_set_drvdata(pdev, pruss); From patchwork Fri May 10 07:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kousik Sanagavarapu X-Patchwork-Id: 13660972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6A6BC25B10 for ; Fri, 10 May 2024 07:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LaFUfRzOeHDXC2APajcw5Vi6Sv8GH7WnFLg3Nu/97g4=; b=E/6X/zoSTHrY3e JjmegDABA1WLolAYYOT67scAXLRJWqGIyWiZAvknNMzDfh9o6P1R+Dq63LKw1JumTuMBb66mMehZq UpVZS0fyZngcTWbPzB/pH+H5vI532/TvtCq7530ltTxJYQYVvE2sn8lr1ZeW0wB76ucb7vVw+Z76L hN84HpvoUwq3UWaE6AZB48hhUoPKOGHjh2WCLLCWPH0Sm4Rr5NsjTxbbahEJqC1QUaScB53/SWJM3 N+hVH+7i5mRZkx4Bnpu+LaoFpaRemZLV3PifDQjkiYQn9bsSEXZO0AHUXrt5DhlXCjvB1JXUIXswo RJNPYhIeHPP3a7mN8PYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5KTA-00000004Kwh-3LSn; Fri, 10 May 2024 07:15:04 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5KT7-00000004KtH-2Ke5 for linux-arm-kernel@lists.infradead.org; Fri, 10 May 2024 07:15:03 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6f0ef6bee72so64733a34.0 for ; Fri, 10 May 2024 00:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715325298; x=1715930098; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z+hTb9Uz5fZ3Gvx3REvMog4ReTfehsa0bk9kBNaBktU=; b=SQpI1FcQWpnfB23F3pppa5ATDLGLjXMVQOZf+SFBfCl4xn1/HnY9u3RFY/EFB/WGNB eZyg3vVKZV5610/SIeimRALgxZyX1yIEjV5Kn3PoQhVraBJt83Wz8DZ+0o1vOymWKYFf kmA9PQvj3ho+xkuYh9GJOpCsBrHX1eQemO3U6Ad49dwFMZot1bPo6+v+UXtLI4/My2jB nx7F00+tfF9cjXhVJaSHC5s0+nXAm9khTmU2Z4xeJQxkEYIyxASOFD1e70vmW/C+hlZh txIq6+kCiF0R+bY8RJA+A+UXf2NxA4VB4DmWxz6yXag94KlkjLqvvRiZF6X0smFrKAcK bbEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715325298; x=1715930098; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z+hTb9Uz5fZ3Gvx3REvMog4ReTfehsa0bk9kBNaBktU=; b=tQeWy9D3Wi+KMMfSTURGA68txtBD1tGkd+rdpMzO899RAzSC06V/8CK0eAwsYc1p/I FGXXl2Qr276Pi7TdvvdMxV+Ma6Sw1LD9duf5VC6pgmLaQLZciTabfDE5kXGqY0AFXvD2 ABHmMCMjTcZGDcpM9LmQF0vYB5MkSZgSVL8BPuZ8kx0/naILpb1wyDPPqNRfN7ws2elc kcdjfubwjR/DB7SpckxpI30+V/t+7385YWSRm4syRe7naxW0UXQar+aRX5NUxjgA9Zp/ EbIpg0M52GfESfAUQu7sfmE89qxZy/0wphGxDGizbrHLrxjg0Z3MIn5j7hBvnqDQdyIn snYg== X-Forwarded-Encrypted: i=1; AJvYcCUUVFdB5EUvG+Uex3K0rVZNkD1QzDgJu5h7Ou0P3E1GACqXOF5sBPiOnzaxCkSG+uvr7C92Y7Imo+XvfpohIb8KlZ9aFz/gHgBZXM0EvQLUFB+L1bc= X-Gm-Message-State: AOJu0YzNn2TgM5NipURnAG8B9QpagvWOUGB3VmcNtNHYQA24vzGHhhhm NorFMaBA/VjyPZFD2tmVO6nu5ZU/BJArlVbliSb5/aI9S3QC7YLFI7hUykFQ X-Google-Smtp-Source: AGHT+IF8XPSpK6Os7Q7kiJB52aBjvbTi/5q1bBhvs1QvP8iY0Js/aA0xNgUw8sbfdd1nCXUC6IC09Q== X-Received: by 2002:a05:6870:17a4:b0:23c:2d6e:96c0 with SMTP id 586e51a60fabf-24172e03f4dmr2100262fac.39.1715325298244; Fri, 10 May 2024 00:14:58 -0700 (PDT) Received: from kousik.local ([2405:201:c01a:90f4:8de5:a651:7145:5260]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2a37sm2344475b3a.161.2024.05.10.00.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 00:14:57 -0700 (PDT) From: Kousik Sanagavarapu To: Nishanth Menon , Santosh Shilimkar , Julia Lawall Cc: Shuah Khan , Javier Carrasco , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kousik Sanagavarapu Subject: [PATCH 2/3] soc: ti: knav_qmss_queue: do device_node auto cleanup Date: Fri, 10 May 2024 12:43:23 +0530 Message-ID: <20240510071432.62913-3-five231003@gmail.com> X-Mailer: git-send-email 2.45.0.rc1.8.ge326e52010 In-Reply-To: <20240510071432.62913-1-five231003@gmail.com> References: <20240510071432.62913-1-five231003@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240510_001501_671222_02134324 X-CRM114-Status: GOOD ( 14.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scope based cleanup, instead of manual of_node_put() calls, which automatically free()s "struct device_node". Doing the cleanup this way has the advantage of reducing the chance of memory leaks in case we need to read from new OF nodes in the future when we probe. Suggested-by: Julia Lawall Signed-off-by: Kousik Sanagavarapu --- drivers/soc/ti/knav_qmss_queue.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 06fb5505c22c..237946312080 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -1755,7 +1755,6 @@ MODULE_DEVICE_TABLE(of, keystone_qmss_of_match); static int knav_queue_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; - struct device_node *qmgrs, *queue_pools, *regions, *pdsps; struct device *dev = &pdev->dev; u32 temp[2]; int ret; @@ -1799,19 +1798,20 @@ static int knav_queue_probe(struct platform_device *pdev) kdev->num_queues = temp[1]; /* Initialize queue managers using device tree configuration */ - qmgrs = of_get_child_by_name(node, "qmgrs"); + struct device_node *qmgrs __free(device_node) = + of_get_child_by_name(node, "qmgrs"); if (!qmgrs) { dev_err(dev, "queue manager info not specified\n"); ret = -ENODEV; goto err; } ret = knav_queue_init_qmgrs(kdev, qmgrs); - of_node_put(qmgrs); if (ret) goto err; /* get pdsp configuration values from device tree */ - pdsps = of_get_child_by_name(node, "pdsps"); + struct device_node *pdsps __free(device_node) = + of_get_child_by_name(node, "pdsps"); if (pdsps) { ret = knav_queue_init_pdsps(kdev, pdsps); if (ret) @@ -1821,17 +1821,16 @@ static int knav_queue_probe(struct platform_device *pdev) if (ret) goto err; } - of_node_put(pdsps); /* get usable queue range values from device tree */ - queue_pools = of_get_child_by_name(node, "queue-pools"); + struct device_node *queue_pools __free(device_node) = + of_get_child_by_name(node, "queue-pools"); if (!queue_pools) { dev_err(dev, "queue-pools not specified\n"); ret = -ENODEV; goto err; } ret = knav_setup_queue_pools(kdev, queue_pools); - of_node_put(queue_pools); if (ret) goto err; @@ -1853,14 +1852,14 @@ static int knav_queue_probe(struct platform_device *pdev) if (ret) goto err; - regions = of_get_child_by_name(node, "descriptor-regions"); + struct device_node *regions __free(device_node) = + of_get_child_by_name(node, "descriptor-regions"); if (!regions) { dev_err(dev, "descriptor-regions not specified\n"); ret = -ENODEV; goto err; } ret = knav_queue_setup_regions(kdev, regions); - of_node_put(regions); if (ret) goto err; From patchwork Fri May 10 07:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kousik Sanagavarapu X-Patchwork-Id: 13660973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82DA7C25B10 for ; Fri, 10 May 2024 07:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ca0DZwEKeAOhC95mGuTrGONX+T2h0KKWZK6Xr2N0PRQ=; b=UGPWu0GWKuXeGo mE6cYIwiz0Vm8Z/JaCK0CJqvJToLUPiwUVFuwatqPgAHtUMrQ+pxE9j76c7SCxKGXzke9UwFeURty ltGeN3KUvoPzS6ZhcX/KUqmbG33x1QwcrhRo8t9ipo+buHzbtNNghCZEn45llNIpzZ5XP4PBCskq4 C2J3q10aTdS6M91Oj3/njKW6yV90neUpxyicXvfI8FK+oUsNtCmxmBSEih5ghLQJ2HMGsmfi7GCJC kOYaKAuylCPOKLF9cdkFnSbBMd4ubO2IZ+pmGTXIqkAKSNYb5Yz2f6vLwH39Pxv8f0bJ9CfAigks+ i0QpAFNzB3w7AiGxavXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5KTG-00000004KzQ-1VZa; Fri, 10 May 2024 07:15:10 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5KTC-00000004KwU-22UK for linux-arm-kernel@lists.infradead.org; Fri, 10 May 2024 07:15:08 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6f4521ad6c0so1527731b3a.0 for ; Fri, 10 May 2024 00:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715325304; x=1715930104; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1e9AaiZhqzpQxOi3rf8QWQAd00HqbSZFUmUbCLkX+1U=; b=L2bn/4WByMtHltKn8rkb3AV1x9l91dEVuqI6fq3upLvv7jVqUH9z/OuA+JqihYONH4 3azB9dYwOM8xN04rUuSdUPZMA1SRKQ+b3MShYwAWe2J0thMDVHcgKwBai5ODV8TmuZg3 ypUBR9zb+BG7UK1ZgDaCXozfZ2vPYiuOxb/LP4YLrLxdjBlVeOmfajeWBuXjN+uc0j/7 GbMNcjbOVyt5IJcASzETQO9dk8Ld6sOiq5y3LipttoFkqtLuAmnAxqGv9ptAya1grlj6 1UFR1GFCXl8TGPaNSgfJ1sF9AGwyibnmTM9ZAwU0c0N/IPZ/teVkf9r6nvxPl02MboAu SLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715325304; x=1715930104; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1e9AaiZhqzpQxOi3rf8QWQAd00HqbSZFUmUbCLkX+1U=; b=iQeUV2EZrItP21wQhdGs08/5mNuRdJ9yy265k4wkLLPdXSsFp45jkR9tF+/6vLrqsV ohKdrWHi/bkxJXF9XoZinbm93br4nEHSeVWllKvjDvUAz1nVsX9Ut2od/fujIhByYF96 CjZnXUhQsvOHILSi7hzlzfMZvs4XvmBY3kL56dPSQ70DN/lvXxwL+nuQKZb9I70waNJ7 1j7IxSi+1ygyQs55FJZQZcuJq1271puT1LRR3QPaTHWY6VRpPhfAn8BwMSXqhLYTFlIr fiwU7MNbLT9O5lpTmX7qfByixFt3kPSrHIHj/ZykedkRDdzPsGG381JYBuI1ZvyipbPO QOMA== X-Forwarded-Encrypted: i=1; AJvYcCXjVGGwrNwst2YQdUjiLG+DKXMh7UlnzGbrOK25k1I2WJySIEnyHJn8cO7dkcip92xylBT6gXUHAj3lCEzZBNccf05fIKSbaLW9dGfsBj1mnmeVTo0= X-Gm-Message-State: AOJu0YwcB0e48QlZpeer+1qI929wTK+JpaMugXwEHjCA630z/PTVAjFQ cINRUGdghwwZBad3r6QYwFKi/enuzIwwgtSgFdza0zV6n4ePb/iq X-Google-Smtp-Source: AGHT+IEwUMH0kBFIFoUmUPVo3NgEwfjmKEL/UUFcaYpx/JhNnaWZO9dILpMlR+hxXvDfTz57P+747Q== X-Received: by 2002:a05:6a00:1a93:b0:6ee:1508:edc8 with SMTP id d2e1a72fcca58-6f4e0347d57mr1783419b3a.23.1715325303602; Fri, 10 May 2024 00:15:03 -0700 (PDT) Received: from kousik.local ([2405:201:c01a:90f4:8de5:a651:7145:5260]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2a37sm2344475b3a.161.2024.05.10.00.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 00:15:03 -0700 (PDT) From: Kousik Sanagavarapu To: Nishanth Menon , Santosh Shilimkar , Julia Lawall Cc: Shuah Khan , Javier Carrasco , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kousik Sanagavarapu Subject: [PATCH 3/3] soc: ti: pm33xx: do device_node auto cleanup Date: Fri, 10 May 2024 12:43:24 +0530 Message-ID: <20240510071432.62913-4-five231003@gmail.com> X-Mailer: git-send-email 2.45.0.rc1.8.ge326e52010 In-Reply-To: <20240510071432.62913-1-five231003@gmail.com> References: <20240510071432.62913-1-five231003@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240510_001506_574314_39B2EE0A X-CRM114-Status: GOOD ( 13.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scope based cleanup instead of manual of_node_put() calls, hence simplifying the handling of error paths. Suggested-by: Julia Lawall Signed-off-by: Kousik Sanagavarapu --- drivers/soc/ti/pm33xx.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c index 8e983c3c4e03..40988c45ed00 100644 --- a/drivers/soc/ti/pm33xx.c +++ b/drivers/soc/ti/pm33xx.c @@ -383,10 +383,9 @@ static void am33xx_pm_free_sram(void) */ static int am33xx_pm_alloc_sram(void) { - struct device_node *np; - int ret = 0; + struct device_node *np __free(device_node) = + of_find_compatible_node(NULL, NULL, "ti,omap3-mpu"); - np = of_find_compatible_node(NULL, NULL, "ti,omap3-mpu"); if (!np) { np = of_find_compatible_node(NULL, NULL, "ti,omap4-mpu"); if (!np) { @@ -400,24 +399,21 @@ static int am33xx_pm_alloc_sram(void) if (!sram_pool) { dev_err(pm33xx_dev, "PM: %s: Unable to get sram pool for ocmcram\n", __func__); - ret = -ENODEV; - goto mpu_put_node; + return -ENODEV; } sram_pool_data = of_gen_pool_get(np, "pm-sram", 1); if (!sram_pool_data) { dev_err(pm33xx_dev, "PM: %s: Unable to get sram data pool for ocmcram\n", __func__); - ret = -ENODEV; - goto mpu_put_node; + return -ENODEV; } ocmcram_location = gen_pool_alloc(sram_pool, *pm_sram->do_wfi_sz); if (!ocmcram_location) { dev_err(pm33xx_dev, "PM: %s: Unable to allocate memory from ocmcram\n", __func__); - ret = -ENOMEM; - goto mpu_put_node; + return -ENOMEM; } ocmcram_location_data = gen_pool_alloc(sram_pool_data, @@ -425,12 +421,10 @@ static int am33xx_pm_alloc_sram(void) if (!ocmcram_location_data) { dev_err(pm33xx_dev, "PM: Unable to allocate memory from ocmcram\n"); gen_pool_free(sram_pool, ocmcram_location, *pm_sram->do_wfi_sz); - ret = -ENOMEM; + return -ENOMEM; } -mpu_put_node: - of_node_put(np); - return ret; + return 0; } static int am33xx_pm_rtc_setup(void)