net: can: Use device_get_match_data()
Subsystems (5)
PATCH RESEND 1/1 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.
--- drivers/net/can/c_can/c_can_platform.c | 9 +++------ drivers/net/can/flexcan/flexcan-core.c | 9 +++------ drivers/net/can/mscan/mpc5xxx_can.c | 8 ++++---- drivers/net/can/xilinx_can.c | 7 ++----- 4 files changed, 12 insertions(+), 21 deletions(-)
drivers/net/can/c_can/c_can_platform.c +3 -6
@@ -30,9 +30,9 @@#include <linux/io.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/clk.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/mfd/syscon.h> #include <linux/regmap.h>
@@ -259,17 +259,14 @@ static int c_can_plat_probe(struct platform_device *pdev)void __iomem *addr;struct net_device *dev;struct c_can_priv *priv; -const struct of_device_id *match;struct resource *mem;int irq;struct clk *clk;const struct c_can_driver_data *drvdata;struct device_node *np = pdev->dev.of_node; - match =of_match_device (c_can_of_table, &pdev->dev); -if (match) { - drvdata = match->data; - }else if (pdev->id_entry->driver_data) { + drvdata =device_get_match_data (&pdev->dev); +if (!drvdata && pdev->id_entry->driver_data) { drvdata = (struct c_can_driver_data *)platform_get_device_id (pdev)->driver_data; }else {
drivers/net/can/flexcan/flexcan-core.c +3 -6
@@ -23,11 +23,11 @@#include <linux/module.h> #include <linux/netdevice.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/can/platform/flexcan.h> #include <linux/pm_runtime.h> +#include <linux/property.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h>
@@ -2034,7 +2034,6 @@ MODULE_DEVICE_TABLE(platform, flexcan_id_table);static int flexcan_probe (struct platform_device *pdev) { -const struct of_device_id *of_id;const struct flexcan_devtype_data *devtype_data;struct net_device *dev;struct flexcan_priv *priv;
@@ -2090,10 +2089,8 @@ static int flexcan_probe(struct platform_device *pdev)if (IS_ERR (regs))return PTR_ERR (regs); - of_id =of_match_device (flexcan_of_match, &pdev->dev); -if (of_id) - devtype_data = of_id->data; -else if (platform_get_device_id (pdev)->driver_data) + devtype_data =device_get_match_data (&pdev->dev); +if (!devtype_data && pdev->id_entry->driver_data) devtype_data = (struct flexcan_devtype_data *)platform_get_device_id (pdev)->driver_data;else
drivers/net/can/mscan/mpc5xxx_can.c +4 -4
@@ -12,8 +12,10 @@#include <linux/module.h> #include <linux/interrupt.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/netdevice.h> #include <linux/can/dev.h> +#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/of_platform.h>
@@ -290,7 +292,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)int irq, mscan_clksrc =0 ;int err = -ENOMEM ; - data =of_device_get_match_data (&ofdev->dev); + data =device_get_match_data (&ofdev->dev);if (!data)return -EINVAL ;
@@ -351,13 +353,11 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)static void mpc5xxx_can_remove (struct platform_device *ofdev) { -const struct of_device_id *match;const struct mpc5xxx_can_data *data;struct net_device *dev =platform_get_drvdata (ofdev);struct mscan_priv *priv =netdev_priv (dev); - match =of_match_device (mpc5xxx_can_table, &ofdev->dev); - data = match ? match->data :NULL ; + data =device_get_match_data (&ofdev->dev);unregister_mscandev (dev);if (data && data->put_clock)
drivers/net/can/xilinx_can.c +2 -5
@@ -20,8 +20,8 @@#include <linux/module.h> #include <linux/netdevice.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/skbuff.h> #include <linux/spinlock.h> #include <linux/string.h>
@@ -1726,7 +1726,6 @@ static int xcan_probe(struct platform_device *pdev)struct net_device *ndev;struct xcan_priv *priv;struct phy *transceiver; -const struct of_device_id *of_id;const struct xcan_devtype_data *devtype = &xcan_axi_data;void __iomem *addr;int ret;
@@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev) goto err; } - of_id =of_match_device (xcan_of_match, &pdev->dev); -if (of_id && of_id->data) - devtype = of_id->data; + devtype =device_get_match_data (&pdev->dev); hw_tx_max_property = devtype->flags &XCAN_FLAG_TX_MAILBOXES ?"tx-mailbox-count" :"tx-fifo-depth" ;
Signature · 1 line
2.42.0
Simon Horman
reviewerQuoted 5 lines · Rob Herring
Use preferred
device_get_match_data()instead ofof_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]>
...
Quoted 15 lines
drivers/net/can/xilinx_can.c +1
-1@@ -20,8 +20,8 @@#include <linux/module.h> #include <linux/netdevice.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/skbuff.h> #include <linux/spinlock.h> #include <linux/string.h>
drivers/net/can/xilinx_can.c static int xcan_probe(struct platform_device *pdev) · line 1729
Quoted 5 lines
drivers/net/can/xilinx_can.c +0
-1@@ -1726,7 +1726,6 @@ static int xcan_probe(struct platform_device *pdev)struct net_device *ndev;struct xcan_priv *priv;struct phy *transceiver; -const struct of_device_id *of_id;const struct xcan_devtype_data *devtype = &xcan_axi_data;
Hi Rob,
Here devtype is initialised.
drivers/net/can/xilinx_can.c static int xcan_probe(struct platform_device *pdev) · line 1746
Quoted 9 lines
drivers/net/can/xilinx_can.c +0
-3void __iomem *addr;int ret;@@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev) goto err; } - of_id =of_match_device (xcan_of_match, &pdev->dev); -if (of_id && of_id->data) - devtype = of_id->data;
And in the old code devtype was conditionally re-initialised here, if a match with data was found.
But in the new code devtype is re-initialised unconditionally.
Possibly I am missing something obvious, but it seems that either this should somehow be made conditional, or the initialisation to &xcan_axi_data should be dropped.
Quoted 7 lines
drivers/net/can/xilinx_can.c +1
-0+ devtype =device_get_match_data (&pdev->dev); hw_tx_max_property = devtype->flags &XCAN_FLAG_TX_MAILBOXES ?"tx-mailbox-count" :"tx-fifo-depth" ;Signature · 1 line
2.42.0
Quoted 48 lines · Simon Horman
Quoted 5 lines · Rob Herring
Use preferred
device_get_match_data()instead ofof_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]>...
Quoted 15 lines
drivers/net/can/xilinx_can.c +1
-1@@ -20,8 +20,8 @@#include <linux/module.h> #include <linux/netdevice.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/skbuff.h> #include <linux/spinlock.h> #include <linux/string.h> drivers/net/can/xilinx_can.c static int xcan_probe(struct platform_device *pdev) · line 1729
Quoted 5 lines
drivers/net/can/xilinx_can.c +0
-1@@ -1726,7 +1726,6 @@ static int xcan_probe(struct platform_device *pdev)struct net_device *ndev;struct xcan_priv *priv;struct phy *transceiver; -const struct of_device_id *of_id;const struct xcan_devtype_data *devtype = &xcan_axi_data;Hi Rob,
Here devtype is initialised.
drivers/net/can/xilinx_can.c static int xcan_probe(struct platform_device *pdev) · line 1746
Quoted 9 lines
drivers/net/can/xilinx_can.c +0
-3void __iomem *addr;int ret;@@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev) goto err; } - of_id =of_match_device (xcan_of_match, &pdev->dev); -if (of_id && of_id->data) - devtype = of_id->data;And in the old code devtype was conditionally re-initialised here, if a match with data was found.
Quoted 5 lines
But in the new code devtype is re-initialised unconditionally.
Possibly I am missing something obvious, but it seems that either this should somehow be made conditional, or the initialisation to
&xcan_axi_datashould be dropped.
of_match_device() would never fail because we only match with DT for this driver and if we didn't match, we wouldn't be in probe. So I'll drop the initialization.
Rob