Skip to content

Commit 5e6c345

Browse files
committed
net: can: 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. Error checking for matching and match data was not necessary as matching is always successful if we're already in probe and the match tables always have data pointers. Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 61c2ef4 commit 5e6c345

File tree

4 files changed

+11
-31
lines changed

4 files changed

+11
-31
lines changed

drivers/net/can/c_can/c_can_platform.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#include <linux/io.h>
3131
#include <linux/platform_device.h>
3232
#include <linux/pm_runtime.h>
33+
#include <linux/property.h>
3334
#include <linux/clk.h>
3435
#include <linux/of.h>
35-
#include <linux/of_device.h>
3636
#include <linux/mfd/syscon.h>
3737
#include <linux/regmap.h>
3838

@@ -259,22 +259,13 @@ static int c_can_plat_probe(struct platform_device *pdev)
259259
void __iomem *addr;
260260
struct net_device *dev;
261261
struct c_can_priv *priv;
262-
const struct of_device_id *match;
263262
struct resource *mem;
264263
int irq;
265264
struct clk *clk;
266265
const struct c_can_driver_data *drvdata;
267266
struct device_node *np = pdev->dev.of_node;
268267

269-
match = of_match_device(c_can_of_table, &pdev->dev);
270-
if (match) {
271-
drvdata = match->data;
272-
} else if (pdev->id_entry->driver_data) {
273-
drvdata = (struct c_can_driver_data *)
274-
platform_get_device_id(pdev)->driver_data;
275-
} else {
276-
return -ENODEV;
277-
}
268+
drvdata = device_get_match_data(&pdev->dev);
278269

279270
/* get the appropriate clk */
280271
clk = devm_clk_get(&pdev->dev, NULL);

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#include <linux/module.h>
2424
#include <linux/netdevice.h>
2525
#include <linux/of.h>
26-
#include <linux/of_device.h>
2726
#include <linux/pinctrl/consumer.h>
2827
#include <linux/platform_device.h>
2928
#include <linux/can/platform/flexcan.h>
3029
#include <linux/pm_runtime.h>
30+
#include <linux/property.h>
3131
#include <linux/regmap.h>
3232
#include <linux/regulator/consumer.h>
3333

@@ -2034,7 +2034,6 @@ MODULE_DEVICE_TABLE(platform, flexcan_id_table);
20342034

20352035
static int flexcan_probe(struct platform_device *pdev)
20362036
{
2037-
const struct of_device_id *of_id;
20382037
const struct flexcan_devtype_data *devtype_data;
20392038
struct net_device *dev;
20402039
struct flexcan_priv *priv;
@@ -2090,14 +2089,7 @@ static int flexcan_probe(struct platform_device *pdev)
20902089
if (IS_ERR(regs))
20912090
return PTR_ERR(regs);
20922091

2093-
of_id = of_match_device(flexcan_of_match, &pdev->dev);
2094-
if (of_id)
2095-
devtype_data = of_id->data;
2096-
else if (platform_get_device_id(pdev)->driver_data)
2097-
devtype_data = (struct flexcan_devtype_data *)
2098-
platform_get_device_id(pdev)->driver_data;
2099-
else
2100-
return -ENODEV;
2092+
devtype_data = device_get_match_data(&pdev->dev);
21012093

21022094
if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&
21032095
!((devtype_data->quirks &

drivers/net/can/mscan/mpc5xxx_can.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#include <linux/module.h>
1313
#include <linux/interrupt.h>
1414
#include <linux/platform_device.h>
15+
#include <linux/property.h>
1516
#include <linux/netdevice.h>
1617
#include <linux/can/dev.h>
18+
#include <linux/of.h>
1719
#include <linux/of_address.h>
1820
#include <linux/of_irq.h>
1921
#include <linux/of_platform.h>
@@ -290,7 +292,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
290292
int irq, mscan_clksrc = 0;
291293
int err = -ENOMEM;
292294

293-
data = of_device_get_match_data(&ofdev->dev);
295+
data = device_get_match_data(&ofdev->dev);
294296
if (!data)
295297
return -EINVAL;
296298

@@ -351,13 +353,11 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
351353

352354
static void mpc5xxx_can_remove(struct platform_device *ofdev)
353355
{
354-
const struct of_device_id *match;
355356
const struct mpc5xxx_can_data *data;
356357
struct net_device *dev = platform_get_drvdata(ofdev);
357358
struct mscan_priv *priv = netdev_priv(dev);
358359

359-
match = of_match_device(mpc5xxx_can_table, &ofdev->dev);
360-
data = match ? match->data : NULL;
360+
data = device_get_match_data(&ofdev->dev);
361361

362362
unregister_mscandev(dev);
363363
if (data && data->put_clock)

drivers/net/can/xilinx_can.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <linux/module.h>
2121
#include <linux/netdevice.h>
2222
#include <linux/of.h>
23-
#include <linux/of_device.h>
2423
#include <linux/platform_device.h>
24+
#include <linux/property.h>
2525
#include <linux/skbuff.h>
2626
#include <linux/spinlock.h>
2727
#include <linux/string.h>
@@ -1726,8 +1726,7 @@ static int xcan_probe(struct platform_device *pdev)
17261726
struct net_device *ndev;
17271727
struct xcan_priv *priv;
17281728
struct phy *transceiver;
1729-
const struct of_device_id *of_id;
1730-
const struct xcan_devtype_data *devtype = &xcan_axi_data;
1729+
const struct xcan_devtype_data *devtype;
17311730
void __iomem *addr;
17321731
int ret;
17331732
int rx_max, tx_max;
@@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev)
17411740
goto err;
17421741
}
17431742

1744-
of_id = of_match_device(xcan_of_match, &pdev->dev);
1745-
if (of_id && of_id->data)
1746-
devtype = of_id->data;
1743+
devtype = device_get_match_data(&pdev->dev);
17471744

17481745
hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ?
17491746
"tx-mailbox-count" : "tx-fifo-depth";

0 commit comments

Comments
 (0)