From patchwork Tue Jan 31 15:10:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 9547425 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C643F604A0 for ; Tue, 31 Jan 2017 15:11:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8DC92839B for ; Tue, 31 Jan 2017 15:11:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADA73283B3; Tue, 31 Jan 2017 15:11:11 +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=-6.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, 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 E02672839C for ; Tue, 31 Jan 2017 15:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750939AbdAaPLE (ORCPT ); Tue, 31 Jan 2017 10:11:04 -0500 Received: from mail.kernel.org ([198.145.29.136]:50596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750740AbdAaPLD (ORCPT ); Tue, 31 Jan 2017 10:11:03 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F21FD2022A; Tue, 31 Jan 2017 15:10:46 +0000 (UTC) Received: from localhost (173-27-161-33.client.mchsi.com [173.27.161.33]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E7162201EF; Tue, 31 Jan 2017 15:10:45 +0000 (UTC) Subject: [PATCH] PCI: rcar: Check for OF device match early From: Bjorn Helgaas To: Simon Horman Cc: linux-renesas-soc@vger.kernel.org, linux-pci@vger.kernel.org Date: Tue, 31 Jan 2017 09:10:44 -0600 Message-ID: <20170131151044.14062.85997.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A match in the rcar_pcie_of_match[] table is required, so check that first, before we start setting up things that need to be undone if it fails. No functional change intended. Signed-off-by: Bjorn Helgaas --- drivers/pci/host/pcie-rcar.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 0d9b96c3c49d..c91ff0b91be8 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1129,6 +1129,10 @@ static int rcar_pcie_probe(struct platform_device *pdev) int err; int (*hw_init_fn)(struct rcar_pcie *); + of_id = of_match_device(rcar_pcie_of_match, dev); + if (!of_id || !of_id->data) + return -EINVAL; + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); if (!pcie) return -ENOMEM; @@ -1149,11 +1153,6 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (err) return err; - of_id = of_match_device(rcar_pcie_of_match, dev); - if (!of_id || !of_id->data) - return -EINVAL; - hw_init_fn = of_id->data; - pm_runtime_enable(dev); err = pm_runtime_get_sync(dev); if (err < 0) { @@ -1162,6 +1161,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) } /* Failure to get a link might just be that no cards are inserted */ + hw_init_fn = of_id->data; err = hw_init_fn(pcie); if (err) { dev_info(dev, "PCIe link down\n");