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

Configure Feed

Select the types of activity you want to include in your feed.

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>

+11 -31
+2 -11
drivers/net/can/c_can/c_can_platform.c
··· 30 30 #include <linux/io.h> 31 31 #include <linux/platform_device.h> 32 32 #include <linux/pm_runtime.h> 33 + #include <linux/property.h> 33 34 #include <linux/clk.h> 34 35 #include <linux/of.h> 35 - #include <linux/of_device.h> 36 36 #include <linux/mfd/syscon.h> 37 37 #include <linux/regmap.h> 38 38 ··· 259 259 void __iomem *addr; 260 260 struct net_device *dev; 261 261 struct c_can_priv *priv; 262 - const struct of_device_id *match; 263 262 struct resource *mem; 264 263 int irq; 265 264 struct clk *clk; 266 265 const struct c_can_driver_data *drvdata; 267 266 struct device_node *np = pdev->dev.of_node; 268 267 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); 278 269 279 270 /* get the appropriate clk */ 280 271 clk = devm_clk_get(&pdev->dev, NULL);
+2 -10
drivers/net/can/flexcan/flexcan-core.c
··· 23 23 #include <linux/module.h> 24 24 #include <linux/netdevice.h> 25 25 #include <linux/of.h> 26 - #include <linux/of_device.h> 27 26 #include <linux/pinctrl/consumer.h> 28 27 #include <linux/platform_device.h> 29 28 #include <linux/can/platform/flexcan.h> 30 29 #include <linux/pm_runtime.h> 30 + #include <linux/property.h> 31 31 #include <linux/regmap.h> 32 32 #include <linux/regulator/consumer.h> 33 33 ··· 2034 2034 2035 2035 static int flexcan_probe(struct platform_device *pdev) 2036 2036 { 2037 - const struct of_device_id *of_id; 2038 2037 const struct flexcan_devtype_data *devtype_data; 2039 2038 struct net_device *dev; 2040 2039 struct flexcan_priv *priv; ··· 2089 2090 if (IS_ERR(regs)) 2090 2091 return PTR_ERR(regs); 2091 2092 2092 - of_id = of_match_device(flexcan_of_match, &pdev->dev); 2093 - if (of_id) 2094 - devtype_data = of_id->data; 2095 - else if (platform_get_device_id(pdev)->driver_data) 2096 - devtype_data = (struct flexcan_devtype_data *) 2097 - platform_get_device_id(pdev)->driver_data; 2098 - else 2099 - return -ENODEV; 2093 + devtype_data = device_get_match_data(&pdev->dev); 2100 2094 2101 2095 if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) && 2102 2096 !((devtype_data->quirks &
+4 -4
drivers/net/can/mscan/mpc5xxx_can.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/platform_device.h> 15 + #include <linux/property.h> 15 16 #include <linux/netdevice.h> 16 17 #include <linux/can/dev.h> 18 + #include <linux/of.h> 17 19 #include <linux/of_address.h> 18 20 #include <linux/of_irq.h> 19 21 #include <linux/of_platform.h> ··· 292 290 int irq, mscan_clksrc = 0; 293 291 int err = -ENOMEM; 294 292 295 - data = of_device_get_match_data(&ofdev->dev); 293 + data = device_get_match_data(&ofdev->dev); 296 294 if (!data) 297 295 return -EINVAL; 298 296 ··· 353 351 354 352 static void mpc5xxx_can_remove(struct platform_device *ofdev) 355 353 { 356 - const struct of_device_id *match; 357 354 const struct mpc5xxx_can_data *data; 358 355 struct net_device *dev = platform_get_drvdata(ofdev); 359 356 struct mscan_priv *priv = netdev_priv(dev); 360 357 361 - match = of_match_device(mpc5xxx_can_table, &ofdev->dev); 362 - data = match ? match->data : NULL; 358 + data = device_get_match_data(&ofdev->dev); 363 359 364 360 unregister_mscandev(dev); 365 361 if (data && data->put_clock)
+3 -6
drivers/net/can/xilinx_can.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/netdevice.h> 22 22 #include <linux/of.h> 23 - #include <linux/of_device.h> 24 23 #include <linux/platform_device.h> 24 + #include <linux/property.h> 25 25 #include <linux/skbuff.h> 26 26 #include <linux/spinlock.h> 27 27 #include <linux/string.h> ··· 1726 1726 struct net_device *ndev; 1727 1727 struct xcan_priv *priv; 1728 1728 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; 1731 1730 void __iomem *addr; 1732 1731 int ret; 1733 1732 int rx_max, tx_max; ··· 1740 1741 goto err; 1741 1742 } 1742 1743 1743 - of_id = of_match_device(xcan_of_match, &pdev->dev); 1744 - if (of_id && of_id->data) 1745 - devtype = of_id->data; 1744 + devtype = device_get_match_data(&pdev->dev); 1746 1745 1747 1746 hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ? 1748 1747 "tx-mailbox-count" : "tx-fifo-depth";