From patchwork Wed Apr 10 08:20:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 162005 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5919938jan; Wed, 10 Apr 2019 01:20:47 -0700 (PDT) X-Received: by 2002:ac2:50cb:: with SMTP id h11mr4849570lfm.116.1554884447109; Wed, 10 Apr 2019 01:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554884447; cv=none; d=google.com; s=arc-20160816; b=R1jk4z6RLwSwb8PiL8+tp+RIaIphZkVIxkljX5eUKTxABGqcxJShleZmOsJz3ga2iJ dQBQ2dmkuZ4Y3wcVvsYNMwRLqKbRErmriMt5Rw90DJoON9LnPBFCvgjUihacANnhMTXw TE8PHoWJLpLP1CjryYH6TowBX3OOl3EcLtKLs5uAGolxpKYA2BKoAs3Y2rat43+VBNV0 NdMoGAwCcJf+FviHMKBPOD6SXly67SvtpojgKJrzNLTn0iYL7UzblNQLnIKPqc8RPio9 HTVy11D5MZKSD5IVyjKmuejC6EBH+bMpzh7RRoQxtLjnJCdeqPntQZjGrXHVw+hyjzz8 ATZQ== 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=qq6IHaPYqBd9wX2q5oeOpUTaACkrRt3re3g5q9NXG6GldRaLEtE8v4Q26X+MKTf7N1 i5kkdnRklyTVMkmZdOvW7V77/lcviwPu4cXVrqx6dIuHMjuLtbj3xU6ofU3OhdM9haW/ KGfS+l+S6kRNOxAwW3w5M2A0xrKulWVpGQQ0wRpAIIuGqALlb2YQsnWwP61D/IOl39aJ 6dImV2gsk3kzdsYwOMxzOVI1ChCCaRkmlEkcHMQEN7OOC7N9ZwDJQVhGjTBdVHwCDpld q53EOVOU1hUHoDodj0tw5/i4djKMd0F6kfgmXP3ngbJhmMalNEDGzcGarcdiDf71G9L+ lPPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GP0phiTi; 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 x1sor22560989ljh.3.2019.04.10.01.20.46 for (Google Transport Security); Wed, 10 Apr 2019 01:20:47 -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=GP0phiTi; 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=GP0phiTitWCowgFdyE98UpDaYbbRdaeoGJJFtlBgkRp4GH8FdondGvkhArSSgqgChh coAcL81UNQii/VcyR3SfUb4lM0b3u3BuhrGsuvTFZne8dNwGN6LiXqgB0OD484bWreYy Gu11Lq1vUN0ZujEmNiVdEyBl1qk8maPGU4Mp65929lOH7Flr5GeeUr0/d33cOwaGc/4V c3patnbK1lCK0fpYA1eoj9TQ9bK6rehv5+e735PCgBU4ccnfQmKVvt623oM9i/DZsVsO HRAlJkOYiL1NaTWgbO9B2incA5QF6Gi1mmODDI7eYO6lFoZ32YtKNH8zF5MY77KkKKjq RtIg== 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=RjSYrncf9vK6xl5V4VJKprci0zh7kxQ6h+nR7jZOUA7lpR8cgjoyhfP3pbNsgo9kZK KL3cc+FSoVtJR+nB6fleilXY6iTm4RjUsxDrsujGWDEpcP7PmvztEiynjHkqDOlI9Qtz W+jb2K55okvmKDa3VmUgcMEErcLbsR1lERKuG2e/rKjuW+k2N3HaHgZbqLovbT1MET+5 4ch5ZNOxshGmMCND+sfcNy9eFfeird5ztF0GCH7tt273z9C16drKEnvgPZjk5D5Gn7SD n7Rc/kWtpSrKk5Z281xjd1ORCH2ZKdtE+tWQpP1nirBmlKto+19YL/V2mQLO4c2vZsZy oQzQ== X-Gm-Message-State: APjAAAVbZBP26IN3dp7luA7ktCx98B+Gu4zArtI3uf3HvuHVHgnpoBcn uqOmOYPgeAvLXH9BSuauxbkwU/B9 X-Google-Smtp-Source: APXvYqzXLcsVniYyBVz9bDCydjsovygxv2CXViJzk5qN80M/7XTQHjtC59HgFjstiGB7qIDg0FH3Vw== X-Received: by 2002:a2e:7114:: with SMTP id m20mr22220697ljc.120.1554884446727; Wed, 10 Apr 2019 01:20:46 -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 q6sm3385189lfj.36.2019.04.10.01.20.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 01:20:46 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Lorenzo Pieralisi , Sudeep Holla , Mark Rutland , Daniel Lezcano , Lina Iyer , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH v2 4/5] drivers: firmware: psci: Simplify error path of psci_dt_init() Date: Wed, 10 Apr 2019 10:20:24 +0200 Message-Id: <20190410082025.5989-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190410082025.5989-1-ulf.hansson@linaro.org> References: <20190410082025.5989-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