From patchwork Wed Jun 20 17:22:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139385 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050854lji; Wed, 20 Jun 2018 10:23:06 -0700 (PDT) X-Received: by 2002:a19:23cb:: with SMTP id j194-v6mr12121192lfj.90.1529515386412; Wed, 20 Jun 2018 10:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515386; cv=none; d=google.com; s=arc-20160816; b=jaDkBh/1fuQ2tfFSBK+r3aJ5KwIbEn1po0T7J77Zjd3sdsfsQTmsYnR5eSPIWllWfg GJDMcXZ864njivBd54kTT1wK4Yqm5ZnfoBSUysdIUEefLzR9SP1K60oo3SUloKySuzRz F40sS2IsHAwdhbCbS0r1N5hqQ0CtskFI1SagihhOx7WNo/WtG9XhmMNzDOGwrSmi+xBh NRTCxqlMdjFuWbQOg7Zm8xda42lfSJcM59/0J43xTYswkXl0EEdysyuFZcyC3dhs4EmJ 31E4i/ixjRUeKDKJY8myDUH7vQAiez9IJ9VS4Cwg2RK0aqnglpS9Ysz4W5yKHuU70lD1 xjsA== 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=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=EJe6I+cNF7nFtIcL17BDc/zrHRiyQ1P0iyKZtVUO00fNJvHa1h0crvTFhWASjlcBVx xWibMu/BemuvM8+RtIJ2YteHJzGC9gBQZgeqzchV0x0sXAqYZens1m5pXd39l11v6AVv /rTTSgbETVakaqTrjDtyci68qZogFWE3bVY7jQzMyMmOCZc9Kuo+u+GklVwVEKDK2OMV DRvxSUojjW35evy1z0jnlAFlEJRvMYobISVuoXc0A2fl/sCH/OEvPD9ccWiDUHuUBd47 c/iPTyqEDoB8f/4xn6xp3WXeU1G8k+el4UVOUWeuexXv/SnQf7Y/I9Xd4FEZXZCcfzcB kEUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FperrAB5; 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 z8-v6sor721092lji.30.2018.06.20.10.23.06 for (Google Transport Security); Wed, 20 Jun 2018 10:23:06 -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=FperrAB5; 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=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=FperrAB5E7YDSjYoP6q0jhEs2Ox1HY0CxDVeDxyDEatvk5EZ/4z2r8mMTpWW2c/L4s gkPJqTo9YiUfQY1rNcGhu8tbZfXXmVL7mgsOkFqSiSEH03eiQBsLjeQ4zNQ7OebEbRfa U+dUGEMYyssb5EltEDwG3oNn2SDVaeN8eJijM= 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=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=XV0Cg+rl1RlZ8KGJO1fVUe338qFKjx0w4qI0YlVLiISX6e99K/QmseP1bDk89u7FDL tfrrLhXOmD4yg8hAfguycTvZLg7C1khNtGYzCAdsEVky61KUOwnZ7QEkGCUSrWt54p5N DDvLfG1QUKgAu2GRQ+jsWCBiYndm8dQ6toTOEmuLnS9ttil01r1Sv1WfdOrMTDeUFw7T Xb0WsSy+twkdAxF/Ue6HFhnpAkHx13dqKmtJvvU+2BteCh68yyz3bBVVrMMfbZoFY6s1 3dZohR1dZg/xzk7/JCa58M9x9T0j5KmTfocqzu4QIGjUF7qjG0Ur+hvaIdAsVng3alMp 1AiQ== X-Gm-Message-State: APt69E1alT+BOZ95804MK7HW1AITT1sWSxt8htZHTOmfhAvGkvE5wpwN 16eYvpIKUfTxhMcosjPn/AK0rIwh X-Google-Smtp-Source: ADUXVKLqDwiJhzmBIyfbizy0XbX1XsRN+liNcsyiQfmTjx25S14cNOUZ4NdRtHhfg2gbblf3geySsg== X-Received: by 2002:a2e:9ac4:: with SMTP id p4-v6mr14792545ljj.60.1529515386233; Wed, 20 Jun 2018 10:23:06 -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 b2-v6sm514441lji.85.2018.06.20.10.23.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:23:05 -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 v8 17/26] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 20 Jun 2018 19:22:17 +0200 Message-Id: <20180620172226.15012-18-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-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.17.1 diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 256b4edbb20a..38881007584e 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