Skip to content

Commit 21bf6fc

Browse files
robherringvinodkoul
authored andcommitted
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 <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 7e90937 commit 21bf6fc

File tree

8 files changed

+26
-55
lines changed

8 files changed

+26
-55
lines changed

drivers/phy/broadcom/phy-bcm-ns-usb3.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
#include <linux/iopoll.h>
1717
#include <linux/mdio.h>
1818
#include <linux/module.h>
19+
#include <linux/of.h>
1920
#include <linux/of_address.h>
20-
#include <linux/of_platform.h>
2121
#include <linux/platform_device.h>
2222
#include <linux/phy/phy.h>
23+
#include <linux/property.h>
2324
#include <linux/slab.h>
2425

2526
#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,
189190
static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
190191
{
191192
struct device *dev = &mdiodev->dev;
192-
const struct of_device_id *of_id;
193193
struct phy_provider *phy_provider;
194194
struct device_node *syscon_np;
195195
struct bcm_ns_usb3 *usb3;
@@ -203,10 +203,7 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
203203
usb3->dev = dev;
204204
usb3->mdiodev = mdiodev;
205205

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);
210207

211208
syscon_np = of_parse_phandle(dev->of_node, "usb3-dmp-syscon", 0);
212209
err = of_address_to_resource(syscon_np, 0, &res);

drivers/phy/marvell/phy-berlin-usb.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
#include <linux/io.h>
1010
#include <linux/module.h>
11-
#include <linux/of_device.h>
11+
#include <linux/of.h>
1212
#include <linux/phy/phy.h>
1313
#include <linux/platform_device.h>
14+
#include <linux/property.h>
1415
#include <linux/reset.h>
1516

1617
#define USB_PHY_PLL 0x04
@@ -162,8 +163,6 @@ MODULE_DEVICE_TABLE(of, phy_berlin_usb_of_match);
162163

163164
static int phy_berlin_usb_probe(struct platform_device *pdev)
164165
{
165-
const struct of_device_id *match =
166-
of_match_device(phy_berlin_usb_of_match, &pdev->dev);
167166
struct phy_berlin_usb_priv *priv;
168167
struct phy *phy;
169168
struct phy_provider *phy_provider;
@@ -180,7 +179,7 @@ static int phy_berlin_usb_probe(struct platform_device *pdev)
180179
if (IS_ERR(priv->rst_ctrl))
181180
return PTR_ERR(priv->rst_ctrl);
182181

183-
priv->pll_divider = *((u32 *)match->data);
182+
priv->pll_divider = *((u32 *)device_get_match_data(&pdev->dev));
184183

185184
phy = devm_phy_create(&pdev->dev, NULL, &phy_berlin_usb_ops);
186185
if (IS_ERR(phy)) {

drivers/phy/ralink/phy-ralink-usb.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
#include <linux/mfd/syscon.h>
1414
#include <linux/module.h>
1515
#include <linux/mutex.h>
16-
#include <linux/of_platform.h>
16+
#include <linux/of.h>
1717
#include <linux/phy/phy.h>
1818
#include <linux/platform_device.h>
19+
#include <linux/platform_device.h>
1920
#include <linux/regmap.h>
2021
#include <linux/reset.h>
2122

@@ -171,18 +172,13 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
171172
{
172173
struct device *dev = &pdev->dev;
173174
struct phy_provider *phy_provider;
174-
const struct of_device_id *match;
175175
struct ralink_usb_phy *phy;
176176

177-
match = of_match_device(ralink_usb_phy_of_match, &pdev->dev);
178-
if (!match)
179-
return -ENODEV;
180-
181177
phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
182178
if (!phy)
183179
return -ENOMEM;
184180

185-
phy->clk = (uintptr_t)match->data;
181+
phy->clk = (uintptr_t)device_get_match_data(&pdev->dev);
186182
phy->base = NULL;
187183

188184
phy->sysctl = syscon_regmap_lookup_by_phandle(dev->of_node, "ralink,sysctl");

drivers/phy/rockchip/phy-rockchip-pcie.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
#include <linux/mfd/syscon.h>
1313
#include <linux/module.h>
1414
#include <linux/of.h>
15-
#include <linux/of_address.h>
16-
#include <linux/of_platform.h>
1715
#include <linux/phy/phy.h>
1816
#include <linux/platform_device.h>
17+
#include <linux/property.h>
1918
#include <linux/regmap.h>
2019
#include <linux/reset.h>
2120

@@ -63,7 +62,7 @@ struct rockchip_pcie_data {
6362
};
6463

6564
struct rockchip_pcie_phy {
66-
struct rockchip_pcie_data *phy_data;
65+
const struct rockchip_pcie_data *phy_data;
6766
struct regmap *reg_base;
6867
struct phy_pcie_instance {
6968
struct phy *phy;
@@ -350,7 +349,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
350349
struct rockchip_pcie_phy *rk_phy;
351350
struct phy_provider *phy_provider;
352351
struct regmap *grf;
353-
const struct of_device_id *of_id;
354352
int i;
355353
u32 phy_num;
356354

@@ -364,11 +362,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
364362
if (!rk_phy)
365363
return -ENOMEM;
366364

367-
of_id = of_match_device(rockchip_pcie_phy_dt_ids, &pdev->dev);
368-
if (!of_id)
365+
rk_phy->phy_data = device_get_match_data(&pdev->dev);
366+
if (!rk_phy->phy_data)
369367
return -EINVAL;
370368

371-
rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data;
372369
rk_phy->reg_base = grf;
373370

374371
mutex_init(&rk_phy->pcie_mutex);

drivers/phy/rockchip/phy-rockchip-usb.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
#include <linux/module.h>
1414
#include <linux/mutex.h>
1515
#include <linux/of.h>
16-
#include <linux/of_address.h>
17-
#include <linux/of_platform.h>
1816
#include <linux/phy/phy.h>
1917
#include <linux/platform_device.h>
18+
#include <linux/property.h>
2019
#include <linux/regulator/consumer.h>
2120
#include <linux/reset.h>
2221
#include <linux/regmap.h>
@@ -458,22 +457,19 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
458457
struct device *dev = &pdev->dev;
459458
struct rockchip_usb_phy_base *phy_base;
460459
struct phy_provider *phy_provider;
461-
const struct of_device_id *match;
462460
struct device_node *child;
463461
int err;
464462

465463
phy_base = devm_kzalloc(dev, sizeof(*phy_base), GFP_KERNEL);
466464
if (!phy_base)
467465
return -ENOMEM;
468466

469-
match = of_match_device(dev->driver->of_match_table, dev);
470-
if (!match || !match->data) {
467+
phy_base->pdata = device_get_match_data(dev);
468+
if (!phy_base->pdata) {
471469
dev_err(dev, "missing phy data\n");
472470
return -EINVAL;
473471
}
474472

475-
phy_base->pdata = match->data;
476-
477473
phy_base->dev = dev;
478474
phy_base->reg_base = ERR_PTR(-ENODEV);
479475
if (dev->parent && dev->parent->of_node)

drivers/phy/ti/phy-omap-control.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
#include <linux/module.h>
1010
#include <linux/platform_device.h>
11+
#include <linux/property.h>
1112
#include <linux/slab.h>
1213
#include <linux/of.h>
13-
#include <linux/of_device.h>
1414
#include <linux/err.h>
1515
#include <linux/io.h>
1616
#include <linux/clk.h>
@@ -268,20 +268,15 @@ MODULE_DEVICE_TABLE(of, omap_control_phy_id_table);
268268

269269
static int omap_control_phy_probe(struct platform_device *pdev)
270270
{
271-
const struct of_device_id *of_id;
272271
struct omap_control_phy *control_phy;
273272

274-
of_id = of_match_device(omap_control_phy_id_table, &pdev->dev);
275-
if (!of_id)
276-
return -EINVAL;
277-
278273
control_phy = devm_kzalloc(&pdev->dev, sizeof(*control_phy),
279274
GFP_KERNEL);
280275
if (!control_phy)
281276
return -ENOMEM;
282277

283278
control_phy->dev = &pdev->dev;
284-
control_phy->type = *(enum omap_control_phy_type *)of_id->data;
279+
control_phy->type = *(enum omap_control_phy_type *)device_get_match_data(&pdev->dev);
285280

286281
if (control_phy->type == OMAP_CTRL_TYPE_OTGHS) {
287282
control_phy->otghs_control =

drivers/phy/ti/phy-omap-usb2.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/phy/phy.h>
2020
#include <linux/platform_device.h>
2121
#include <linux/pm_runtime.h>
22+
#include <linux/property.h>
2223
#include <linux/regmap.h>
2324
#include <linux/slab.h>
2425
#include <linux/sys_soc.h>
@@ -371,16 +372,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
371372
struct device_node *node = pdev->dev.of_node;
372373
struct device_node *control_node;
373374
struct platform_device *control_pdev;
374-
const struct of_device_id *of_id;
375-
struct usb_phy_data *phy_data;
375+
const struct usb_phy_data *phy_data;
376376

377-
of_id = of_match_device(omap_usb2_id_table, &pdev->dev);
378-
379-
if (!of_id)
377+
phy_data = device_get_match_data(&pdev->dev);
378+
if (!phy_data)
380379
return -EINVAL;
381380

382-
phy_data = (struct usb_phy_data *)of_id->data;
383-
384381
phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
385382
if (!phy)
386383
return -ENOMEM;

drivers/phy/ti/phy-ti-pipe3.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/module.h>
1010
#include <linux/platform_device.h>
11+
#include <linux/property.h>
1112
#include <linux/slab.h>
1213
#include <linux/phy/phy.h>
1314
#include <linux/of.h>
@@ -778,23 +779,16 @@ static int ti_pipe3_probe(struct platform_device *pdev)
778779
struct phy_provider *phy_provider;
779780
struct device *dev = &pdev->dev;
780781
int ret;
781-
const struct of_device_id *match;
782-
struct pipe3_data *data;
782+
const struct pipe3_data *data;
783783

784784
phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
785785
if (!phy)
786786
return -ENOMEM;
787787

788-
match = of_match_device(ti_pipe3_id_table, dev);
789-
if (!match)
788+
data = device_get_match_data(dev);
789+
if (!data)
790790
return -EINVAL;
791791

792-
data = (struct pipe3_data *)match->data;
793-
if (!data) {
794-
dev_err(dev, "no driver data\n");
795-
return -EINVAL;
796-
}
797-
798792
phy->dev = dev;
799793
phy->mode = data->mode;
800794
phy->dpll_map = data->dpll_map;

0 commit comments

Comments
 (0)