From patchwork Thu Apr 12 11:14:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133255 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573824ljb; Thu, 12 Apr 2018 04:15:08 -0700 (PDT) X-Received: by 10.46.23.70 with SMTP id l67mr377777lje.132.1523531708418; Thu, 12 Apr 2018 04:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531708; cv=none; d=google.com; s=arc-20160816; b=iC1LGQWh+Cq0esFBnjxankLCPVe46KEjQiAU5f3553yJ5WZNMQChZNp2IxbRnOZQ1F 6BHIoEIJnbAxxfgumNDZY3IfFAI3mXC/HBoBo36cz3b/74RjS3Hp9UE1o8TLPMD/CHL+ gh1X/quNKyusVfalKsjiMysyj01NwuPjEHPkITi7FMrqyYMABjFf7HQ1YPSiUxF8QzLJ T6UxKYTWwhDx0AYxt4iR6NQhVHkPWvX354iKoWN6EEyHzAkJ8vNLRhF+cl1bId5FcfdW cMzqPj2UrZYHMRb8aLAQd+EObGIZfBMWxLsTZriDlniReidGUGSa/OO08aeHKm+yAg27 ERaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=PYhBtjezaaEmZ0eR+XM1owcIpoWo9JIYuOj1ACA+7+s=; b=BIy3vwPgta0fH3jjRzj0jOnn2ABC93yG0cOX7V1kcRqEQKeSujtA9niP7XouNTC4dl ZR5B0uj6LsLU6MNKojsbIbxwqoeY5Hl4LHbQKQVK6N1+6kmwsDVeyGuTS0M17Va3Posf d8bthhpPfqBWD96dXYZWZHDdpa2gJotYoZWKk/TXSqXNHC5sBIj3j/S5/83CrMubMccw 4czPzfgBqdvmb9wU66GbGt52ltnVSAXOYPHG5QcEJakrzQiZt7I2PN6lhCXQNuutHZ7s +0EcfGQNPTxf2uNJQ+3MJckXZn1oXl5iw1Lli/MbKxas/Hw12vzvvFPjoapeTfDKjARR QrHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AmksM3vK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r2sor895606ljg.15.2018.04.12.04.15.08 for (Google Transport Security); Thu, 12 Apr 2018 04:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AmksM3vK; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PYhBtjezaaEmZ0eR+XM1owcIpoWo9JIYuOj1ACA+7+s=; b=AmksM3vKIKxcaI1989QRGc1s0rL3cuveCZnPP1Q/5sNV9Au+FELWq7Wd8JRBrNf3pE itANAQKacs3r3NvniX0BXF74J9KxeRL8IxiEpgHKToQCo4fIAbDk0JD0KT4P6p+kpd5x n9ovGA/hFDxdUgDC62BUwHnO0yyKWTmHtAfBc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PYhBtjezaaEmZ0eR+XM1owcIpoWo9JIYuOj1ACA+7+s=; b=qbEGNzut3OEtAiQLXfOpV240Q72SAmw9oCqS24bRbG7EyXzYGX2MG+omTyRr39Pk3e hTf81AAg4TdqbaPHLUGe9t9k6Im+/1lj8dQBJrBD1bAgfc8ohJq0DjseS/q/enexTXrL xXIcJuGAP9uMSVxwXgti2o37kCmZlcLIcPdpRV9stulvBLbURCKUXJLVbIOMcafY+ev5 NnleCwOofScvCHL2muJnRs30aMx0Qv6sPeoVc+LP4rLKDXmvadovIq3o/0xHf/7xDWEN 5aZI2UkJGsXRwxgSFlYQ7fL8+/thES7b2fuhvry/+ZI/zJn427ifzWUqQhhPWbYlB8+g /HEQ== X-Gm-Message-State: ALQs6tD8U3sDb2EMGb+4YphQN/jZOUBqiw/9fJvKQVFgUzVcdqz87Rg9 SC0D9UiXqLwDIQliPYBEWgJW0Vtj X-Google-Smtp-Source: AIpwx4+jqCTSrlYsj/+p7GfLrjP0akYXKPREuOGasYM4FsAiageLrYjJgIpS8DVsOXZrYoTNezMwow== X-Received: by 10.46.5.200 with SMTP id 191mr429354ljf.8.1523531708214; Thu, 12 Apr 2018 04:15:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:07 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 17/26] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Thu, 12 Apr 2018 13:14:22 +0200 Message-Id: <1523531671-27491-18-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Instead of having each psci init function taking care of the of_node_put(), let's deal with that from psci_dt_init(), as this enables a bit simpler error path for each psci init function. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson Acked-by: Mark Rutland --- drivers/firmware/psci/psci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 256b4ed..3888100 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -608,9 +608,9 @@ static int __init psci_0_2_init(struct device_node *np) int err; err = get_set_conduit_method(np); - if (err) - goto out_put_node; + return err; + /* * Starting with v0.2, the PSCI specification introduced a call * (PSCI_VERSION) that allows probing the firmware version, so @@ -618,11 +618,7 @@ static int __init psci_0_2_init(struct device_node *np) * can be carried out according to the specific version reported * by firmware */ - err = psci_probe(); - -out_put_node: - of_node_put(np); - return err; + return psci_probe(); } /* @@ -634,9 +630,8 @@ static int __init psci_0_1_init(struct device_node *np) int err; err = get_set_conduit_method(np); - if (err) - goto out_put_node; + return err; pr_info("Using PSCI v0.1 Function IDs from DT\n"); @@ -660,9 +655,7 @@ static int __init psci_0_1_init(struct device_node *np) psci_ops.migrate = psci_migrate; } -out_put_node: - of_node_put(np); - return err; + return 0; } static const struct of_device_id psci_of_match[] __initconst = { @@ -677,6 +670,7 @@ int __init psci_dt_init(void) struct device_node *np; const struct of_device_id *matched_np; psci_initcall_t init_fn; + int ret; np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); @@ -684,7 +678,10 @@ int __init psci_dt_init(void) return -ENODEV; init_fn = (psci_initcall_t)matched_np->data; - return init_fn(np); + ret = init_fn(np); + + of_node_put(np); + return ret; } #ifdef CONFIG_ACPI