Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2793248lqt; Tue, 23 Apr 2024 01:28:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVstyCaj+tpaKtWDl3jpZFC2t5J65Fy3b+gXxmkTGm/12AJA+gLBefOI5yo3nMdnOF5pV8PPaGeSQ23qHF7IV6phIARZVsj41eCSUPHoQ== X-Google-Smtp-Source: AGHT+IFIGU1CB2QSPLrmYms8RM7y8YGNULsOGfC1nMnEftD08Naz9Go9+umL0lcZ/q5wkZ1Laq7h X-Received: by 2002:a05:6512:923:b0:516:26cd:da71 with SMTP id f3-20020a056512092300b0051626cdda71mr8902136lft.3.1713860903968; Tue, 23 Apr 2024 01:28:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713860903; cv=pass; d=google.com; s=arc-20160816; b=U9aAniBho71FkShcc/CeGuFyj8CLgYfLUl7omwX8kEK332gHACrgCoNPW6Kua8aRp6 rPT7NbLzb+naJnWAGxqU1Y9ZcKssDgIAY+uH+XZ/+0kJQn3+eFg+pmuhBdkKPLLgpvud KlyXNwXUZZWJodfQqGeCNYcYlzJlFrFA3ePdC633goSrrj/LinRga3S3DZqdDY0tuAMP dcpcQsf9Ii6ujNFA5G8g0am2YblOGoUXtC4xn/Bsgo8YehLJX5PU9BCGzBmK7i3pTSVu gAooMlqDqyUSfda+pLOw1U37Pz5kiAsusQxxCzvoNGKO9f1qGQTtK+Rw3OrrnAlA2pm1 zuoA== 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=Oi+kksVAmLiDnfPl3EhNSxJEKMAcV8AHjUA/UGReHCA=; fh=7PwTPYPAkdJyPhDrUpCymcphNWfNemp9Ah4kUfkrf1k=; b=AxS9v92VwcIAWN+KcODYGIJeIpg6yO4diJU0awdFL1J1jnb4qp98VvJv0I+TUgM1yt T1WMRHTzw5pA/8VroTFShbtz3ACPdVWZzLmhyRCevcPreMJ4885FbTrorsBwBb6gpPn+ heE4U7hXDY7CvtbXBsJC037hm8p98LKVNsihBAFCzPnvLxU7vxZRlKkFU3n4WaK/ddJl T8MrSTO+3umWnjYbXHRs+nuSRGl/LEQQaDt42CDUID4/z4mSnQ8Tjd2kp3hjVCPnzlpn 9kobcEeJMjKqyt6dQ+iYMu+dqumK5VHTV44LxLaTJtuJK9FKrm/C/hZej+6P7m1FbzMy uKKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gsgONNVZ; 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-154682-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v13-20020a1709067d8d00b00a526d522847si6785626ejo.768.2024.04.23.01.28.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154682-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gsgONNVZ; 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-154682-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154682-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8E50F1F23977 for ; Tue, 23 Apr 2024 08:28:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4223A53818; Tue, 23 Apr 2024 08:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gsgONNVZ" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 CF7D751C59; Tue, 23 Apr 2024 08:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713860883; cv=none; b=a038XcZilsU8JI4eUfj6rJ9kxs9ZyOif/fQl1ewR550FkuMaWVr93v/zau6uON6/OR9dVUqkxxs3dzYCuNW7USq+WYPCdT9frSqIsCVsvpkMcLT8soBMDtpJF2JdXqvWO/rp3r4AtrXHgAQaDQ5FCjF0wCdqRvVpjV+lXgvnvKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713860883; c=relaxed/simple; bh=d0C33HQybEZzIdgZN8yAFVztmrggKfPv2Wce7jGP7xc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gymPShMfyx/uuYIPX52hNZZgSxD5cwKR6/lzaonhbHbrAGDFnEVtngd3szTzvukZaNAvC8sZqNJR/reFv3mOixDG/mdm+9FZp+O8PEm8A1XwS4XKjtWg7mBrKJO42XusUjXy9c8QUfoTg5o1QYkWzuIZ7zvnUkjU/hP8kYcEpZE= 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=gsgONNVZ; arc=none smtp.client-ip=209.85.167.52 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-lf1-f52.google.com with SMTP id 2adb3069b0e04-51bafbe7509so357401e87.1; Tue, 23 Apr 2024 01:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713860880; x=1714465680; 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=Oi+kksVAmLiDnfPl3EhNSxJEKMAcV8AHjUA/UGReHCA=; b=gsgONNVZE6U6Aohy3FczIrLW23DrBP/jV/0qY2q58SmEbFhgLRLagY/t4wuKL6no00 9DBr1bM4mRjRuVE3IBwaBSFCTCGE4trzq8pwl8Nh9cZOvUmv5uBqHs8AVMh1A8c6V0mT loXUIYFzdx1ePFwMHvWamyKj7GPwQPamd3wYJQUG3xZXk5J4PucwEGoDV5jHR7ghtMX0 tQSkodE3cBWtuk+VEbvQ0bht8EmwaRcWs8VUrj4hvyeQBt16jchwM3v2Kp21Z+DKd6iV PBvI7zQtBZSEEFXCtX20LWmzdLZpHoJ6eKF78Ke20zKSWmtHllzsA3WZWePRNyRtJnva pLhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713860880; x=1714465680; 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=Oi+kksVAmLiDnfPl3EhNSxJEKMAcV8AHjUA/UGReHCA=; b=o0EoZ4cwTvBMnjA6ozlTA4dTimXx2vmkW+A/utcSPg0QJOyRXFWlBT13GWhF6rN2Xr aJrHgnIda91jUGiWoxyteEffD1qpR9dcLTYbhHg9G/mNpRIs4whMypmohsx399WejZPw 9XRVQ05ZM3x8BQoT5jspSlmnnEkZsByIX6QXpubnRA5gug4NudWy62OhXH1uRWcNvXP4 bbnOp26Euqp0UBY0jBoi8C+secjn5F4mDXXRtp2Jfszx+/dd/B8xiLRK8oamS5P/eK5z ZHRVeSvtqv0s9yZLFCHj2Kb69R3uB/AUXkk0V5VqvQidNRW9ceNwXlpM71DkzfxaUZAG bzOA== X-Forwarded-Encrypted: i=1; AJvYcCVmsDRK99lDwxbb76AnVuMHm7PkZyZVdXEXzoSusaYzYEUcmZocmk5rNYzDI71NnwEWl7it9HyxNYDMorfyjeYpLjWZortxYhE9v7Pd X-Gm-Message-State: AOJu0YzA9cc+h64mfyzp5rUC3RwWttQuO2rgWkmPJ7H/QIkyf+0CWLC5 d9PKGjW8RfaSC97si2tpREpuSl162BoadB7BdooMILyXNDO934eF X-Received: by 2002:ac2:4e4f:0:b0:516:d1af:adc1 with SMTP id f15-20020ac24e4f000000b00516d1afadc1mr9369519lfr.9.1713860879667; Tue, 23 Apr 2024 01:27:59 -0700 (PDT) Received: from [127.0.1.1] (91-118-163-37.static.upcbusiness.at. [91.118.163.37]) by smtp.gmail.com with ESMTPSA id z13-20020a17090655cd00b00a4739efd7cesm6798786ejp.60.2024.04.23.01.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:27:58 -0700 (PDT) From: Javier Carrasco Date: Tue, 23 Apr 2024 10:27:44 +0200 Subject: [PATCH 1/2] cpufreq: dt: eliminate uses of of_node_put() 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: <20240423-of_node_put_cpufreq_dt-v1-1-19f51910276f@gmail.com> References: <20240423-of_node_put_cpufreq_dt-v1-0-19f51910276f@gmail.com> In-Reply-To: <20240423-of_node_put_cpufreq_dt-v1-0-19f51910276f@gmail.com> To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1713860876; l=1637; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=d0C33HQybEZzIdgZN8yAFVztmrggKfPv2Wce7jGP7xc=; b=RWxlXNGqAG/TzyjJ70OIBiL7qItq1KzVbtL8EjAHW9lv+Zct8riu3DAV+6NSqD9Qpj64+t6V/ e0dvN/UHMaGDrsbAb/94lBB4RZUzqrd3DhG9AyFIb95pLTwRSJsKe03 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. Only find_supply_name() is affected, and the new mechanism removes the need for a 'goto' and the 'name' local variable. Signed-off-by: Javier Carrasco --- drivers/cpufreq/cpufreq-dt.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 2d83bbc65dd0..907e22632fda 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -68,12 +68,9 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) */ static const char *find_supply_name(struct device *dev) { - struct device_node *np; + struct device_node *np __free(device_node) = of_node_get(dev->of_node); struct property *pp; int cpu = dev->id; - const char *name = NULL; - - np = of_node_get(dev->of_node); /* This must be valid for sure */ if (WARN_ON(!np)) @@ -82,22 +79,16 @@ static const char *find_supply_name(struct device *dev) /* Try "cpu0" for older DTs */ if (!cpu) { pp = of_find_property(np, "cpu0-supply", NULL); - if (pp) { - name = "cpu0"; - goto node_put; - } + if (pp) + return "cpu0"; } pp = of_find_property(np, "cpu-supply", NULL); - if (pp) { - name = "cpu"; - goto node_put; - } + if (pp) + return "cpu"; dev_dbg(dev, "no regulator for cpu%d\n", cpu); -node_put: - of_node_put(np); - return name; + return NULL; } static int cpufreq_init(struct cpufreq_policy *policy) -- 2.40.1