]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: Use device_get_match_data()
authorRob Herring <robh@kernel.org>
Mon, 9 Oct 2023 17:29:10 +0000 (12:29 -0500)
committerVinod Koul <vkoul@kernel.org>
Fri, 13 Oct 2023 10:15:40 +0000 (15:45 +0530)
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20231009172923.2457844-15-robh@kernel.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/broadcom/phy-bcm-ns-usb3.c
drivers/phy/marvell/phy-berlin-usb.c
drivers/phy/ralink/phy-ralink-usb.c
drivers/phy/rockchip/phy-rockchip-pcie.c
drivers/phy/rockchip/phy-rockchip-usb.c
drivers/phy/ti/phy-omap-control.c
drivers/phy/ti/phy-omap-usb2.c
drivers/phy/ti/phy-ti-pipe3.c

index 69584b685edbb7cc1371e6d6f61ce8f313b8c918..2c8b1b7dda5bdc9cb44f5076bd7953c895f7492f 100644 (file)
 #include <linux/iopoll.h>
 #include <linux/mdio.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/phy/phy.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 #define BCM_NS_USB3_PHY_BASE_ADDR_REG  0x1f
@@ -189,7 +190,6 @@ static int bcm_ns_usb3_mdio_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
 static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
 {
        struct device *dev = &mdiodev->dev;
-       const struct of_device_id *of_id;
        struct phy_provider *phy_provider;
        struct device_node *syscon_np;
        struct bcm_ns_usb3 *usb3;
@@ -203,10 +203,7 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
        usb3->dev = dev;
        usb3->mdiodev = mdiodev;
 
-       of_id = of_match_device(bcm_ns_usb3_id_table, dev);
-       if (!of_id)
-               return -EINVAL;
-       usb3->family = (uintptr_t)of_id->data;
+       usb3->family = (enum bcm_ns_family)device_get_match_data(dev);
 
        syscon_np = of_parse_phandle(dev->of_node, "usb3-dmp-syscon", 0);
        err = of_address_to_resource(syscon_np, 0, &res);
index 78ef6ae72a9a7482bde14e69b72ddd8b3b7a8e23..f26bf630da2c9fbad74872d58581fb7dd3944119 100644 (file)
@@ -8,9 +8,10 @@
 
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/reset.h>
 
 #define USB_PHY_PLL            0x04
@@ -162,8 +163,6 @@ MODULE_DEVICE_TABLE(of, phy_berlin_usb_of_match);
 
 static int phy_berlin_usb_probe(struct platform_device *pdev)
 {
-       const struct of_device_id *match =
-               of_match_device(phy_berlin_usb_of_match, &pdev->dev);
        struct phy_berlin_usb_priv *priv;
        struct phy *phy;
        struct phy_provider *phy_provider;
@@ -180,7 +179,7 @@ static int phy_berlin_usb_probe(struct platform_device *pdev)
        if (IS_ERR(priv->rst_ctrl))
                return PTR_ERR(priv->rst_ctrl);
 
-       priv->pll_divider = *((u32 *)match->data);
+       priv->pll_divider = *((u32 *)device_get_match_data(&pdev->dev));
 
        phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops);
        if (IS_ERR(phy)) {
index 2bd8ad2e76eda05f349d6c4dc5cee27a5a7eb605..41bce5290e92207767b97ca3ad3f46fa8e3d4642 100644 (file)
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/of_platform.h>
+#include <linux/of.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 
@@ -171,18 +172,13 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct phy_provider *phy_provider;
-       const struct of_device_id *match;
        struct ralink_usb_phy *phy;
 
-       match = of_match_device(ralink_usb_phy_of_match, &pdev->dev);
-       if (!match)
-               return -ENODEV;
-
        phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
        if (!phy)
                return -ENOMEM;
 
-       phy->clk = (uintptr_t)match->data;
+       phy->clk = (uintptr_t)device_get_match_data(&pdev->dev);
        phy->base = NULL;
 
        phy->sysctl = syscon_regmap_lookup_by_phandle(dev->of_node, "ralink,sysctl");
index 8234b83fdd88c012fdd92f567b3423cfac650036..1bbd6be2a58473db756e85631505bf81bdc29b77 100644 (file)
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 
@@ -63,7 +62,7 @@ struct rockchip_pcie_data {
 };
 
 struct rockchip_pcie_phy {
-       struct rockchip_pcie_data *phy_data;
+       const struct rockchip_pcie_data *phy_data;
        struct regmap *reg_base;
        struct phy_pcie_instance {
                struct phy *phy;
@@ -350,7 +349,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
        struct rockchip_pcie_phy *rk_phy;
        struct phy_provider *phy_provider;
        struct regmap *grf;
-       const struct of_device_id *of_id;
        int i;
        u32 phy_num;
 
@@ -364,11 +362,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 = device_get_match_data(&pdev->dev);
+       if (!rk_phy->phy_data)
                return -EINVAL;
 
-       rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data;
        rk_phy->reg_base = grf;
 
        mutex_init(&rk_phy->pcie_mutex);
index 8454285977ebc17326e406fb749d9cd9a208b0c4..666a896c8f0a08443228914a039b95974e15ba58 100644 (file)
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/reset.h>
 #include <linux/regmap.h>
@@ -458,7 +457,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;
 
@@ -466,14 +464,12 @@ 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) {
+       phy_base->pdata = device_get_match_data(dev);
+       if (!phy_base->pdata) {
                dev_err(dev, "missing phy data\n");
                return -EINVAL;
        }
 
-       phy_base->pdata = match->data;
-
        phy_base->dev = dev;
        phy_base->reg_base = ERR_PTR(-ENODEV);
        if (dev->parent && dev->parent->of_node)
index 76c5595f0859cb2fcd6b4d258e287d06fdda4710..2fdb8f4241c7422e93db3c4cb3fd7968fbf1e152 100644 (file)
@@ -8,9 +8,9 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/clk.h>
@@ -268,20 +268,15 @@ MODULE_DEVICE_TABLE(of, omap_control_phy_id_table);
 
 static int omap_control_phy_probe(struct platform_device *pdev)
 {
-       const struct of_device_id *of_id;
        struct omap_control_phy *control_phy;
 
-       of_id = of_match_device(omap_control_phy_id_table, &pdev->dev);
-       if (!of_id)
-               return -EINVAL;
-
        control_phy = devm_kzalloc(&pdev->dev, sizeof(*control_phy),
                GFP_KERNEL);
        if (!control_phy)
                return -ENOMEM;
 
        control_phy->dev = &pdev->dev;
-       control_phy->type = *(enum omap_control_phy_type *)of_id->data;
+       control_phy->type = *(enum omap_control_phy_type *)device_get_match_data(&pdev->dev);
 
        if (control_phy->type == OMAP_CTRL_TYPE_OTGHS) {
                control_phy->otghs_control =
index 762d3de8b3c530ed5c1c402ae170e27dd841d9a7..dd2913ac0fa28cea0cabf82c491e2ba49dfcb80e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/sys_soc.h>
@@ -371,16 +372,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
        struct device_node *node = pdev->dev.of_node;
        struct device_node *control_node;
        struct platform_device *control_pdev;
-       const struct of_device_id *of_id;
-       struct usb_phy_data *phy_data;
+       const struct usb_phy_data *phy_data;
 
-       of_id = of_match_device(omap_usb2_id_table, &pdev->dev);
-
-       if (!of_id)
+       phy_data = device_get_match_data(&pdev->dev);
+       if (!phy_data)
                return -EINVAL;
 
-       phy_data = (struct usb_phy_data *)of_id->data;
-
        phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
        if (!phy)
                return -ENOMEM;
index 507e1552db5e83a8cc0e5767118a2a73caeba5a3..874c1a25ce36e699049b995ee8fbf347d1303ff3 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/phy/phy.h>
 #include <linux/of.h>
@@ -778,23 +779,16 @@ static int ti_pipe3_probe(struct platform_device *pdev)
        struct phy_provider *phy_provider;
        struct device *dev = &pdev->dev;
        int ret;
-       const struct of_device_id *match;
-       struct pipe3_data *data;
+       const struct pipe3_data *data;
 
        phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
        if (!phy)
                return -ENOMEM;
 
-       match = of_match_device(ti_pipe3_id_table, dev);
-       if (!match)
+       data = device_get_match_data(dev);
+       if (!data)
                return -EINVAL;
 
-       data = (struct pipe3_data *)match->data;
-       if (!data) {
-               dev_err(dev, "no driver data\n");
-               return -EINVAL;
-       }
-
        phy->dev = dev;
        phy->mode = data->mode;
        phy->dpll_map = data->dpll_map;