From patchwork Wed Aug 9 09:17:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunfeng Yun X-Patchwork-Id: 9889975 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 A3E7C602D7 for ; Wed, 9 Aug 2017 09:30:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 921B928A47 for ; Wed, 9 Aug 2017 09:30:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86CA828A4F; Wed, 9 Aug 2017 09:30:28 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D46128A49 for ; Wed, 9 Aug 2017 09:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=5RzlfSVzihvl0Yjon04o7vkM1VIWMfWIgKD6l2WJQ7o=; b=a0QmekmG8hKG0o FCopYrDl4JG271PIwoPE5+8qzVDI2/JuDncmGhFtDZvii4ZMscmuWaTP347+8BGxOJ7qBkp4FtykO 1+8hkIn2TQjMJOb5kUoLnx0p5JNJPK+ciniiVH57JpptAhT5A7V+PapiWDvoKe+aANcnWAGPjAGod nfZd4T9ek6ru/b/0uH3to+kSnCQuormIfdhd5snxp66+T9b90YGqP5wTHEdzOAaEcZdRyu3LV4YCI F6euHo9Zzfab5EZaFMe2+bvTE0CMcz6hjOXpicXoJmoVJ9TOfWwifRT9te7pkgM2cM0AuZVzhxD7k wkmY5R1x7kUuCl5xx6Dg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dfNJr-0001B3-3L; Wed, 09 Aug 2017 09:30:27 +0000 Received: from [218.249.47.110] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dfNIw-0007Mv-LB; Wed, 09 Aug 2017 09:29:36 +0000 Received: from mtkcas35.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 755999661; Wed, 09 Aug 2017 17:18:09 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 9 Aug 2017 17:18:07 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 9 Aug 2017 17:18:00 +0800 From: Chunfeng Yun To: Kishon Vijay Abraham I Subject: [PATCH 1/4] phy: rockchip: use of_device_get_match_data() Date: Wed, 9 Aug 2017 17:17:57 +0800 Message-ID: <1502270280-13792-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170809_022931_344367_9A5F7458 X-CRM114-Status: GOOD ( 11.52 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Viresh Kumar , Sekhar Nori , Kamil Debski , linux-tegra@vger.kernel.org, Thierry Reding , Vivek Gautam , Sylwester Nawrocki , Baoyou Xie , Lee Jones , linux-samsung-soc@vger.kernel.org, Axel Lin , Krzysztof Kozlowski , Jonathan Hunter , Jaehoon Chung , linux-rockchip@lists.infradead.org, Kukjin Kim , Chunfeng Yun , Arnd Bergmann , Bartlomiej Zolnierkiewicz , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP reduce the boilerplate code to get the specific data Signed-off-by: Chunfeng Yun --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 9 +++------ drivers/phy/rockchip/phy-rockchip-pcie.c | 7 +++---- drivers/phy/rockchip/phy-rockchip-usb.c | 10 +++------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 626883d..c2379b2 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1024,7 +1025,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) struct phy_provider *provider; struct rockchip_usb2phy *rphy; const struct rockchip_usb2phy_cfg *phy_cfgs; - const struct of_device_id *match; unsigned int reg; int index, ret; @@ -1032,11 +1032,9 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) if (!rphy) return -ENOMEM; - match = of_match_device(dev->driver->of_match_table, dev); - if (!match || !match->data) { - dev_err(dev, "phy configs are not assigned!\n"); + phy_cfgs = of_device_get_match_data(dev); + if (!phy_cfgs) return -EINVAL; - } if (!dev->parent || !dev->parent->of_node) return -EINVAL; @@ -1052,7 +1050,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) } rphy->dev = dev; - phy_cfgs = match->data; rphy->chg_state = USB_CHG_STATE_UNDEFINED; rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN; platform_set_drvdata(pdev, rphy); diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c index 6904633..f7dc0d6 100644 --- a/drivers/phy/rockchip/phy-rockchip-pcie.c +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -286,7 +287,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev) struct phy *generic_phy; struct phy_provider *phy_provider; struct regmap *grf; - const struct of_device_id *of_id; grf = syscon_node_to_regmap(dev->parent->of_node); if (IS_ERR(grf)) { @@ -298,11 +298,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev) if (!rk_phy) return -ENOMEM; - of_id = of_match_device(rockchip_pcie_phy_dt_ids, &pdev->dev); - if (!of_id) + rk_phy->phy_data = of_device_get_match_data(dev); + if (!rk_phy->phy_data) return -EINVAL; - rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data; rk_phy->reg_base = grf; rk_phy->phy_rst = devm_reset_control_get(dev, "phy"); diff --git a/drivers/phy/rockchip/phy-rockchip-usb.c b/drivers/phy/rockchip/phy-rockchip-usb.c index 3378eeb..7db1166 100644 --- a/drivers/phy/rockchip/phy-rockchip-usb.c +++ b/drivers/phy/rockchip/phy-rockchip-usb.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -417,7 +418,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct rockchip_usb_phy_base *phy_base; struct phy_provider *phy_provider; - const struct of_device_id *match; struct device_node *child; int err; @@ -425,13 +425,9 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) if (!phy_base) return -ENOMEM; - match = of_match_device(dev->driver->of_match_table, dev); - if (!match || !match->data) { - dev_err(dev, "missing phy data\n"); + phy_base->pdata = of_device_get_match_data(dev); + if (!phy_base->pdata) return -EINVAL; - } - - phy_base->pdata = match->data; phy_base->dev = dev; phy_base->reg_base = ERR_PTR(-ENODEV);