Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp663249lqo; Fri, 10 May 2024 10:42:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV024lhmbhmhhIXwQLTYlJuRZ27E/kx8BVyqLr6N/o+IQwd4JIUNCjk43xuqUO7JBm7wW1LuuQORQfBK1n4JesPA/9VEv2Hu6J/2lS5cg== X-Google-Smtp-Source: AGHT+IGf2VSE+aFvN79BX/mKGgeOaaCCF8Jqj/VHsv9RYPs0Y5G6vfFvUBvdvKdHYistKPty9mLD X-Received: by 2002:a17:906:ae45:b0:a59:c208:a4c with SMTP id a640c23a62f3a-a5a2d583d60mr200111466b.17.1715362947687; Fri, 10 May 2024 10:42:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715362947; cv=pass; d=google.com; s=arc-20160816; b=iaJR646A7gibXc3LZXyWdLCzD6g1+Q9Pob13Z4luniTNBQX4sYk+YT/l9BfxyFBglr GzN8V1IKFSqK9lHuY8+47fIC4Y5h/MdsbZVmFZWh+Gf283zCNh0SjEGwIeye/KEmPh2j lFIxPTn9eJiAQWwgl/qVDYlwxRiDTTSOICx2GmVICqpQXgqD89i4DYHIObtiHfWOl1iZ 0HIAWoGy+cxTrRXsi5C9+rsF0xmPAYik+9cwAWoQTF/Iigk6fLCTVT9QM+K5NAks2gWZ Ej8Grq2Lo9NNFSxoqcuBfVSP/PYncmGBLClUp9JNsvD108fYTQOmTyIQtOIJ5kUMzfD6 EWCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=px2RjRK4DF0J8ikFGvxQVciSNztyXUhNMc4UsT3B0wk=; fh=55rHtnTnGCux3ZAl876AoPkzVL+WuxIc4PPHgVpf4AM=; b=i/e6myASOIsAOE8069nvEShAnqgNP2sqfZE1nv6Z05XvqqWBqerEZzUkNwWh/geRlI fVpm58hfCHDXgORDd8XFjkfkRteb/R93Z9nHiIhPi0sL3phDuUWIUJDT5Ymk4PJXZYwm VeOatXlewJxH4VmQCAxOLsIFpH289cWA4uVl8zhHic0e+KSsfk3vB14RQuXlToThFO/g epGtdMe54htgGGDTNr+I4ti+rgTIWMAXRE29t/n3Qiq6F5+Qbe7TOpuiSbMn+YZmBemj y1irHXXcw21SKPJC66g/c1bUHK3OLlUjpx2XIb+r072j3fAW8SY41N5rhtBye/7//uZf n/Tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-176061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c04388si212169366b.892.2024.05.10.10.42.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 10:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-176061-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6AD521F2150A for ; Fri, 10 May 2024 17:42:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D9711C69A; Fri, 10 May 2024 17:42:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E45D11C6A5; Fri, 10 May 2024 17:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715362940; cv=none; b=Nop1Zo/IPdEdLYxpbZbzGJF1C/pO8MZzauk35MAHHv8ygn7MDmWQkLhvVCFOH9CBLMqObP0zfQ0HBqDhT7GS0g61fVXFtSBy4nNb0BPIFhQBDtV5zEJi+SBT9jj9gWEikPc+6SyO4voeXrNHx+wHjTz4dNNMCw2fs/+YDOV6e1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715362940; c=relaxed/simple; bh=6Rt5NSPnzn2NwoYdNUH+A4syqFWse6boHm56KdEPN7A=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JlH1Oq1GNQCA2iUReiY+jV17tugQtKV28dzLHmSWcdxGkVhAWU5zTqG+9ShRXeTHR8/HKdu6ezvG0jgXc/Jl+9HJpFKU8T54hGfsBuH+by8lTl/HBp6zgLBZWTvv7tOwODiT07rJhOkmx4ZmWFnwtoCIXhDYKWXzLc8KzVr9nAo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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); > } > > /* >