]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
phy: Use device_get_match_data()
authorRob Herring <robh@kernel.org>
Wed, 17 Sep 2025 13:55:01 +0000 (09:55 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Oct 2025 11:35:43 +0000 (13:35 +0200)
[ Upstream commit 21bf6fc47a1e45031ba8a7084343b7cfd09ed1d3 ]

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>
Stable-dep-of: 64961557efa1 ("phy: ti: omap-usb2: fix device leak at unbind")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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 3b017f20d1742e52e2e76f8f24c35897084dd929..45b366855e80d2d85c506d4ba671b79a07e87033 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 a43df63007c5ccdf3186c59b609df4e43a4adda2..49de0741cdbfa2fda59ac6b6a05fa939a697c845 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 resource *res;
        struct phy *phy;
@@ -182,7 +181,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 95dfa9fd284daf60935731e1f60924d044f609d6..9d227a79139e3795f459af87df84855d2fe58808 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>
 
@@ -172,18 +173,13 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct resource *res;
        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 75216091d90121c6a3a29cbeee51e76bc63c8a3c..c6b4c0b5a6beac4e6bb2cfed39a0fd2ed20d021d 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;
@@ -365,7 +364,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;
 
@@ -379,11 +377,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 47482f106fab34ed0a0438baf6580c07b848374f..1009afc5f42156d3dd9b23914299299acd428cdc 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 59d3a692c72551d5c5918bcfed95f716026c2012..dd55f4db72707589c6dc192278aabc9ba4f5c720 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 a6ca00d240d1b77e1fb35b709eeef8d93ed118ee..9f24db315513d6a5a9c1c24d8d2cb0d822526040 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>
@@ -790,23 +791,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;