From patchwork Tue Apr 23 08:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 791856 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gsgONNVZ" 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-Google-Smtp-Source: AGHT+IF7Icf4xFnq8lYBnuZCWCXdkLjK1vKPpxojgtOUi/4kBIDOFWXaPzHZSfD6HdK0tdaphd9tmQ== 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-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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) From patchwork Tue Apr 23 08:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 791395 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 57F57524BA; Tue, 23 Apr 2024 08:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713860883; cv=none; b=nVg1Sla/y3xkHDTZzeTERAME5pL9IbyTounSkFtynF2Agcz1OvFmnniOCa7EFtph4mAeew+AoozHOCdTjO/qYtpkX/rV1KwsN+ynH88Hgvn7nNdsWKYTZEkFgkJwaYTgfdhotSHZL5dxeoVP1dlc+BQZHbl4oFoUt+qcYKKVxTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713860883; c=relaxed/simple; bh=W8LjUVAmqv/G+B+i2P0GUBDI1TRWfOmtY46AfJi9z+o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DtZCtBQrYz5IVvPajYqvRZmbwrAyQ+qQUpKXy182Aeq4TqxzIvekdlhQfI7jGq8U+HPapMYVOHImiHF8sCT5xzflhiw4TsDFHNd3OnAOpn8qYHxhSnLxaPjriZRnm1p14uAsOks2Z4o5s9UIzdz4eWbNortI0KUDXYRJGYVomRg= 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=XQZJYx6x; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XQZJYx6x" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-56e56ee8d5cso6628015a12.2; Tue, 23 Apr 2024 01:28:02 -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=xlx4itTMzYZnTqS6gtVBP4dI6YRkemDRngd0L+Y36pA=; b=XQZJYx6xUFNbe9dyXTfJGXJBpVTacv4NKz0CmLKdD5pDyuFSWadSo5iGDBlA7pm1gj dmQn0/ro/+xDGbmDN2nTqQtQG7R+6gkWyaMBPviahSJIZbb0Yt9NUGdtRfkt+xftwQN+ JQ9Kv6ZdiS4RldTQvaaXoKf3DO6cIp0TwWx4/XJjtbbSqK2WJYzyJyfaZejVVL6+FYTR 1oUZ8zKf12rTTQIZcrmemeRjuBQvW2+Y06BqT50b2n/NyWdj/6ySQT2BkLLemoc4z2aD A1m3JijQUJTrIcRzalSLBD2AfE4bIMtlodYeayI/banpWVo2l16vPwDFbQFWgwmQYLwB N3ZA== 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=xlx4itTMzYZnTqS6gtVBP4dI6YRkemDRngd0L+Y36pA=; b=POkzTOYeuS5YCU5L/zyaugEZsfFxC2XFSyd2uCml1/89ypkZ89OwVVucd6rWbfoKk3 y8jvmUAU2P/qzXoFC0K1Ll8f6EeyEQDakxWlAFgiRe6akFWe5AABeD/glnh7dl835JmW QRXV3WihCry9XmCn9jyoFOhRQcn/tdTk+bIBMF7CajF5U8qsyS/68WU5O7Ekk+mxTSN2 MSwZRuIBVhj/8xhxN2nLnshDsuugfajAEVU2zF7zkvKqFzOvBH/KWKwq3A3UYVeqNwM/ +LQiLS1Z90cY1SobOhr7yuRVlKcrctk4Rnl9VMpAC+gw6crsi/4TulMyQxSB9859635N PYDg== X-Forwarded-Encrypted: i=1; AJvYcCVeMocfCoq7Aiq0A50bzmpe3bFMoeJC1dcVVI/AVLpzXqbmV2KLCc1fuXyxFeIAcaUFMl5dOjhgIk+8gjGB0EGZmF277r9BbxrCEjrR X-Gm-Message-State: AOJu0YzmheeSUSYCLIqzhciOamxb3mo1LSiI49dq0xzt1GYl85i7X9Y5 jCOg3QniHLe3jMN7HbDsDrT9aF5qAkT6B7jkZYihCl6x0jt65xg3 X-Google-Smtp-Source: AGHT+IEgxdOZQ8SuuB7L2mai+DTt6vRJ1eD4V2jED1n2XIMDcZibJjv1XGjkC7o73VBe2Wxz1vDU3Q== X-Received: by 2002:a17:906:f8c5:b0:a55:766b:8caf with SMTP id lh5-20020a170906f8c500b00a55766b8cafmr9485194ejb.6.1713860880537; Tue, 23 Apr 2024 01:28:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:28:00 -0700 (PDT) From: Javier Carrasco Date: Tue, 23 Apr 2024 10:27:45 +0200 Subject: [PATCH 2/2] cpufreq: dt-platdev: eliminate uses of of_node_put() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240423-of_node_put_cpufreq_dt-v1-2-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=1568; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=W8LjUVAmqv/G+B+i2P0GUBDI1TRWfOmtY46AfJi9z+o=; b=6R9d+vfyMbyfOyLA9B2PJLd8ar7A3d0KSveYfeHYcYbckLNjFMi9yvKi0egueBJEojM7rEHLB F4e5COJCckIBtUCbTy77x3J4zH7004A+ZiPQBv/VKtVTjhiBZoujEwg 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/cpufreq-dt-platdev.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index 86d8baa81679..c74dd1e01e0d 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c @@ -198,19 +198,18 @@ static const struct of_device_id blocklist[] __initconst = { static bool __init cpu0_node_has_opp_v2_prop(void) { - struct device_node *np = of_cpu_device_node_get(0); + struct device_node *np __free(device_node) = of_cpu_device_node_get(0); bool ret = false; if (of_property_present(np, "operating-points-v2")) ret = true; - of_node_put(np); return ret; } static int __init cpufreq_dt_platdev_init(void) { - struct device_node *np = of_find_node_by_path("/"); + struct device_node *np __free(device_node) = of_find_node_by_path("/"); const struct of_device_id *match; const void *data = NULL; @@ -226,11 +225,9 @@ static int __init cpufreq_dt_platdev_init(void) if (cpu0_node_has_opp_v2_prop() && !of_match_node(blocklist, np)) goto create_pdev; - of_node_put(np); return -ENODEV; create_pdev: - of_node_put(np); return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt", -1, data, sizeof(struct cpufreq_dt_platform_data)));