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)