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: 10624923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10C6A16B1 for ; Wed, 3 Oct 2018 14:39:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3D2028AF5 for ; Wed, 3 Oct 2018 14:39:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7E5128B10; Wed, 3 Oct 2018 14:39:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A39128AF5 for ; Wed, 3 Oct 2018 14:39:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727484AbeJCV1n (ORCPT ); Wed, 3 Oct 2018 17:27:43 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37731 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbeJCV1k (ORCPT ); Wed, 3 Oct 2018 17:27:40 -0400 Received: by mail-lf1-f68.google.com with SMTP id a82-v6so4339640lfa.4 for ; Wed, 03 Oct 2018 07:38:59 -0700 (PDT) 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=ChvpDpAsKt/lNCU51TiFIxPbKCBtPbAClJlGFGm0vZO7NBAEmbnK27p0y4NxjSGTSH Z1McaLmN9D5RpAe2WosqLkpFO1+m3b1sFKKw1m3cJh6YBeso6XGoyo93Gui1SGm7no8n Q5l5VZhb69P/6om7W+du15uX3KHzJLWpWszZkiBCXRFk05b1c39jPPbN5H4UQEzqwZow vjnTepHuJyTeiplCURpPX8FYF+pWUlwiZ0M9IHz40WKod0SmxUW0L9R5ZD3N7wkay6M4 tOHQlWqtmYpFnRPj60T9sPM73jrSneu3k45DM7aXduewcDLMGdyYr21DG8FrivvkMgh+ UQxQ== X-Gm-Message-State: ABuFfogLvm+1PPrc8giGMBCFcbl6i/KkBIX236iiLR2vsFheWtKwtVrE jME6OrI/zOG7P/5jyYk6ayRtew== 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) 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> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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