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: 13766487 X-Patchwork-Delegate: daniel.lezcano@linaro.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 32AC21BCA16 for ; Fri, 16 Aug 2024 15:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820978; cv=none; b=eYcbZz0rd/KChtCTvg0NOp6i833iHRiLRG2wP9LSKC9nE6GvnPqwA7msLRHL54LbDBH/YQB9gg0e67ukv9zrym52f6bFO3i0E/dS0d7+OeMjnGIfE3vLERYszoxsaZjef5Kb0FvIAEtTIEzq5uQO/YpUAUt2Qj8yan/+KiERmy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820978; c=relaxed/simple; bh=XzdvY7dTSy94mw2/rQM0iFi1pa3M0LsbqBKyIiUy9+E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a52hxITVW5TXhhu4AaASBlP7zTwPN8jZoI3m87SZz3XeMEgKVEcbrCujs59ZSrAk2D93rzWRen8AGlELBJKlM4gl39mGs3PvjrLvC/ePNi5FNY0iR1jyYwNXblcawzHmvPHDC/0NnZT/kjNt3Lb7bB+eyDpEFgB0ea+GtiJSSuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=A7EqRt58; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="A7EqRt58" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-428e3129851so15427515e9.3 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=vger.kernel.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=A7EqRt58KZpuu8L6OoagPNaPAUwSjSK232MEGaoWfylAW460Vb00U5ZlN17Upgg8VW G33U4BBxwNrucuhDozqGE/8FQzNi5NFPnld1Z31K6AFMbJAOayEhK6nI0MvIMjHsyu37 D+LFh/Jl2QvqImFpUYU5TvkQHE9nFy+gVkuZ1BhR/PL3tY3iRE+Uz7T3++Qi+pZ8fdlK ywd6SHF++ACZERowTLSQgiWbquKqWgvf04KA9CkSAh37V+BmIM7/gs00KhKcCJk6+gS5 9HAF5BZ483yrDepzc/+ejCdWTvtyVf9Ku86V1yV0edj4hefGl+NOgQ9LKYQoN7no6yGX QB4Q== 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=YlFGUBUIUPOSH88mBTG9SMIsl88vDoghckJ0fgtTNH3roHQUFDU5WI3vCKE6tGBleo lN5kOcNUrG0qAM/Fe1k2zD1IrjMKUzxhdAW5bKZ+Dp3zqVe5noCphGzE2TBGztuxMt6a Tpaiab8gKkhl1EImLsHbb54o48PTRz/aiqVA3e3+/libQNCGQrrYEKhXIOMo0AaLof4f ziO9tF1O2EqKph1v/SRDW8XAFB99XnSSkKbHcRZKyfBPl2QZa0+4Gl4NT9CUHyCcdmC8 aQS49h1/ij0ACywILM7BfanfGGEvq2Ux7iFlE29BeLPSasN/N/B5gCw6pqbaZldygCmL 2pSQ== X-Forwarded-Encrypted: i=1; AJvYcCUztKbTtIlRDtBQAOf46tbOIoyBUb8ePsxUd80dirSztMc+8ZmK6vyd+Oqqb5L51dS+n/M8n0HQpIl0PZG9tU8JFBdcpppXeEs= X-Gm-Message-State: AOJu0Yx7aEX+Mz1kp6DEnq806furuIBrtTnc+AmxW+IX6P5aKrmNu7gf /MXaKZ95tuJ4gduLiOAm34nXhJ2BFGPn9IhZkHKAIoPlA+bPsMDUVbVuvvFqWMtwdkLRrjSIqnj F 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 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13766488 X-Patchwork-Delegate: daniel.lezcano@linaro.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 8B22E817 for ; Fri, 16 Aug 2024 15:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820981; cv=none; b=o32fUDAJf1xvJc5sGWfXlR5XsUEuMOn9zKF9Y2Ey+Zl6VD5ZbfVDWIAszKWTG70HFoTLl3XPFu9/c4L13GPfkIGqAMbd8T/cR+yuv5xrysqhX87pM6Dr5fcee1D8ACtVz0najpuA5PKHdeX2bkBJ6FXqo5r1TnnOKO/1hIqWgos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820981; c=relaxed/simple; bh=DutqlqHE6bdTfzEusV88EvHx97cLnaHqQXNHMGXgdd4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OYPEmFm4Er9F83tht2M+3mOSo/jwY+eCNDbeOZXn8FRCFGGNqzN2phkEQaGB3ABhU5e9eQzriZSX13XoFzV92ARBdbE5MVguDXRFOCWJAtQ3ZRL2gHLnstxK9SUvAMwCQOgEZFaWo2CpN3kIwW/aEQPFlN5pefM3TpfR82MDpY0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=eYx180bK; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="eYx180bK" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-37196681d3bso464113f8f.3 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=vger.kernel.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=eYx180bKiY4F/wON9/KOJ6RD1w+RQZ8Dg2nM/UDNm9Cc39OkfH4ljUt1xp51laaVdv Vu92t6YaDvD6KhjHAJk8STCRVHqltjMrPBivk+v4QTFeG3VUlyfMFslJ81UzRzxVVf2D jMluB0LRmJUzmsPSFNTLhkgH3ujFaBlyiUcmY/ZeF4t6qM3YSs2zFh8V5V9tnr3rPr4d U1Spoy6jTO0nfVkPKxq7RhQuoLOcATOgwku7wufxby+dnDLl6CFQYgIQPMklc2KjIWdn Qf1yowwyM/DjKsV+yS375LfzUxy6GINpXaVV+Wyj+zzAymAP8j4eee5fQm7uXng4mBVW wK0Q== 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=c1ZhDKGMw7/5X2nJYnxVA+tPM0XxtQZadREgAVlzveZsxmHQaQscMZfTRzgIkEQXQu tL5y6NhcYK2ieNkdneGYKcolb89g5vorIKf53W1kG8IHhnCrTjGYXmY0lhQams0pfUOZ 1pGIXyeXZEde+r/KY6p2tw68QZ8KPSLuuwQQkY5d81Ca6HbKP1cXkA4slJM05CSUQrvT Q1Yt7oLtqkHsPCHOAGg7FUBdg8HFILbggk7lQBwKXdU8nPQHZTIm2CWCcvW7QN0/ptn/ T1Xy9Nap3wxMbYY/BRIrc9D+0RmKOmRq1WqHuGtJtomLcaTN1dmAospRcFydsQzwnTZL C4lw== X-Forwarded-Encrypted: i=1; AJvYcCUYI1ky0d5NJGyrU19sVigLDH6s2Z5ttMW3DMQA+CIRWtAMdQod0qXRHPcUkRsTBmERM9jXV0ka9c0omcVfbP/3aysG8NICqpc= X-Gm-Message-State: AOJu0YyW6uwjfuXFuggSUaXnlbeENG5eWIfVAlpleFLibAYUZ7PP+dfE cDzh54Gp+aDwx7WpJfiZ64g1YgfxxrHKzgpPOOqFDV+FG0LEGORzVepLtELEYC4= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13766489 X-Patchwork-Delegate: daniel.lezcano@linaro.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 8A94A1BD502 for ; Fri, 16 Aug 2024 15:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820982; cv=none; b=DWH+IYWDZee005a0vK1RXfFe+axWSeB6IBIZv9ZTLDbaytjLw6sVTHmhR/n7+SkZzwobUPuhFuuoNt6uxOe4k32U4papdmONpS7wyke0YB/yCqDhIDPAJeWLoG297QjFSxAgzABvKDyhIoPJ66+cT6oD2+aRBcJcrP1yZL7buvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820982; c=relaxed/simple; bh=RxdSPEBhE/sg1xbx+aIm2P4PC4lrIxdxMgkdgbz3zms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UAkLhqbv89vr8WmfyXFkl5hVblfgV4+8Sp/Jc1EKALIFatZz02sgkuukUGb6nM0MmHOvr7vM1rJDZFm4mnuUnrym1o9ERC9U9prg+JMGU2s0DddGrZgCq7Fs/8tYjfpzI/cu97Ca+MgBauZUEcd91nxy90GjCOSLsd4vVGFIrKQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LFX/IDR7; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LFX/IDR7" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-52efa16aad9so2644514e87.0 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=vger.kernel.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=LFX/IDR7y2KQlzCCSqNSkqKwRDXFDHjLoYTzz7Te+W6RaRJLDtIe3pd9n5Tg9Kd18A bS+JoYI6hkvCd+er9tRcZR7qKKqNSoSkVsilzUtzRtRISJx8amupJDeqxqc2nUEgcVbx 01NZ77HBu96zR4uOVOe+NVhKKBmY/5+pu5rgt4RMsmSCgbbSCDcImS9a7iQIghP8jvg6 ZTn2EI1Ps/sg8UDft3El8LY0HQVom4ORLrqaKbYJLs3iZbpCqYNb42H0NuJFt+Sfs0lu 1ZeLmsiCNbOk6o5iYGxkvj75shWP0l35gxdzvFc9oq1ampwaO3WBOAy1W8cL59trxM02 Kf5Q== 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=EZau0fblZCxGYJSf6AkDwNg+C02AgClCHmhRKTXzYSwbLKWu8jW/s6F6jT/ZrMq2ID KwfOdqFUvaFUhBgng9qmiHJk6/DpFZ1FAM80919HuzszWvKYMdpbAPNorIxzzUiz6+67 nIAdLcXcu+NL3IF1FVTfWM8CREuRD2XiQtrLLHl9Y4cAgiAwD73dun5y8cqITmBd0Zl+ XWZgke02SBEapbHVI9TMldshko/BCeW0yHcqGepcYjNZ3iMLQG24VhW8G/0NRmiqcArf vlRu+rKI/7yb+V4bk28u8YJYrSja8T1pS4FI6B9FkGLGjhI6Nq64lTmvdlUS7P5yGVzU /vnw== X-Forwarded-Encrypted: i=1; AJvYcCWXuCRI349TxeJcTMzDrgOQT7ZsYqRVC0ENQ5vwwk/d98UnSW2kezne/dzPi9d93nbf43NZo+eqdcy5pRycPsRVjS9x9CczeYU= X-Gm-Message-State: AOJu0YxIsSIFlaWPb7ktJl2VnxRunjGLTnYxGR/GQ9f+MEMVjjycKTKB Wh7d3FSNHCTlmuLyddMbHf7kDBfyw5g+42zeOX/M09i3FFUd0ZdvbkcykQJACMA= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13766490 X-Patchwork-Delegate: daniel.lezcano@linaro.org Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 0BA3A1BDAAD for ; Fri, 16 Aug 2024 15:09:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820983; cv=none; b=UGpqHVqKJyv+juTpjbEEvdSQvlUHVgLECJMozBZT2pFwlnVJ8CEBIuRXN5pNrTbpTzC0343ry3WLr6B+rr8+wP7nrOpAfrUf8qHfIOHVCq70mocPt/RwbwYbDLAe1FgE4DIBeuFXthTuGXyUSWnNJ3w/Ea8DpSVKtkXZQ1V/i0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723820983; c=relaxed/simple; bh=CEjcql4r8jrN0HpKHlQy9SWhvCfWbDDbc0f9H3G2KSE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E2pYVr2KgPAmMRdMV7zCQkS+XfuRsgQ7zDHgr8qEAD9xTbVtBjvsD6GT3OZayEfLZOV/zDbfjgtozCt5i0SHMVx5Tgj42YPDQTH4anNVEfr/Qp34UWaFJXDXpwj8DE0dRK4PB19dSdJq+TYFTql28vTxwHg8nhqg21D+it1ZuEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jlY0dP8G; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jlY0dP8G" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-52efd8807aaso2851012e87.3 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=vger.kernel.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=jlY0dP8Gytm4C5jvW0XvkzV8S7Bv6+nYQ1L0z80eocpVlTKd9f/GJ26nI8jq/5FpR7 JKa/2GY+e2HqZ0b6i7lIqOe7Xsvz9brFsnXAmAFmsw6w54UM2rISmsfbSJ2rJo2Rr2qc bMIEzqnaO3WsNojRZdSGQe5Uj96HSsT4b+eXuV+JtB1ej3n5Q/hV1Vt8tUocgqNMO8GD GFB6Et/SDseXA9isXRCz2WM0gRCN5hy6RRjWaEcCDZAkbyKCN3xK9diH6zZ1IIFrWWug cei0/NMdPyQ6Cfh5lwuCClMrzwGo1RJ63rZ8vhePS5UFKHPUjf++lZetb76Ql5CDc17i h4+g== 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=QWM16gugK45YfEmB0a0vXZq2Fee6VXfKNApJACsqmWtvft48nm7QEjohrfGaCqS8H1 B3iY91w6U64p12skMJvxYIJvFZPdvyivQd+HNtNrg3PWC9+mOVNAQcBaMmfw4L9iqP+Q 56/eJtE9RPVNChoBQin54AlkKtRk03AIm+rZI4isivlv2VGxDyzpJ3VM3BwfcpWefLsB jH6Tt+V1U6yDLl9gjOR3Zzybp7BxPYnrIs0k0m9/vuvrOrqfxX7DzQXQUBQarXt6S8Vg 60rXoahbuaS8UH/W3pnyGI8ytzzLaIpWiOhgI5P0JAVOwXx3ROWSe/8gAkrpGBMKred5 zKCQ== X-Forwarded-Encrypted: i=1; AJvYcCXLCC0tgvdAxDT22xnzLebBwz3e2NWNpwCoti2rAfbGZZ+iQrzhQPzERVhqM+Irv109yYflNxOQvlH5p9wIuRgyiwIqiTP3VAg= X-Gm-Message-State: AOJu0YyUGadt2QKYJuHknuuA7/vNtQSlu8/KYsj8O6kzt13SsptszlIf by6Sq5PtHRutoZJEULS/0LxqLyZbkiKS4tDpmMQ/xXSfj/jKbyv6QslfWt1sXIM= 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> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;