Skip to content

Commit b037711

Browse files
robherringdavem330
authored andcommitted
net: ethernet: 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]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4d177f4 commit b037711

File tree

13 files changed

+40
-132
lines changed

13 files changed

+40
-132
lines changed

drivers/net/ethernet/altera/altera_tse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ struct altera_tse_private {
472472
/* ethtool msglvl option */
473473
u32 msg_enable;
474474

475-
struct altera_dmaops *dmaops;
475+
const struct altera_dmaops *dmaops;
476476

477477
struct phylink *phylink;
478478
struct phylink_config phylink_config;

drivers/net/ethernet/altera/altera_tse_main.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
#include <linux/mii.h>
3030
#include <linux/mdio/mdio-regmap.h>
3131
#include <linux/netdevice.h>
32-
#include <linux/of_device.h>
32+
#include <linux/of.h>
3333
#include <linux/of_mdio.h>
3434
#include <linux/of_net.h>
35-
#include <linux/of_platform.h>
3635
#include <linux/pcs-lynx.h>
3736
#include <linux/phy.h>
3837
#include <linux/platform_device.h>
38+
#include <linux/property.h>
3939
#include <linux/regmap.h>
4040
#include <linux/skbuff.h>
4141
#include <asm/cacheflush.h>
@@ -82,8 +82,6 @@ MODULE_PARM_DESC(dma_tx_num, "Number of descriptors in the TX list");
8282

8383
#define TXQUEUESTOP_THRESHHOLD 2
8484

85-
static const struct of_device_id altera_tse_ids[];
86-
8785
static inline u32 tse_tx_avail(struct altera_tse_private *priv)
8886
{
8987
return priv->tx_cons + priv->tx_ring_size - priv->tx_prod - 1;
@@ -1133,7 +1131,6 @@ static int request_and_map(struct platform_device *pdev, const char *name,
11331131
*/
11341132
static int altera_tse_probe(struct platform_device *pdev)
11351133
{
1136-
const struct of_device_id *of_id = NULL;
11371134
struct regmap_config pcs_regmap_cfg;
11381135
struct altera_tse_private *priv;
11391136
struct mdio_regmap_config mrc;
@@ -1159,11 +1156,7 @@ static int altera_tse_probe(struct platform_device *pdev)
11591156
priv->dev = ndev;
11601157
priv->msg_enable = netif_msg_init(debug, default_msg_level);
11611158

1162-
of_id = of_match_device(altera_tse_ids, &pdev->dev);
1163-
1164-
if (of_id)
1165-
priv->dmaops = (struct altera_dmaops *)of_id->data;
1166-
1159+
priv->dmaops = device_get_match_data(&pdev->dev);
11671160

11681161
if (priv->dmaops &&
11691162
priv->dmaops->altera_dtype == ALTERA_DTYPE_SGDMA) {

drivers/net/ethernet/amd/xgbe/xgbe-platform.c

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@
123123
#include <linux/io.h>
124124
#include <linux/of.h>
125125
#include <linux/of_net.h>
126-
#include <linux/of_address.h>
127126
#include <linux/of_platform.h>
128-
#include <linux/of_device.h>
129127
#include <linux/clk.h>
130128
#include <linux/property.h>
131129
#include <linux/acpi.h>
@@ -135,17 +133,6 @@
135133
#include "xgbe-common.h"
136134

137135
#ifdef CONFIG_ACPI
138-
static const struct acpi_device_id xgbe_acpi_match[];
139-
140-
static struct xgbe_version_data *xgbe_acpi_vdata(struct xgbe_prv_data *pdata)
141-
{
142-
const struct acpi_device_id *id;
143-
144-
id = acpi_match_device(xgbe_acpi_match, pdata->dev);
145-
146-
return id ? (struct xgbe_version_data *)id->driver_data : NULL;
147-
}
148-
149136
static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
150137
{
151138
struct device *dev = pdata->dev;
@@ -173,29 +160,13 @@ static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
173160
return 0;
174161
}
175162
#else /* CONFIG_ACPI */
176-
static struct xgbe_version_data *xgbe_acpi_vdata(struct xgbe_prv_data *pdata)
177-
{
178-
return NULL;
179-
}
180-
181163
static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
182164
{
183165
return -EINVAL;
184166
}
185167
#endif /* CONFIG_ACPI */
186168

187169
#ifdef CONFIG_OF
188-
static const struct of_device_id xgbe_of_match[];
189-
190-
static struct xgbe_version_data *xgbe_of_vdata(struct xgbe_prv_data *pdata)
191-
{
192-
const struct of_device_id *id;
193-
194-
id = of_match_device(xgbe_of_match, pdata->dev);
195-
196-
return id ? (struct xgbe_version_data *)id->data : NULL;
197-
}
198-
199170
static int xgbe_of_support(struct xgbe_prv_data *pdata)
200171
{
201172
struct device *dev = pdata->dev;
@@ -244,11 +215,6 @@ static struct platform_device *xgbe_of_get_phy_pdev(struct xgbe_prv_data *pdata)
244215
return phy_pdev;
245216
}
246217
#else /* CONFIG_OF */
247-
static struct xgbe_version_data *xgbe_of_vdata(struct xgbe_prv_data *pdata)
248-
{
249-
return NULL;
250-
}
251-
252218
static int xgbe_of_support(struct xgbe_prv_data *pdata)
253219
{
254220
return -EINVAL;
@@ -290,12 +256,6 @@ static struct platform_device *xgbe_get_phy_pdev(struct xgbe_prv_data *pdata)
290256
return phy_pdev;
291257
}
292258

293-
static struct xgbe_version_data *xgbe_get_vdata(struct xgbe_prv_data *pdata)
294-
{
295-
return pdata->use_acpi ? xgbe_acpi_vdata(pdata)
296-
: xgbe_of_vdata(pdata);
297-
}
298-
299259
static int xgbe_platform_probe(struct platform_device *pdev)
300260
{
301261
struct xgbe_prv_data *pdata;
@@ -321,7 +281,7 @@ static int xgbe_platform_probe(struct platform_device *pdev)
321281
pdata->use_acpi = dev->of_node ? 0 : 1;
322282

323283
/* Get the version data */
324-
pdata->vdata = xgbe_get_vdata(pdata);
284+
pdata->vdata = (struct xgbe_version_data *)device_get_match_data(dev);
325285

326286
phy_pdev = xgbe_get_phy_pdev(pdata);
327287
if (!phy_pdev) {

drivers/net/ethernet/apm/xgene/xgene_enet_main.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,6 @@ static int xgene_enet_probe(struct platform_device *pdev)
20182018
struct xgene_enet_pdata *pdata;
20192019
struct device *dev = &pdev->dev;
20202020
void (*link_state)(struct work_struct *);
2021-
const struct of_device_id *of_id;
20222021
int ret;
20232022

20242023
ndev = alloc_etherdev_mqs(sizeof(struct xgene_enet_pdata),
@@ -2039,19 +2038,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
20392038
NETIF_F_GRO |
20402039
NETIF_F_SG;
20412040

2042-
of_id = of_match_device(xgene_enet_of_match, &pdev->dev);
2043-
if (of_id) {
2044-
pdata->enet_id = (uintptr_t)of_id->data;
2045-
}
2046-
#ifdef CONFIG_ACPI
2047-
else {
2048-
const struct acpi_device_id *acpi_id;
2049-
2050-
acpi_id = acpi_match_device(xgene_enet_acpi_match, &pdev->dev);
2051-
if (acpi_id)
2052-
pdata->enet_id = (enum xgene_enet_id) acpi_id->driver_data;
2053-
}
2054-
#endif
2041+
pdata->enet_id = (enum xgene_enet_id)device_get_match_data(&pdev->dev);
20552042
if (!pdata->enet_id) {
20562043
ret = -ENODEV;
20572044
goto err;

drivers/net/ethernet/apm/xgene/xgene_enet_main.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#include <linux/efi.h>
1616
#include <linux/irq.h>
1717
#include <linux/io.h>
18-
#include <linux/of_platform.h>
18+
#include <linux/of.h>
1919
#include <linux/of_net.h>
2020
#include <linux/of_mdio.h>
21+
#include <linux/platform_device.h>
2122
#include <linux/mdio/mdio-xgene.h>
2223
#include <linux/module.h>
2324
#include <net/ip.h>

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
#include <linux/clk.h>
5353
#include <linux/crc32.h>
5454
#include <linux/platform_device.h>
55+
#include <linux/property.h>
5556
#include <linux/mdio.h>
5657
#include <linux/phy.h>
5758
#include <linux/fec.h>
5859
#include <linux/of.h>
59-
#include <linux/of_device.h>
6060
#include <linux/of_mdio.h>
6161
#include <linux/of_net.h>
6262
#include <linux/regulator/consumer.h>
@@ -4292,14 +4292,13 @@ fec_probe(struct platform_device *pdev)
42924292
phy_interface_t interface;
42934293
struct net_device *ndev;
42944294
int i, irq, ret = 0;
4295-
const struct of_device_id *of_id;
42964295
static int dev_id;
42974296
struct device_node *np = pdev->dev.of_node, *phy_node;
42984297
int num_tx_qs;
42994298
int num_rx_qs;
43004299
char irq_name[8];
43014300
int irq_cnt;
4302-
struct fec_devinfo *dev_info;
4301+
const struct fec_devinfo *dev_info;
43034302

43044303
fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
43054304

@@ -4314,10 +4313,9 @@ fec_probe(struct platform_device *pdev)
43144313
/* setup board info structure */
43154314
fep = netdev_priv(ndev);
43164315

4317-
of_id = of_match_device(fec_dt_ids, &pdev->dev);
4318-
if (of_id)
4319-
pdev->id_entry = of_id->data;
4320-
dev_info = (struct fec_devinfo *)pdev->id_entry->driver_data;
4316+
dev_info = device_get_match_data(&pdev->dev);
4317+
if (!dev_info)
4318+
dev_info = (const struct fec_devinfo *)pdev->id_entry->driver_data;
43214319
if (dev_info)
43224320
fep->quirks = dev_info->quirks;
43234321

drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@
3535
#include <linux/fs.h>
3636
#include <linux/platform_device.h>
3737
#include <linux/phy.h>
38+
#include <linux/property.h>
3839
#include <linux/of.h>
3940
#include <linux/of_mdio.h>
40-
#include <linux/of_platform.h>
41-
#include <linux/of_gpio.h>
4241
#include <linux/of_net.h>
4342
#include <linux/pgtable.h>
4443

@@ -884,9 +883,9 @@ static const struct ethtool_ops fs_ethtool_ops = {
884883
/**************************************************************************************/
885884

886885
#ifdef CONFIG_FS_ENET_HAS_FEC
887-
#define IS_FEC(match) ((match)->data == &fs_fec_ops)
886+
#define IS_FEC(ops) ((ops) == &fs_fec_ops)
888887
#else
889-
#define IS_FEC(match) 0
888+
#define IS_FEC(ops) 0
890889
#endif
891890

892891
static const struct net_device_ops fs_enet_netdev_ops = {
@@ -903,10 +902,9 @@ static const struct net_device_ops fs_enet_netdev_ops = {
903902
#endif
904903
};
905904

906-
static const struct of_device_id fs_enet_match[];
907905
static int fs_enet_probe(struct platform_device *ofdev)
908906
{
909-
const struct of_device_id *match;
907+
const struct fs_ops *ops;
910908
struct net_device *ndev;
911909
struct fs_enet_private *fep;
912910
struct fs_platform_info *fpi;
@@ -916,15 +914,15 @@ static int fs_enet_probe(struct platform_device *ofdev)
916914
const char *phy_connection_type;
917915
int privsize, len, ret = -ENODEV;
918916

919-
match = of_match_device(fs_enet_match, &ofdev->dev);
920-
if (!match)
917+
ops = device_get_match_data(&ofdev->dev);
918+
if (!ops)
921919
return -EINVAL;
922920

923921
fpi = kzalloc(sizeof(*fpi), GFP_KERNEL);
924922
if (!fpi)
925923
return -ENOMEM;
926924

927-
if (!IS_FEC(match)) {
925+
if (!IS_FEC(ops)) {
928926
data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len);
929927
if (!data || len != 4)
930928
goto out_free_fpi;
@@ -986,7 +984,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
986984
fep->dev = &ofdev->dev;
987985
fep->ndev = ndev;
988986
fep->fpi = fpi;
989-
fep->ops = match->data;
987+
fep->ops = ops;
990988

991989
ret = fep->ops->setup_data(ndev);
992990
if (ret)

drivers/net/ethernet/freescale/fs_enet/mii-fec.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
#include <linux/ethtool.h>
3131
#include <linux/bitops.h>
3232
#include <linux/platform_device.h>
33+
#include <linux/property.h>
34+
#include <linux/of.h>
3335
#include <linux/of_address.h>
3436
#include <linux/of_mdio.h>
35-
#include <linux/of_platform.h>
3637
#include <linux/pgtable.h>
3738

3839
#include <asm/irq.h>
@@ -96,20 +97,15 @@ static int fs_enet_fec_mii_write(struct mii_bus *bus, int phy_id, int location,
9697

9798
}
9899

99-
static const struct of_device_id fs_enet_mdio_fec_match[];
100100
static int fs_enet_mdio_probe(struct platform_device *ofdev)
101101
{
102-
const struct of_device_id *match;
103102
struct resource res;
104103
struct mii_bus *new_bus;
105104
struct fec_info *fec;
106105
int (*get_bus_freq)(struct device *);
107106
int ret = -ENOMEM, clock, speed;
108107

109-
match = of_match_device(fs_enet_mdio_fec_match, &ofdev->dev);
110-
if (!match)
111-
return -EINVAL;
112-
get_bus_freq = match->data;
108+
get_bus_freq = device_get_match_data(&ofdev->dev);
113109

114110
new_bus = mdiobus_alloc();
115111
if (!new_bus)

drivers/net/ethernet/freescale/fsl_pq_mdio.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
#include <linux/delay.h>
2020
#include <linux/module.h>
2121
#include <linux/mii.h>
22+
#include <linux/of.h>
2223
#include <linux/of_address.h>
2324
#include <linux/of_mdio.h>
24-
#include <linux/of_device.h>
25+
#include <linux/property.h>
2526

2627
#include <asm/io.h>
2728
#if IS_ENABLED(CONFIG_UCC_GETH)
@@ -407,8 +408,6 @@ static void set_tbipa(const u32 tbipa_val, struct platform_device *pdev,
407408

408409
static int fsl_pq_mdio_probe(struct platform_device *pdev)
409410
{
410-
const struct of_device_id *id =
411-
of_match_device(fsl_pq_mdio_match, &pdev->dev);
412411
const struct fsl_pq_mdio_data *data;
413412
struct device_node *np = pdev->dev.of_node;
414413
struct resource res;
@@ -417,15 +416,12 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
417416
struct mii_bus *new_bus;
418417
int err;
419418

420-
if (!id) {
419+
data = device_get_match_data(&pdev->dev);
420+
if (!data) {
421421
dev_err(&pdev->dev, "Failed to match device\n");
422422
return -ENODEV;
423423
}
424424

425-
data = id->data;
426-
427-
dev_dbg(&pdev->dev, "found %s compatible node\n", id->compatible);
428-
429425
new_bus = mdiobus_alloc_size(sizeof(*priv));
430426
if (!new_bus)
431427
return -ENOMEM;

drivers/net/ethernet/hisilicon/hix5hd2_gmac.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#include <linux/interrupt.h>
88
#include <linux/etherdevice.h>
99
#include <linux/platform_device.h>
10-
#include <linux/of_device.h>
10+
#include <linux/property.h>
11+
#include <linux/of.h>
1112
#include <linux/of_net.h>
1213
#include <linux/of_mdio.h>
1314
#include <linux/reset.h>
@@ -1094,7 +1095,6 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
10941095
{
10951096
struct device *dev = &pdev->dev;
10961097
struct device_node *node = dev->of_node;
1097-
const struct of_device_id *of_id = NULL;
10981098
struct net_device *ndev;
10991099
struct hix5hd2_priv *priv;
11001100
struct mii_bus *bus;
@@ -1110,12 +1110,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
11101110
priv->dev = dev;
11111111
priv->netdev = ndev;
11121112

1113-
of_id = of_match_device(hix5hd2_of_match, dev);
1114-
if (!of_id) {
1115-
ret = -EINVAL;
1116-
goto out_free_netdev;
1117-
}
1118-
priv->hw_cap = (unsigned long)of_id->data;
1113+
priv->hw_cap = (unsigned long)device_get_match_data(dev);
11191114

11201115
priv->base = devm_platform_ioremap_resource(pdev, 0);
11211116
if (IS_ERR(priv->base)) {

0 commit comments

Comments
 (0)