From patchwork Wed Oct 3 14:38:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 148066 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp6557790lji; Wed, 3 Oct 2018 07:38:58 -0700 (PDT) X-Received: by 2002:a2e:921a:: with SMTP id k26-v6mr1352930ljg.163.1538577538423; Wed, 03 Oct 2018 07:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538577538; cv=none; d=google.com; s=arc-20160816; b=UHzqMTZeZpeE310RNdQqepSMfgmLSkXv0fbRy1AkqMw1t+wsl5+PrB32mX/mdJ6zSE mCHXQAhDWjwB5oKa7sVf0M0z8jnDbSlGeTpV0mi0Gwv5NyIa0G7nSMTo+xKo90HuugnN EwADs4ZTsXwn1aacdB42qy5ddPrdQbOAEo3v7QAqvlusMAT8L0+3mk2YRUk1a32tr8ID eJurNZJfl+I6n/dvhn8rUCh5JEZr7qBtD+TaaUbAn6LXhJ3EgklNSKUJnKgnhVnFHGzg ETFArYr0lHXj9WzpC4zEN7pa6bvBNxpDcosxZrD9Op9CIPMNCfrQPfcxwA83JOtfPh3D bmIA== 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; bh=TjQPuSPVMZIQ7LGnNwV9hx0MvmHHDvnmuj1+IqpIlaE=; b=GKlPTGWvlNpDeEL/RGDSTui8/bvfas/GbXXhsjIOMqOEO765g6L5aWRcB9bcdSTLbU +a0NUehRpg47Y7yfhvAiKQPuqGvdHZvPJMg7OInp2lsZCli4ZuUM8Pva5EgVM3+c0Woj EaJbpK+wNVE3d3w56RP9ne60y6ltVRnZQVrpzX/DfmTpT62wBZJNkCRFYR2lleLhLnVo ubJLX2gT837vPdaMyZgEkFg7daYHrghVimOvJ/LfTSKBMQ7cp2YoUyAFox9gjaQ92W/U 4XnP8zqXsaR/5cdp/e/LUlk4Zfd83USbYe15HhzJgCE0502mFbX+NFDjJC4zGM87sUyX P1Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H0bYXmMh; 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 p5-v6sor626020lfh.24.2018.10.03.07.38.58 for (Google Transport Security); Wed, 03 Oct 2018 07:38:58 -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=H0bYXmMh; 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=H0bYXmMhr8euPxdBpNA9AnsaYn53qUB0wHQFSrgL4hE63SPaGSrM+bC/pMemM+dLTN py83DMk+1hfKAd+qyzkiu7hbKNlnKXbxAjm3A6CitXadRIugK3gAq3twnJdizU/V0oKe 4Zecg7CXLZJ8Q7RDZXZR3GMnGDF/iygCBUGfo= 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=tXyDth7/uJIJcKN7miPa1rZ2rorJIoZ7API2QJEHmLXLI6kY6/A96jMVMq9JEwmJNK e0NiqPUVuUkl/QghfKEdSLXKIzT5iFOmwoidTZ6vem+ZSAl4Y7leuoH3Q/p7319RFmUJ RgwkDwdeCQaBUoOYn+waRMjgj86E5Wp/lytYOO5K3slrbnEbOGL2/eXDvxaxcKMDOUgk z5iWlrkgGYrStIY520cyffdSEc3eZCysmfyP4dF7WcpHeSmLQDZLbGj7fSYrCtBzmgKw RVFjw1qjPHerjy3/HDGavQWR2xPFb3PFazHQuiZhte3iBNahh0vfqay6ELzYbTG0y6+R UxHg== X-Gm-Message-State: ABuFfoi5tso3codFjxwWmR5gArATvPve59NViNLd0glHNChBMA3QIIBZ qcyCu+4dH08hgF9n+NDLFmOj2isU X-Google-Smtp-Source: ACcGV61f5JUyC6umbYRFx0mdAKGPXSoeFi5/0BwWrS2NmAnUsu6nhSdb24pQow20ow245IggCVsDLw== X-Received: by 2002:a19:ca09:: with SMTP id a9-v6mr1159446lfg.149.1538577538176; Wed, 03 Oct 2018 07:38:58 -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 18-v6sm380867ljo.74.2018.10.03.07.38.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:38:57 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Tony Lindgren , Kevin Hilman , Lina Iyer , Ulf Hansson , Rob Herring , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 11/11] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 3 Oct 2018 16:38:24 +0200 Message-Id: <20181003143824.13059-12-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181003143824.13059-1-ulf.hansson@linaro.org> References: <20181003143824.13059-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