From patchwork Wed Mar 13 08:36:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 160210 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp14045765jad; Wed, 13 Mar 2019 01:37:11 -0700 (PDT) X-Received: by 2002:a2e:7816:: with SMTP id t22mr597629ljc.25.1552466231467; Wed, 13 Mar 2019 01:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552466231; cv=none; d=google.com; s=arc-20160816; b=G3GVI9OoZi+ROHv01ja8QxLQQ+O6uuzDLnUY0lQf3ZkpYGpguBzudzfSBukaRgrnfO 8didn7o/bKu53HTzw7O7ON2Dv5aYj0sDgyNfSjqWNrLrg3g9lZkaiY/P9/zwciNTZrmY ajK50yONqivTwxjRWrWek0rEXFUl9n6CZy5rEInLCT/w9Zyu9PXITVBjHOYz0/u1fLv6 zy3GbaOsbJFDEp/9w+f31DKXZdy7/T5FhPpHL9iIs8EAWrXO34y9KrBDh2Zlifp1AC3q w4/Wolli5hdxpKRkq+ssLkpWCuKGKeFPhUYq+Ydj5Qzbq+JaDLtRWLh8GLem3zAgPFfk venQ== 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=/i1P7RcZS0nPamy0F7apI0HkwNW2ZATDEDVSzcyhElI=; b=DV5mcsOFQXqZ2zxbi/G6DEVF/K2aifALIu62KDHZmIQ57yDMPu7SQa+UyayTfkz94O zt7nys2rWF/Z9ebxRDszCXmOwSwKlWDARle7D8SJeMPYinGrnh8HaL7ncWchMQ42F50a 4VeyN/jHgJ0R1ENNA/lag89zyAgSGbLphSJPfclyIbI/IL/cX9BPz0yufp1QO7r3stF8 vxE7l9KQtPxWSfRCJOxPcusoQxixKPm+9yMgrszGPCwDtRqJR8Z4Y3dqgT/hXm6UmR8I qfYF33yPr3iZ8bWp5oFuO8SDEFaT03+F9v4RU9Lk4eT80JIaXL61GfCEQ2iDQJyukpXT yYlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LNCVQhFp; 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 f75sor6460073lji.38.2019.03.13.01.37.11 for (Google Transport Security); Wed, 13 Mar 2019 01:37:11 -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=LNCVQhFp; 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=/i1P7RcZS0nPamy0F7apI0HkwNW2ZATDEDVSzcyhElI=; b=LNCVQhFpUnIOYlMOLUOr9mSM5ufWoZgXkbtMcNfVpkPXTftWr8Gw2KduEBb2OJid0k ZgI5gQqetdcd8ZwZ1dlP8lp+5epDmkQqxiM58kUOir8YdPU8LMaLu9ZgY+uGi/9ErKiD zEAy7Ub8jGCrBlsroVQjdMIu8iAXfQhexCgYPSAekZIXCy4cAX3QVSDP3Vf6oS4pm0i7 RFkyE2vlRtqKEUq5AQJgmmnpEzPpn36k1ycO26wqVnn0ANSUeg3NhwmtMtoMy151QESE JJ03Nj4v4PLn9wg+fjV/QDj3/tUG1hFiqfV8AyxkgpkWyB1OCeoj83ql5ucPdrULMyg3 gtcA== 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=/i1P7RcZS0nPamy0F7apI0HkwNW2ZATDEDVSzcyhElI=; b=M88DOkSedDrvf9vh7VtORAQIvN2czrRsBEKiVF8YStVLFDVWBSJTf8+XlTaQFGJg5z coQT+ydN7ICtYvuPNCB2cmI7s1+DeMAIp0Q0zPIXg8PUo9Y/OSnJpW6x0/a5+wrpgvkg ouSmDyxOO0Ia6HeF/i2ESavumYGU4amAFng0xrR1Uu9uYMJczYDfWiLcj1rFqIFShIEw 8+KJ/XV2UKYE2NyM3DAoNvRoQ9e+9J3AW0xKDCydB5xTY8Mn2bmPpVHYBOZKE1fNKksF 7QnAI4iTlbvXh2PEeOrvtxnKhg7gvlSmFVzsV88QahNbFe8MaXrNstznnmWLoLuoY+af Fdkw== X-Gm-Message-State: APjAAAW+RlHy0zdsmC2LDAXajqdT1xCK+arJtIRVUoOg735A0tJ13/IV d4qKWYFrnGfLZTcbCYZtcdfeTu0O X-Google-Smtp-Source: APXvYqyz0xVl/9wVKjxyA7k3YPcw6zwyqcIHTFAw+4Quuz1CFeIEK39/+Z84eyG9JSC3B7vo5kED9Q== X-Received: by 2002:a2e:80cd:: with SMTP id r13mr22164205ljg.34.1552466231095; Wed, 13 Mar 2019 01:37:11 -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 a23sm1707716ljd.20.2019.03.13.01.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Mar 2019 01:37:10 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Lorenzo Pieralisi Cc: Sudeep Holla , Mark Rutland , Daniel Lezcano , Lina Iyer , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 13 Mar 2019 09:36:58 +0100 Message-Id: <20190313083659.7100-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190313083659.7100-1-ulf.hansson@linaro.org> References: <20190313083659.7100-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 Reviewed-by: Daniel Lezcano Acked-by: Lorenzo Pieralisi --- 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 9788bfc1cf8b..e480e0af632c 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -609,9 +609,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 @@ -619,11 +619,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(); } /* @@ -635,9 +631,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"); @@ -661,9 +656,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 = { @@ -678,6 +671,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); @@ -685,7 +679,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