From patchwork Wed Mar 14 16:58:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131684 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410648edg; Wed, 14 Mar 2018 09:59:30 -0700 (PDT) X-Received: by 2002:a19:5c84:: with SMTP id u4-v6mr3875861lfi.14.1521046770122; Wed, 14 Mar 2018 09:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046770; cv=none; d=google.com; s=arc-20160816; b=yWV1R6EN8yzxji6MTE0K8S/gXYg88rA37ox2DTSauogF8iqE1dNP7BgzIgNHS3A1zU 2XvdV34CEn3/NCwYXRu95YLIlkSJMPxLIUUMe3FbKfFREWb/wrDnYm4c+N/H8lLnBx3H U95wAKVH/I4TupCqmsiNajbroUaALjBoI3Jx1TJEAPLb493w8mX7NcKbquXIAPRwGqJv Tcxoio2xWfnmDzMJt1ABI0FPyFQQ3iMkx44bekxm1g1Bnx1u9Bsscdvlsdu+ppIsafdH Zy7q6zES4Zx2+s6Akkp4cdVyhFOaRnwI+Dv2C9sQj1YGDJ0bJWeBKXGAlLUb//0nIRl+ 6hkQ== 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=g6J+Mt0dxNiE2gvJIR0aa/PVw928eU14k0v88Ig1Q0o=; b=MJAehFOk0FUMiIYsv/6bnVVWgbS/W1NFLJ9gRae/Bpyho5P0X3ufe27Ev0qfU6yV8B N/uyOkR8w5VDHI4EFe5/uAFgchOBN81w5hLVSw4HZ8O3djmofZ2ZkArI3a/UUzQCxy7g 3URBI4AGq5O+q0WqIL3Py2dWm1wu1/ELzXE0XYEfcv7ZwM3i5ceJL0jj8uPT5EYMeMBD FNi7Ds/gfWq+ukkrU2v7T7O8oq6DhisuzuhoRt1OxJninkdrxg8/OAhlpPBWXHaUw54M bWzPTTnuuI/7UfCdNPH+ePlkIXlYvO5wRuQ649ZJNAgrPCAs3qwCNao0UdzEAbmKAzeb le2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CYSNVHww; 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 c5-v6sor836570lfh.103.2018.03.14.09.59.30 for (Google Transport Security); Wed, 14 Mar 2018 09:59:30 -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=CYSNVHww; 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=g6J+Mt0dxNiE2gvJIR0aa/PVw928eU14k0v88Ig1Q0o=; b=CYSNVHwwWLQtzkK03Dgssxd1yrghlcrWqI3rCI3Ok/ZY87Lvnut+fwtTlG/5nKtXyl 4t0i6LQMxnOrejUbs6TqRcyjCGogeo8t2JAF+usSQBMelWCuI2QhctPJGCrByU8oKJpC 2jEMPrcQnBSBhHBWV2okjPu4DbhHxbrSieLpY= 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=g6J+Mt0dxNiE2gvJIR0aa/PVw928eU14k0v88Ig1Q0o=; b=pM7Ffc4s8KQi2fl2CD+kap4s7vtFqC8eDQiuiZ+Fq5wIBTsf9kBDBmsSUVWPZabJ6W QZtevZqi/HCBl3TZPiPPVh2IXxT4VtIbQPBb2WejB5vWsma++XktM7hIL869owXoeYQA g03PnfedJpFLHySwadC41UcLTL5kRv8QN3maXjH89NyBdRhU9WFE26M1hcv1M/9xZuwe sAO2vusZMc3gEzyrD2UNWYXb6FWuBn4HuyV5vXj1XQkJ97KCq7dvyo8XYYAdwMXBQjQK 7iRPEMw8XvM0pJdGqPXQXwcR4vhtF/mn9Fk+L09sYkzIv9Fh6H4T55fWaR9JCTJBpOun cfsw== X-Gm-Message-State: AElRT7E5DYPPx+SC+syBBCYt+9oiZXATjKIAmf0Yn0DhqfNBcg8qnlGJ C3/iOQ29nTmnAwg/CgU/F2xN84em X-Google-Smtp-Source: AG47ELu1hIHjEEkW7n3Mgt+GoyhmIf4Xjl4gwwsY2V+IbgyTTjijA1QngaMFXoW2cUBPnSAAH69Nhg== X-Received: by 2002:a19:9a0a:: with SMTP id c10-v6mr4100905lfe.30.1521046769776; Wed, 14 Mar 2018 09:59:29 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:29 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 15/25] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 14 Mar 2018 17:58:25 +0100 Message-Id: <1521046715-30683-16-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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 --- drivers/firmware/psci.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.7.4 Acked-by: Mark Rutland diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 256b4ed..3888100 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/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