From patchwork Fri Aug 16 15:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766486 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 91F4DC531DC for ; Fri, 16 Aug 2024 15:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=q0sK0ufc7qEbd/mn2fdq4hcobz3MRQ2PN+HK1BuFHRw=; b=EKC7Bbe0pxtlzpg8gY/vPsxGff uTtJwsu4XteQl9fBFb69Qui4dAMszyaAjh4LNrJYNGV7OWPH5wlcWa/hXrO9pmjawmS+F1bHi29ul T6B8kJrnHmqyuZLQelM6iyPaP/EMDVWDacXIabAVKzXRjqMYe7RqKomOe5qQ5i/5Asv/GhupwJQdS VZXn0WJfpEInOTWtqfdcO60yHTMDCFz4nlurEv8iFLiJJP4CnWYwQfWup8iZDu2zBYvNuaG4iM4oT P9qQJE2jDhOiQYmPuI5YZeqzLR3l/doQPM/ZXahzTUrEUALs7qhMKbjx9fuKb+ZvvuCx+hohKEJYk UyjIyqXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyb7-0000000DKMj-0Yvx; Fri, 16 Aug 2024 15:10:37 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seya8-0000000DK5c-3XYV for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:09:38 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso15486115e9.1 for ; Fri, 16 Aug 2024 08:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723820975; x=1724425775; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=q0sK0ufc7qEbd/mn2fdq4hcobz3MRQ2PN+HK1BuFHRw=; b=HwgTQNFTjjprQHEdW+d7wIFDTOP2IkgXFE6kvf5rk2JAbPulL9GaS858kmmfFS6k1A 0/C5sGC2wujv3H9qVpta5SrymbDckXXmQ0FVxMparxad1DgsdIyasJGmvLZlH4wFzzzV 9AYyy9bCELWmZvB7uAH3Cl02h0xuhc2tkwGIkKKBuBEBU459lbcCGcG6JEJqW1Iet5ne rjl0KoTk26FdqZU+JegTP/P7Nzmu2PlZbVAR5mymjirMVwxL1LYmfQj0FdghPuS7SjaT dBotEQIh0e1wnufmrXbAVtH0RPvBvdj+PSfiNQVgbSeuQkeHnroY6aoGedNHFHY6ukpA yLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723820975; x=1724425775; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q0sK0ufc7qEbd/mn2fdq4hcobz3MRQ2PN+HK1BuFHRw=; b=bI4urdGgL4Z7b3CoscQPuUmO1KJrNfsnLVCXXrL7Djuq7o6XScwdNPbbrwVKaWUYSa ug6iK7UgAJ+A/3l0LaglTcVmqjjpmRHcKZTh2w1Tc8dgqfiGwdFbIuuMApURQ7fDZaws MGclVsbCosXv/X/2oHuKp7p5MyQlxmbj0WbTDyAL8ObuWV8Lr60VKG0MAEDH3sI0/G8E E2cKJpiqrXbZyvS3JxMQVQD/6h4mEvXA0LK2TsaC9EHovdIg3YoJMQiiAEQgWnFCetBH fP8K16Bj1Ys1T3A89M/wWI6xZUCybo4X1EynMXS6D1yL+j74M3r8ssqvQGY4avkjZX1D ju+g== X-Forwarded-Encrypted: i=1; AJvYcCXSO5qAeshejP8khmADyYcQlR2Ap4k9RdvCsaAvDmJTNNkq0V79dakWTzj4DGsi9Z7UIvoZoWfqb6Uyx5QUFei4mV29uYf/qham6F3RO/Nb0pBcieM= X-Gm-Message-State: AOJu0YwVhBNi+XrzR3+ZyezgCaHctlDyfV+VMXoqjrJ4xipT9YFUj0wj gJCG2AT/5OxaHJdYkprmQ58iFQDosxtK00HDAsAMXSHU6Lj+4SJYSVs9lxaMG1o= X-Google-Smtp-Source: AGHT+IFhP/NIsW9PWfnEcWLqi7chpg87KWhwfD8tKVYrnOj6sJddsAiBh6dq11WCBuqo717hp+HeUw== X-Received: by 2002:a05:600c:444b:b0:426:6320:7ddf with SMTP id 5b1f17b1804b1-429ed7f944bmr19485875e9.35.1723820975298; Fri, 16 Aug 2024 08:09:35 -0700 (PDT) Received: from krzk-bin.. ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3718984993fsm3808758f8f.31.2024.08.16.08.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:09:34 -0700 (PDT) From: Krzysztof Kozlowski To: Ulf Hansson , "Rafael J. Wysocki" , Daniel Lezcano , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 1/4] cpuidle: psci: Simplify with scoped for each OF child loop Date: Fri, 16 Aug 2024 17:09:28 +0200 Message-ID: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_080936_903762_DDDD1B48 X-CRM114-Status: GOOD ( 14.18 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- drivers/cpuidle/cpuidle-psci-domain.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index ea28b73ef3fb..146f97068022 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -142,7 +142,6 @@ static const struct of_device_id psci_of_match[] = { static int psci_cpuidle_domain_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct device_node *node; bool use_osi = psci_has_osi_support(); int ret = 0, pd_count = 0; @@ -153,15 +152,13 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) * Parse child nodes for the "#power-domain-cells" property and * initialize a genpd/genpd-of-provider pair when it's found. */ - for_each_child_of_node(np, node) { + for_each_child_of_node_scoped(np, node) { if (!of_property_present(node, "#power-domain-cells")) continue; ret = psci_pd_init(node, use_osi); - if (ret) { - of_node_put(node); + if (ret) goto exit; - } pd_count++; } From patchwork Fri Aug 16 15:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766493 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 2734BC531DC for ; Fri, 16 Aug 2024 15:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ycsrSNVghYJYo7Kq/sAqp6MnjeFyaL9nJFuFS/dh9Nk=; b=gwSL/p2wtrLRYdQ0ZQIyI64mSP js7fUK5pFzbI+jn+SX3dPWJZ7w45RPAhNfd+bHcmSnbNE523W/QeW5neuZwy/P1okpxk14KRQBzRL 0Ax1/dLvSivjMfz64hYhs7or00O6V/o49qTE3jrccIGfxhUPCap4BVOD25kPBa0hcjU7ABu9Hy9hf 0C0icmW4YcjxW65xMImmT3KPHQNyOg8Px/9+Z5Aj5MZ4RJaTD2NQRL1X1gJKiDJxWYDmsVReJs27q +J9+rFo6VpsosjfRuaJcWPLSxtXhJsb0SR6rck8iV+NxlaLCjvmokEAfnay4ByZwApWnpYC1/gpcS qG6XgfaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seybl-0000000DKYs-1jKH; Fri, 16 Aug 2024 15:11:17 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyaA-0000000DK5t-3eiK for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:09:41 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3718b5e9c4fso914355f8f.0 for ; Fri, 16 Aug 2024 08:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723820977; x=1724425777; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ycsrSNVghYJYo7Kq/sAqp6MnjeFyaL9nJFuFS/dh9Nk=; b=xyvCllSfHZolJ6UK7A0KEJHusyFJaiyglwNdTbFk1xr6z80ASDmPs4GC5Z//AQnfta PYEw/qwjPXC5oA9OgtlifHQZGFC+iOpwVUqKWm61TdtXpb7p49ko4EIxbQof16npGE7b mcKOG42OVnHbYv/R8GDorfMvbSHhjpliimkGd3NWImhvOaSrV/0xPUxbOatfdpmAAbCK mlOc3khO0B/SILf0fmr1SyXZPIi4Y0FTaB86XG0onH525Mbs1aUAKWwX29JXEoUPBmy+ 9TgLjneT25fhcb6b/VNYnlliBELTgAO/SLCMLKawKU+XZgeAlgKhQW3qoORopRaczcLv xdaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723820977; x=1724425777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ycsrSNVghYJYo7Kq/sAqp6MnjeFyaL9nJFuFS/dh9Nk=; b=AetlcZrf4pVSKVS9ZRIbAwR5F0YsEWfMfEQmtb0/5Yze/UnBoyTcUxoGZJlEr/+C66 35GHhX+VGZ/q0oqKfGaxi4l2SRGDipxCcnRPqxmIm4mLFNbaLeJzjzBFPaoVvg5Gj/7R khVoN1Rqho6n05qTA6i3LFyboiT9hoD8nGAR0wTUEG2l3jrOJrqqSvZuE9ciIhT1+bQH s6PxBZ2NBDlnhibqF3+yV+FnJmVkQDI8YNqCLYHasckQaddmMm2vg9eLAvwd49EsM4zi mMPDjWbtI5Bh7j/eB1L/u9q5zlaFSUvxT6LQYauAC18wQecf/gnX4k8haFMmxike+6/U KJ9Q== X-Forwarded-Encrypted: i=1; AJvYcCUauhZKiLKU8v1JaGHth9YljCN6LDy4fgbtrt+BZoEyhEoiP6Z5TLKDKLrvU8ndii8H9B3X+hKanZk2ayqxmlr2cXsAvjAK6ccRrEe5lGAXEfdbRQM= X-Gm-Message-State: AOJu0YzyvY9bc2YOpaYvs4WdyXL5XMTpFhpJ1OO6m74HbleGp9eGMZXP igyy2KPv7W8R+b22AThVbmCCWjMIgeUPN+IW1cgvLyxsg8Q/XKQOqqrwYUbur1Q= X-Google-Smtp-Source: AGHT+IFDGX+GfHixPCgcFALGkNattnCz9fLq1GjkO92ZX/36nvryecE+9MvCeLg53L+RFEWex0FMuw== X-Received: by 2002:a5d:5442:0:b0:371:8c79:73c1 with SMTP id ffacd0b85a97d-37194317aa2mr2276336f8f.2.1723820976767; Fri, 16 Aug 2024 08:09:36 -0700 (PDT) Received: from krzk-bin.. ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3718984993fsm3808758f8f.31.2024.08.16.08.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:09:36 -0700 (PDT) From: Krzysztof Kozlowski To: Ulf Hansson , "Rafael J. Wysocki" , Daniel Lezcano , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 2/4] cpuidle: riscv-sbi: Use scoped device node handling to simplify error paths Date: Fri, 16 Aug 2024 17:09:29 +0200 Message-ID: <20240816150931.142208-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> References: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_080938_940957_022EB468 X-CRM114-Status: GOOD ( 15.73 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/cpuidle/cpuidle-riscv-sbi.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c index a6e123dfe394..5bb3401220d2 100644 --- a/drivers/cpuidle/cpuidle-riscv-sbi.c +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "cpuidle-riscv-sbi: " fmt +#include #include #include #include @@ -236,19 +237,16 @@ static int sbi_cpuidle_dt_init_states(struct device *dev, { struct sbi_cpuidle_data *data = per_cpu_ptr(&sbi_cpuidle_data, cpu); struct device_node *state_node; - struct device_node *cpu_node; u32 *states; int i, ret; - cpu_node = of_cpu_device_node_get(cpu); + struct device_node *cpu_node __free(device_node) = of_cpu_device_node_get(cpu); if (!cpu_node) return -ENODEV; states = devm_kcalloc(dev, state_count, sizeof(*states), GFP_KERNEL); - if (!states) { - ret = -ENOMEM; - goto fail; - } + if (!states) + return -ENOMEM; /* Parse SBI specific details from state DT nodes */ for (i = 1; i < state_count; i++) { @@ -264,10 +262,8 @@ static int sbi_cpuidle_dt_init_states(struct device *dev, pr_debug("sbi-state %#x index %d\n", states[i], i); } - if (i != state_count) { - ret = -ENODEV; - goto fail; - } + if (i != state_count) + return -ENODEV; /* Initialize optional data, used for the hierarchical topology. */ ret = sbi_dt_cpu_init_topology(drv, data, state_count, cpu); @@ -277,10 +273,7 @@ static int sbi_cpuidle_dt_init_states(struct device *dev, /* Store states in the per-cpu struct. */ data->states = states; -fail: - of_node_put(cpu_node); - - return ret; + return 0; } static void sbi_cpuidle_deinit_cpu(int cpu) From patchwork Fri Aug 16 15:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766494 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 188D5C531DC for ; Fri, 16 Aug 2024 15:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=td2rg5GyKlqce51WO+zvnPs34jMkYsAdv+WksjCyFsM=; b=ii3Lbcx23yLfp27Irp0LZOUXzW cKZdbhHL/6ciOxKbHq9sJjj4HzrtKJWlc0XoFRQnENbtnfASuE3fmP39zi9pEHrpfR/V908LJo1ij hHCOhpciQfU0VIO2TwpsvuXKIXGeFrJi5sf5yagffhhWeZG86IB3jeIJ8IX4E34L0EUL8EyY3TjAY CI2XKxWv8/o4BAPAN9D12r7F+MCT3QKJmK5ChF91danDZpJ0FEQfx551635mt8aQ1/xibRZPX30HG 7HaJI8Vz8ToKH/oWcXBlUeMxrxLv1mcluhRP+xagJ2tDoRljn9P2QHIkPMOxIinWBDjXi3z5CAQyc K+1SfA2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seycN-0000000DKhd-2ZE6; Fri, 16 Aug 2024 15:11:55 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyaC-0000000DK6n-1ZPR for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:09:41 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52f025bc147so2499307e87.3 for ; Fri, 16 Aug 2024 08:09:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723820979; x=1724425779; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=td2rg5GyKlqce51WO+zvnPs34jMkYsAdv+WksjCyFsM=; b=bNfNsL9V2FrInMEeMggdtLpO9JhTYBrK4l80P+Jyiowx/byws7KmTXL7V5oNoeO0XR MjpcfiiVZO50ItZ0pEMChBPaKiYQx1PjBs3F3MZRJUIY2pS5Zg7VKnwZjBj1+6AJHGuE WjTbXiANasVieYb0RYT8mCK38FioT1UuC3B/pJ6aeiul7j93QzUhlLOxFKGgSatrIkob J3IjWs7xk/RZZ8DdONVR5Pb7ukEe2Jrg/hL52ANAmoHcZWCQG9D9KjlfxLmQ1aG4VD4C pkJGHN7pgiB5r5WRGHqoPTGekDG/Puy7dSnJc6jaGuUWP4n5l2FeQE996ngTBlMjeC1O lLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723820979; x=1724425779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=td2rg5GyKlqce51WO+zvnPs34jMkYsAdv+WksjCyFsM=; b=NSv7zzMiIMeKXaQt7OXyRoRXQ6ab03M61R37IXpTimf80UiLpNnVh4/I8TxigusGu5 fhLzbRQhYij4Z1isnU0BKJqEgw3y8/rrw/8JwaVqid3z50OEO82nMtiesXWL1VgxugYt wjm7Otp49AzbiJl2hHgOnj/6a6/mXGkfco/3kGOeuF4WZlJgKCqqRJsuNerv5dr9Jnwj d8oAMxP3JmkuZEl7NDzBeOjEbqrtyKDDVMZ9vv+0uUos4F/L+yHLRkK/K2CZU/h4IFXl eOcYuHGATTfVBMnTBFdXfj/SL+GrZ4D8LYWZ3bU9jnoNadYE31G1nqaQMV/h0x/N3BXE 6WJA== X-Forwarded-Encrypted: i=1; AJvYcCUjK329iYy6kDyI0nc6i79LdGpPunpAGnUQEnJR8JHYkMyM03KcixTZI7T7kAmtfaxnVOt/8nW81bs3pLfa7zDF+KlN2In1ewPtgdOSzBnuk9sVY3E= X-Gm-Message-State: AOJu0Yx7xtjnImcu3rl4ukVer5B1AmEPtfqyPF0UjIlRRiloPs0ukATM rr3QxWCh+ERXl2HhZgBBtjqMHCmaMaSPikA3pM+UAFlxFA3cZm/3wxagOswx3sA= X-Google-Smtp-Source: AGHT+IHaJrVe+YG7WrIsIhySz+TrI0z8q1N6+97MbyrpU5ReE7HuOkmva7Y8+xgV05N9m9+gUaX3EQ== X-Received: by 2002:a05:6512:10c2:b0:530:da95:b54c with SMTP id 2adb3069b0e04-5331c6acec2mr2537162e87.23.1723820978496; Fri, 16 Aug 2024 08:09:38 -0700 (PDT) Received: from krzk-bin.. ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3718984993fsm3808758f8f.31.2024.08.16.08.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:09:37 -0700 (PDT) From: Krzysztof Kozlowski To: Ulf Hansson , "Rafael J. Wysocki" , Daniel Lezcano , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 3/4] cpuidle: riscv-sbi: Simplify with scoped for each OF child loop Date: Fri, 16 Aug 2024 17:09:30 +0200 Message-ID: <20240816150931.142208-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> References: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_080940_432039_6A8BA031 X-CRM114-Status: GOOD ( 13.20 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- drivers/cpuidle/cpuidle-riscv-sbi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c index 5bb3401220d2..d228b4d18d56 100644 --- a/drivers/cpuidle/cpuidle-riscv-sbi.c +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c @@ -448,7 +448,6 @@ static void sbi_pd_remove(void) static int sbi_genpd_probe(struct device_node *np) { - struct device_node *node; int ret = 0, pd_count = 0; if (!np) @@ -458,13 +457,13 @@ static int sbi_genpd_probe(struct device_node *np) * Parse child nodes for the "#power-domain-cells" property and * initialize a genpd/genpd-of-provider pair when it's found. */ - for_each_child_of_node(np, node) { + for_each_child_of_node_scoped(np, node) { if (!of_property_present(node, "#power-domain-cells")) continue; ret = sbi_pd_init(node); if (ret) - goto put_node; + goto remove_pd; pd_count++; } @@ -480,8 +479,6 @@ static int sbi_genpd_probe(struct device_node *np) return 0; -put_node: - of_node_put(node); remove_pd: sbi_pd_remove(); pr_err("failed to create CPU PM domains ret=%d\n", ret); From patchwork Fri Aug 16 15:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766495 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 6BEB2C531DC for ; Fri, 16 Aug 2024 15:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MbmbkUcCYIXjsRgrPS/3FHLQvhhOEq6OSnn8VLc5BA8=; b=wJP9Co5g9uzWgh9+UAZ4Ux2/+b 10fhIW0rMj0ZzGc7w8v4mB27wuHqsdn4oDOEyu9gZxs+Iy2PQNORcKbdhL1ZkzH/p/UMTdnZQmBcj hyP6c0Zx0vWgwGZQRxDf3v65+Idu0UyGnumLVEVNUjpsYZkg9N0z7JYiPq3jRyKJmOgxZl4oINVuD XQGX4NggyPdim7+i0g8COFjzvU4Fgj4yOkbXTXS5Mf8u6Y3N4g8WlkpwFXMWqL3i7whe3Kya3OAuc pcKL9b46/NYf2B3LYgTuNzVUMss8bQW864U/Psym8J/PWMkkTq6tRa31zpo998usU/SRc3OBwTInZ 7FkxfGLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyd1-0000000DKtA-26UT; Fri, 16 Aug 2024 15:12:35 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyaE-0000000DK73-1zGN for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:09:43 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52f025ab3a7so2852930e87.2 for ; Fri, 16 Aug 2024 08:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723820980; x=1724425780; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MbmbkUcCYIXjsRgrPS/3FHLQvhhOEq6OSnn8VLc5BA8=; b=mHRvDzTzdgmudZpBGlJEM/ParpBDycNuROUUUVExHq8L2jWios/oHcG9ysS2cICG7N HVKLd/aow6v7op0mdT8r5AeMOGmsNrD8XZoY5ZS7zOm5onLBr8JGi+IYrvLrU6Aslg2O Sle5dYCso2o9YJ+cjvuLF3pVslua6wJQZ8NO+pBf0X6ir7vdBbFFmtXpT/vy7prTgQY3 8Lh6ZGU8yoGEEVDZfoIEjsZ4D0pmGuQvDcx0z5mfNOnsPGHCMH2oOlSvSMJAzLJqCxH2 pNpvnOwDaVSROhWLkfP3lhDXgmR4xoKLb2HP16nrONcHp+Nu+nK+hZYPTFedNBUAR8MJ 0M4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723820980; x=1724425780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbmbkUcCYIXjsRgrPS/3FHLQvhhOEq6OSnn8VLc5BA8=; b=qBA94YhAt46xJfS6Nqh2agQLiOM2eufqeIpnxei0xd05hMxMN2AD+HJ8DCrDAPMgQh 1NTtal7Z18BekP5PrvxvChVgpRjGwmqxNH/BjYhLOw59xgyzNL962CBMPl3xF7LQ9Kfb I85xtJWCJ3eoIN3q2h9VN9rFfHXYGcB0F0nn8OeawOp/k0bza6UEGL/f31lOT9BF7Gs+ Lq0wCgXAbTbqXJOkrQFvLIvt9moKAOcGq/NSefdgPlXJho+F5kdY261iNo2+IjxA2hVO 50p5D/yO7W27bugcrx08NRY2grJRnYO2/TBvv2CvllbPBIoxSIdTvH5rrp9MplozIt7Y 1dqA== X-Forwarded-Encrypted: i=1; AJvYcCW+n1oxjLmJRAh7GFQyWcruEIYATzyKZLE+OePdc/60aW1GaMaE73Md75tGFTzzPaDYiSZhEUQgmL21/XajUZT9cz2AgUEcMJTpMTciU529Wo4B5PQ= X-Gm-Message-State: AOJu0YyJeAU6jWRd5IF3HLS9XLrEs0QdEJsXQXoscs6XBOU+aabu+9+5 FgsoVGMtYpWvmmx42dT4s24Gifc6v8Kdwx9m57WzaOJikkZkAh/5mSvr87y+m/g= X-Google-Smtp-Source: AGHT+IFmY/sEGKzTKMYSCVLBNr0cmG/bAj/lYGZIFzFIBymPr4dUDTzJ6fAp0qTNkGSzAxbZDMsqbw== X-Received: by 2002:a05:6512:239e:b0:52f:c0ee:3b5f with SMTP id 2adb3069b0e04-5331c691494mr2172309e87.10.1723820980087; Fri, 16 Aug 2024 08:09:40 -0700 (PDT) Received: from krzk-bin.. ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3718984993fsm3808758f8f.31.2024.08.16.08.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:09:39 -0700 (PDT) From: Krzysztof Kozlowski To: Ulf Hansson , "Rafael J. Wysocki" , Daniel Lezcano , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Krzysztof Kozlowski Subject: [PATCH 4/4] cpuidle: dt_idle_genpd: Simplify with scoped for each OF child loop Date: Fri, 16 Aug 2024 17:09:31 +0200 Message-ID: <20240816150931.142208-4-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> References: <20240816150931.142208-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_080942_535740_66657E01 X-CRM114-Status: GOOD ( 11.11 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Jonathan Cameron --- drivers/cpuidle/dt_idle_genpd.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/cpuidle/dt_idle_genpd.c b/drivers/cpuidle/dt_idle_genpd.c index 1af63c189039..203e9b754aea 100644 --- a/drivers/cpuidle/dt_idle_genpd.c +++ b/drivers/cpuidle/dt_idle_genpd.c @@ -130,11 +130,10 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np, int dt_idle_pd_init_topology(struct device_node *np) { - struct device_node *node; struct of_phandle_args child, parent; int ret; - for_each_child_of_node(np, node) { + for_each_child_of_node_scoped(np, node) { if (of_parse_phandle_with_args(node, "power-domains", "#power-domain-cells", 0, &parent)) continue; @@ -143,10 +142,8 @@ int dt_idle_pd_init_topology(struct device_node *np) child.args_count = 0; ret = of_genpd_add_subdomain(&parent, &child); of_node_put(parent.np); - if (ret) { - of_node_put(node); + if (ret) return ret; - } } return 0; @@ -154,11 +151,10 @@ int dt_idle_pd_init_topology(struct device_node *np) int dt_idle_pd_remove_topology(struct device_node *np) { - struct device_node *node; struct of_phandle_args child, parent; int ret; - for_each_child_of_node(np, node) { + for_each_child_of_node_scoped(np, node) { if (of_parse_phandle_with_args(node, "power-domains", "#power-domain-cells", 0, &parent)) continue; @@ -167,10 +163,8 @@ int dt_idle_pd_remove_topology(struct device_node *np) child.args_count = 0; ret = of_genpd_remove_subdomain(&parent, &child); of_node_put(parent.np); - if (ret) { - of_node_put(node); + if (ret) return ret; - } } return 0;