From mboxrd@z Thu Jan 1 00:00:00 1970 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 5258FC25B10 for ; Fri, 10 May 2024 17:42:33 +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:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R3yhpMJWsCvV6Nl2ml4aJHPdD9oWMWhnGG2JVfGM980=; b=xDNs8Z8liQM1bO xrwvvLFNFNPzg8ykVQ8mck6vwn9IDNXVTghbFYfi86U/Vhktu0jxy+WCra6b9VY40FPK3MLxWb80V 2NQ8DEjB4S1CwrRmCpogI3FxierLxIDfKMp/Bgwo0lg32R9tjgU6tTEYei/jS96vh0AJm38erlfGa 86F1KqdVv10351t+SQZqisaB0TzLAkPCCj+7OiTq9CBzmNu3PO3JnmdT7g4ec3TvKeKv0deO1NCyS r3cYphL5cZ9MGpEiEkETweSz6oN7LbRKTulcztvakvjmfDvKCh3WGD+WHet1V8eQeeVwPekb9whqV UL6fe1j2Ec6L2tSzKkug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5UGD-000000062aL-0Q29; Fri, 10 May 2024 17:42:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5UGA-000000062ZO-0v9H for linux-arm-kernel@lists.infradead.org; Fri, 10 May 2024 17:42:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9082711FB; Fri, 10 May 2024 10:42:42 -0700 (PDT) Received: from donnerap.manchester.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 831123F6A8; Fri, 10 May 2024 10:42:15 -0700 (PDT) Date: Fri, 10 May 2024 18:42:13 +0100 From: Andre Przywara To: Javier Carrasco Cc: Yangtao Li , "Rafael J. Wysocki" , Viresh Kumar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] cpufreq: sun50i: replace of_node_put() with automatic cleanup handler Message-ID: <20240510184213.68f92cab@donnerap.manchester.arm.com> In-Reply-To: <20240503-sun50i-cpufreq-nvmem-cleanup-v1-2-0a2352cac46b@gmail.com> References: <20240503-sun50i-cpufreq-nvmem-cleanup-v1-0-0a2352cac46b@gmail.com> <20240503-sun50i-cpufreq-nvmem-cleanup-v1-2-0a2352cac46b@gmail.com> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240510_104218_430151_83D4874E X-CRM114-Status: GOOD ( 19.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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 03 May 2024 19:52:33 +0200 Javier Carrasco wrote: Hi, > Make use of the __free() cleanup handler to automatically free nodes > when they get out of scope. Looks alright, the last function is now particularly neat. > Signed-off-by: Javier Carrasco Reviewed-by: Andre Przywara I haven't tested the error paths yet, but it certainly boots fine on an OrangePi Zero3. Cheers, Andre > --- > drivers/cpufreq/sun50i-cpufreq-nvmem.c | 25 ++++++++----------------- > 1 file changed, 8 insertions(+), 17 deletions(-) > > diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c > index ef83e4bf2639..eb47c193269c 100644 > --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c > +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c > @@ -131,14 +131,14 @@ static const struct of_device_id cpu_opp_match_list[] = { > static bool dt_has_supported_hw(void) > { > bool has_opp_supported_hw = false; > - struct device_node *np; > struct device *cpu_dev; > > cpu_dev = get_cpu_device(0); > if (!cpu_dev) > return false; > > - np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); > + struct device_node *np __free(device_node) = > + dev_pm_opp_of_get_opp_desc_node(cpu_dev); > if (!np) > return false; > > @@ -149,8 +149,6 @@ static bool dt_has_supported_hw(void) > } > } > > - of_node_put(np); > - > return has_opp_supported_hw; > } > > @@ -165,7 +163,6 @@ static int sun50i_cpufreq_get_efuse(void) > const struct sunxi_cpufreq_data *opp_data; > struct nvmem_cell *speedbin_nvmem; > const struct of_device_id *match; > - struct device_node *np; > struct device *cpu_dev; > u32 *speedbin; > int ret; > @@ -174,19 +171,18 @@ static int sun50i_cpufreq_get_efuse(void) > if (!cpu_dev) > return -ENODEV; > > - np = dev_pm_opp_of_get_opp_desc_node(cpu_dev); > + struct device_node *np __free(device_node) = > + dev_pm_opp_of_get_opp_desc_node(cpu_dev); > if (!np) > return -ENOENT; > > match = of_match_node(cpu_opp_match_list, np); > - if (!match) { > - of_node_put(np); > + if (!match) > return -ENOENT; > - } > + > opp_data = match->data; > > speedbin_nvmem = of_nvmem_cell_get(np, NULL); > - of_node_put(np); > if (IS_ERR(speedbin_nvmem)) > return dev_err_probe(cpu_dev, PTR_ERR(speedbin_nvmem), > "Could not get nvmem cell\n"); > @@ -301,14 +297,9 @@ MODULE_DEVICE_TABLE(of, sun50i_cpufreq_match_list); > > static const struct of_device_id *sun50i_cpufreq_match_node(void) > { > - const struct of_device_id *match; > - struct device_node *np; > - > - np = of_find_node_by_path("/"); > - match = of_match_node(sun50i_cpufreq_match_list, np); > - of_node_put(np); > + struct device_node *np __free(device_node) = of_find_node_by_path("/"); > > - return match; > + return of_match_node(sun50i_cpufreq_match_list, np); > } > > /* > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel