Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1950492lqm; Fri, 3 May 2024 10:53:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUKo4Mh3qFxlRLKgxeTp0YyZ1LZNEJOXGdFMPTW8NZpi+zRVOHPhpMCgxRgqmaxZlSngHCIwGXZf0c9rAT7ddQwuMKgoepz2NtvzdcGyA== X-Google-Smtp-Source: AGHT+IEGEoflqpWkKCaEnP3sVoGVtxrrroaiybL/XycVWL3rAHZOS1vkEWTlxwmyM07fbxOG2RPU X-Received: by 2002:a05:620a:29cd:b0:790:d62a:da09 with SMTP id s13-20020a05620a29cd00b00790d62ada09mr4163822qkp.5.1714758796910; Fri, 03 May 2024 10:53:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714758796; cv=pass; d=google.com; s=arc-20160816; b=apQNv87uY9llsnHSqgPgX1ikoQ+ATk9/asNCimYHZabILTmgVOYnAKVePOhCxPC9g/ zobMVoFTnHWhBdMXdeJRQyh0WLffwFLtMkbqzPLsCtff251VCjLPbWLLsJuObrZaOGBG 2jzUJInAmRAwGL67YhHVUcF9OBGJ87fJgrvVwk3ozGBTEXIz44tmFX5aY4FPiCN8S7xS FeOWedyGO32suUxy6rhEijPerLmCMnLMLR9sqTb1l8N/uZLM1GMtgkp7GyHCyMdyf92S 7t+as0ZHO+QuDIBFm8O8ylS7qgheR3c/Q5fPVj7IuRUjpyMnz1rmyJaaA07/Q568iDch AGYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=nDa0e4iujX0ACKE4cFSjYtiiXZ+21EvsOzvNajBTvcI=; fh=W0yQE/5G3gMrqLUyfruqHsDoHglk8fMk1RWGl+JSj9g=; b=SjMvrVBQOdc4DQmkcfjYmw4XX8XFFkT2na+kGcQ+LAQciwXya7u/ydWZS6gSXzgp8Z lqfDmoCbsPJl13kMPbi3IthIaTdaxyxiNBU3nuUN3TpNJrXCEMGe0Ld1MO9UjdKKffiU JAjUPK2wRLoTmg4knJ/OhCk70hMwKW0s/5MMrXAHla6sp0omkJXzx1gvnBWN1T3ZhYeM OyiMB636J9MhF353vl/+vQb5Ht++3h8jvZ/TdbZgzu6B5I7ruqkzA6/4rrqb1Gas7cqM JTSyocdFTpmlxT4+ks5TBR2v/1wvM7KGsAYWRC6sF04TtrAS3N8i59BEYjiziME0EMUM 7N+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fHBnhkNf; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-167989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167989-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wg22-20020a05620a569600b00790702b5541si3542220qkn.190.2024.05.03.10.53.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fHBnhkNf; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-167989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167989-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 923501C21911 for ; Fri, 3 May 2024 17:53:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9687158861; Fri, 3 May 2024 17:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fHBnhkNf" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76C02158219; Fri, 3 May 2024 17:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714758763; cv=none; b=ErlMyvl619DK31vKE543BjtUqNNIBrfHXke6DIChK3Va1gRlR/28pcsqhZruYNGdpJexeY7nyfHPoAzQxSOOefcaRjxvU4FxH9gI8k+DZ6gHfFa98h9JDMZPLNxRt6uLtPxwXDFvcbfuJ4rRZ6C8XyuRUyrJdFaU3CKVffzsjTo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714758763; c=relaxed/simple; bh=lzVnrSjci3YdZbJDcigjVDnutqYD0vEbfrujcq5AHHs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kx6rgwmJDiz1z7RcsAdiTZLNOOY2vlw52ChjQ1R64gapawoNZS9Cctckp0WGy6RGtbDzpp119WXmcqEl7LNFjK8y+R0ld03VVkcBYjSp5LzZrZVN14jIzkZ8ml5c37wUL2S91/uI4te3xzENHr4o+Y6CMNyiW9JX5C/o9bRRwG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fHBnhkNf; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a5894c1d954so462406166b.1; Fri, 03 May 2024 10:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714758760; x=1715363560; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nDa0e4iujX0ACKE4cFSjYtiiXZ+21EvsOzvNajBTvcI=; b=fHBnhkNfFgY0EOvMbeVCSgUkK7B04ewgHLaKvupBI1FHbml3mOuJNEtp4z3KnDfxnP q/kpD0T4HiVuwFL0hzy/8ZE73zCE3GgCyoFHSwTqzKksgDaMMNnLm7kFmEHveYVR5Src YXEmQyX5QUeLdOF5PQ8IsAyZ6QXAPeue/CP1RzyBIg2hZYlVNhpb0Pm2ab+X6946Y+an x9LMs8Tnwo02wbyE+f8xZQQLQdkv1XJVdJ6N3fdMRQxPd6fU8rl5s1h4axpsQAkYCDCT h/8VKiGbPhwq56kNy+kXIdjb6pvFeQwx72K2b75ExFzx+K7llCFwQH68VOTtfKfSFU9o gkqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714758760; x=1715363560; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nDa0e4iujX0ACKE4cFSjYtiiXZ+21EvsOzvNajBTvcI=; b=LEAj6ZkKB/Gzuip3jB6vw7KmUtWNXJb/CnZrFKXCl53KJttPngkg6zRoUdkNqEyEsI FncKm1W2eqF38E3HUDbQffM0tPOtwZ8c3/MqfHwQYspzZcneeQTMiuKmtQZZL50ocqdN 9L4NL5nrZfivnMGMUGzUU9r1T+dOqUSRVihH3Rt48iOeR+XHcJ0mTcatMXKiU5gPQmzV l5YrsJPl4tAgBiftbHy7h/CUlVjvKGZrUhGP3ke/Cuisj9suOMzSOIEEwiN7qCSfFmHn 4qSPIaPz5b8VwplAQf25mEjQtJdo251Fu8LWaaU/9/kHVZ12d5HlUVfnC5Vl6CHA9z1N y13w== X-Forwarded-Encrypted: i=1; AJvYcCUKfcPbNup11HdOgEIuDb30/ppXFEml47MxXTiR9wpbmDethXSNwaMdepGZV5l/R/xE6zD5l4m3pgN3nIwt3XdhtxBaItTAoJzLKyN9 X-Gm-Message-State: AOJu0Yy4sgNylC9OgJUrFGg9xvoB/S6GdsZGsVICfGsnowSkJ3O1HfVZ QjIc/MN9VQZ4+qdoPJEyjDQB1+xPX8yLIkpXn4h3kIw84KdNkaovYFLSc2wcOjE= X-Received: by 2002:a50:9549:0:b0:572:3483:8a27 with SMTP id v9-20020a509549000000b0057234838a27mr2688603eda.33.1714758759958; Fri, 03 May 2024 10:52:39 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-47.cable.dynamic.surfer.at. [84.115.213.47]) by smtp.gmail.com with ESMTPSA id q28-20020a50aa9c000000b00572469a7948sm1968368edc.45.2024.05.03.10.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:52:39 -0700 (PDT) From: Javier Carrasco Date: Fri, 03 May 2024 19:52:33 +0200 Subject: [PATCH 2/2] cpufreq: sun50i: replace of_node_put() with automatic cleanup handler 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240503-sun50i-cpufreq-nvmem-cleanup-v1-2-0a2352cac46b@gmail.com> References: <20240503-sun50i-cpufreq-nvmem-cleanup-v1-0-0a2352cac46b@gmail.com> In-Reply-To: <20240503-sun50i-cpufreq-nvmem-cleanup-v1-0-0a2352cac46b@gmail.com> To: Yangtao Li , "Rafael J. Wysocki" , Viresh Kumar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andre Przywara , Jonathan Cameron Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1714758755; l=2545; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=lzVnrSjci3YdZbJDcigjVDnutqYD0vEbfrujcq5AHHs=; b=EOd+5S8zrky1F+pf72NRCJOPHcqlppmlIu7H4SxMTuZa8DO0mns86VbChhQoq1UQhqm1esOuH iDf9qDV2t7qDx8DC46feRuLOrY1zGZIHAzv0ufxTYPAlC0XNm2P0FzB X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Make use of the __free() cleanup handler to automatically free nodes when they get out of scope. Signed-off-by: Javier Carrasco --- 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); } /* -- 2.40.1