Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: Use device_get_match_data()

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>

authored by

Rob Herring and committed by
Vinod Koul
21bf6fc4 7e909370

+26 -55
+3 -6
drivers/phy/broadcom/phy-bcm-ns-usb3.c
··· 16 16 #include <linux/iopoll.h> 17 17 #include <linux/mdio.h> 18 18 #include <linux/module.h> 19 + #include <linux/of.h> 19 20 #include <linux/of_address.h> 20 - #include <linux/of_platform.h> 21 21 #include <linux/platform_device.h> 22 22 #include <linux/phy/phy.h> 23 + #include <linux/property.h> 23 24 #include <linux/slab.h> 24 25 25 26 #define BCM_NS_USB3_PHY_BASE_ADDR_REG 0x1f ··· 190 189 static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev) 191 190 { 192 191 struct device *dev = &mdiodev->dev; 193 - const struct of_device_id *of_id; 194 192 struct phy_provider *phy_provider; 195 193 struct device_node *syscon_np; 196 194 struct bcm_ns_usb3 *usb3; ··· 203 203 usb3->dev = dev; 204 204 usb3->mdiodev = mdiodev; 205 205 206 - of_id = of_match_device(bcm_ns_usb3_id_table, dev); 207 - if (!of_id) 208 - return -EINVAL; 209 - usb3->family = (uintptr_t)of_id->data; 206 + usb3->family = (enum bcm_ns_family)device_get_match_data(dev); 210 207 211 208 syscon_np = of_parse_phandle(dev->of_node, "usb3-dmp-syscon", 0); 212 209 err = of_address_to_resource(syscon_np, 0, &res);
+3 -4
drivers/phy/marvell/phy-berlin-usb.c
··· 8 8 9 9 #include <linux/io.h> 10 10 #include <linux/module.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/phy/phy.h> 13 13 #include <linux/platform_device.h> 14 + #include <linux/property.h> 14 15 #include <linux/reset.h> 15 16 16 17 #define USB_PHY_PLL 0x04 ··· 163 162 164 163 static int phy_berlin_usb_probe(struct platform_device *pdev) 165 164 { 166 - const struct of_device_id *match = 167 - of_match_device(phy_berlin_usb_of_match, &pdev->dev); 168 165 struct phy_berlin_usb_priv *priv; 169 166 struct phy *phy; 170 167 struct phy_provider *phy_provider; ··· 179 180 if (IS_ERR(priv->rst_ctrl)) 180 181 return PTR_ERR(priv->rst_ctrl); 181 182 182 - priv->pll_divider = *((u32 *)match->data); 183 + priv->pll_divider = *((u32 *)device_get_match_data(&pdev->dev)); 183 184 184 185 phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops); 185 186 if (IS_ERR(phy)) {
+4 -7
drivers/phy/rockchip/phy-rockchip-pcie.c
··· 12 12 #include <linux/mfd/syscon.h> 13 13 #include <linux/module.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_address.h> 16 - #include <linux/of_platform.h> 17 15 #include <linux/phy/phy.h> 18 16 #include <linux/platform_device.h> 17 + #include <linux/property.h> 19 18 #include <linux/regmap.h> 20 19 #include <linux/reset.h> 21 20 ··· 62 63 }; 63 64 64 65 struct rockchip_pcie_phy { 65 - struct rockchip_pcie_data *phy_data; 66 + const struct rockchip_pcie_data *phy_data; 66 67 struct regmap *reg_base; 67 68 struct phy_pcie_instance { 68 69 struct phy *phy; ··· 349 350 struct rockchip_pcie_phy *rk_phy; 350 351 struct phy_provider *phy_provider; 351 352 struct regmap *grf; 352 - const struct of_device_id *of_id; 353 353 int i; 354 354 u32 phy_num; 355 355 ··· 362 364 if (!rk_phy) 363 365 return -ENOMEM; 364 366 365 - of_id = of_match_device(rockchip_pcie_phy_dt_ids, &pdev->dev); 366 - if (!of_id) 367 + rk_phy->phy_data = device_get_match_data(&pdev->dev); 368 + if (!rk_phy->phy_data) 367 369 return -EINVAL; 368 370 369 - rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data; 370 371 rk_phy->reg_base = grf; 371 372 372 373 mutex_init(&rk_phy->pcie_mutex);
+3 -7
drivers/phy/rockchip/phy-rockchip-usb.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/mutex.h> 15 15 #include <linux/of.h> 16 - #include <linux/of_address.h> 17 - #include <linux/of_platform.h> 18 16 #include <linux/phy/phy.h> 19 17 #include <linux/platform_device.h> 18 + #include <linux/property.h> 20 19 #include <linux/regulator/consumer.h> 21 20 #include <linux/reset.h> 22 21 #include <linux/regmap.h> ··· 457 458 struct device *dev = &pdev->dev; 458 459 struct rockchip_usb_phy_base *phy_base; 459 460 struct phy_provider *phy_provider; 460 - const struct of_device_id *match; 461 461 struct device_node *child; 462 462 int err; 463 463 ··· 464 466 if (!phy_base) 465 467 return -ENOMEM; 466 468 467 - match = of_match_device(dev->driver->of_match_table, dev); 468 - if (!match || !match->data) { 469 + phy_base->pdata = device_get_match_data(dev); 470 + if (!phy_base->pdata) { 469 471 dev_err(dev, "missing phy data\n"); 470 472 return -EINVAL; 471 473 } 472 - 473 - phy_base->pdata = match->data; 474 474 475 475 phy_base->dev = dev; 476 476 phy_base->reg_base = ERR_PTR(-ENODEV);
+2 -7
drivers/phy/ti/phy-omap-control.c
··· 8 8 9 9 #include <linux/module.h> 10 10 #include <linux/platform_device.h> 11 + #include <linux/property.h> 11 12 #include <linux/slab.h> 12 13 #include <linux/of.h> 13 - #include <linux/of_device.h> 14 14 #include <linux/err.h> 15 15 #include <linux/io.h> 16 16 #include <linux/clk.h> ··· 268 268 269 269 static int omap_control_phy_probe(struct platform_device *pdev) 270 270 { 271 - const struct of_device_id *of_id; 272 271 struct omap_control_phy *control_phy; 273 - 274 - of_id = of_match_device(omap_control_phy_id_table, &pdev->dev); 275 - if (!of_id) 276 - return -EINVAL; 277 272 278 273 control_phy = devm_kzalloc(&pdev->dev, sizeof(*control_phy), 279 274 GFP_KERNEL); ··· 276 281 return -ENOMEM; 277 282 278 283 control_phy->dev = &pdev->dev; 279 - control_phy->type = *(enum omap_control_phy_type *)of_id->data; 284 + control_phy->type = *(enum omap_control_phy_type *)device_get_match_data(&pdev->dev); 280 285 281 286 if (control_phy->type == OMAP_CTRL_TYPE_OTGHS) { 282 287 control_phy->otghs_control =
+4 -7
drivers/phy/ti/phy-omap-usb2.c
··· 19 19 #include <linux/phy/phy.h> 20 20 #include <linux/platform_device.h> 21 21 #include <linux/pm_runtime.h> 22 + #include <linux/property.h> 22 23 #include <linux/regmap.h> 23 24 #include <linux/slab.h> 24 25 #include <linux/sys_soc.h> ··· 372 371 struct device_node *node = pdev->dev.of_node; 373 372 struct device_node *control_node; 374 373 struct platform_device *control_pdev; 375 - const struct of_device_id *of_id; 376 - struct usb_phy_data *phy_data; 374 + const struct usb_phy_data *phy_data; 377 375 378 - of_id = of_match_device(omap_usb2_id_table, &pdev->dev); 379 - 380 - if (!of_id) 376 + phy_data = device_get_match_data(&pdev->dev); 377 + if (!phy_data) 381 378 return -EINVAL; 382 - 383 - phy_data = (struct usb_phy_data *)of_id->data; 384 379 385 380 phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL); 386 381 if (!phy)
+4 -10
drivers/phy/ti/phy-ti-pipe3.c
··· 8 8 9 9 #include <linux/module.h> 10 10 #include <linux/platform_device.h> 11 + #include <linux/property.h> 11 12 #include <linux/slab.h> 12 13 #include <linux/phy/phy.h> 13 14 #include <linux/of.h> ··· 779 778 struct phy_provider *phy_provider; 780 779 struct device *dev = &pdev->dev; 781 780 int ret; 782 - const struct of_device_id *match; 783 - struct pipe3_data *data; 781 + const struct pipe3_data *data; 784 782 785 783 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); 786 784 if (!phy) 787 785 return -ENOMEM; 788 786 789 - match = of_match_device(ti_pipe3_id_table, dev); 790 - if (!match) 787 + data = device_get_match_data(dev); 788 + if (!data) 791 789 return -EINVAL; 792 - 793 - data = (struct pipe3_data *)match->data; 794 - if (!data) { 795 - dev_err(dev, "no driver data\n"); 796 - return -EINVAL; 797 - } 798 790 799 791 phy->dev = dev; 800 792 phy->mode = data->mode;