From patchwork Wed Jul 3 06:55:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kousik Sanagavarapu X-Patchwork-Id: 13721469 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 90C59C30653 for ; Wed, 3 Jul 2024 06:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bxbxKt+yrBPNNKQZqw0DOsM2FX9GJEjPe3EATpJa3RU=; b=jOhoTiDEfBVurKfvv0eRogY941 50uqkO3dwKWw8NDHsoQCU9umjKf4wrarnqTBOzyG+kwpvPWp554qgmQeOxeoh1GVYhENzNQlQREBV muXS+vssEicPW09zcXtGV216aYebiJyWNZGX2QwOr6EkS+PV4JMJLeO3mu2T6Oax8Bi9fU/6VZoRf FEKK39zENhb26j2yctMqnIwoTtPkT0YecaCkOdAzNfLiHqcoSuiztKfglcDOb6C12SUHowofAnHP3 aSMJ0gUgswFG6avrQALiDFf0nz0PXR+eHYgqCrWpNG6F1a9vfWEa6wyVbwVjYixmaneqBmrqQptcR ggptbLjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOtx1-00000009Glh-3dms; Wed, 03 Jul 2024 06:58:47 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOtwb-00000009GbJ-2YUX for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2024 06:58:23 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2c97aceb6e4so175842a91.2 for ; Tue, 02 Jul 2024 23:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719989901; x=1720594701; 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=bxbxKt+yrBPNNKQZqw0DOsM2FX9GJEjPe3EATpJa3RU=; b=HI4pAqZKxDCYplVoaPbXaTj+PVrpWXzcFVdXRPGN5iKu1KZkQs91wgu8GHvN2JWffp MnCypNOdsYGYCsDtH6hRYhLBHyqKchI+H5keW1sNl4ZdX+S2Uxg17BwvgfQ9UCKPcomu Rvbsg9qTaMJsoivAIEIglBjYaJlFO3J4T2GJVyiorUrwTPykEfbUoQBIXA53Fky2MOr9 WMRNFt9+7CQS6NIolhVh3vckJ2d6IkHoEN7SBJ9hAO1EkyvCJXjTQfQBZPJYw+lXtUK3 /FK5JnbuRR5r4n3I9Y9ZfnvxysW2OGQnyrJR6nBmoebcxmS6BaljTMdrkapdwrB5X201 kl5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719989901; x=1720594701; 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=bxbxKt+yrBPNNKQZqw0DOsM2FX9GJEjPe3EATpJa3RU=; b=fNwCOKKqWfYsUEOQTWXw3MoKpyxoIS3XyfmDOVQyL1wLB+C6VsQUWtmBA1DqL7mHEv jTPRhT0qcSGlEEsrPrbB7e5mG0bV/AZXeXVod7+bvtCiEppe/xgokU8lNN1ZuYdILRRB zXP6CNFXJtUXapNl99ZUXjDjui+5v8B1Q9w2s2jAIwzT5R1adrmeeqjMXm+nLeCWXDE/ 1x6qzi+Yc4OU+TZsoNGVu1JEgzAzPzZYAp27oN5TJC3TtRlaS2jsp4RISjvuCp7ESauR h4J5BbSk9ppOtcHcWwgf/AjtAtIDQd1HTJYwH/mJ6Fm2ECl6Hu7n/r04dwO1vU628RAb kbnw== X-Forwarded-Encrypted: i=1; AJvYcCWA6e1zHWObuihcwpLnmR1jCSBxzpUeoQoGoKcrnd/BsJHFxiQGFevb8Iv19zkQJ6QaLEC7F0eB5j5sM1Ql2avYox9pyiw7AHAd4Jy+ha+tIV9WFLQ= X-Gm-Message-State: AOJu0YyVSEykuE4R3ivQL89ohNZ0RAbDLxQIAgIj5ZzKshERcHOR/X6Y WpmvgJpqyT/XqZVGTfH/EeNmdBVomMECwTCwo7ZrH/6CxrfPrfHF X-Google-Smtp-Source: AGHT+IHArs7mizExpBu5sv5B/RYD+ZEGUNrrOWSx56Hcy+SLKwJ5Kja6sljlxOWMSAWYm+qthagh5g== X-Received: by 2002:a17:90a:ec12:b0:2c8:880:776b with SMTP id 98e67ed59e1d1-2c93d71f509mr9257040a91.23.1719989900562; Tue, 02 Jul 2024 23:58:20 -0700 (PDT) Received: from kousik.local ([2405:201:c006:312d:258c:c06c:76e7:dba9]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3e818asm9973921a91.51.2024.07.02.23.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 23:58:20 -0700 (PDT) From: Kousik Sanagavarapu To: Julia Lawall , Nishanth Menon , Jonathan Cameron , Santosh Shilimkar , Nathan Chancellor Cc: Shuah Khan , Javier Carrasco , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kousik Sanagavarapu Subject: [PATCH v2 3/3] soc: ti: pm33xx: do device_node auto cleanup Date: Wed, 3 Jul 2024 12:25:28 +0530 Message-ID: <20240703065710.13786-4-five231003@gmail.com> X-Mailer: git-send-email 2.45.2.561.g66ac6e4bcd In-Reply-To: <20240703065710.13786-1-five231003@gmail.com> References: <20240703065710.13786-1-five231003@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240702_235821_673835_2880EDC5 X-CRM114-Status: GOOD ( 13.31 ) 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)