mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 20:24:12 +08:00
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>
This commit is contained in:
parent
61c2ef4b6c
commit
5e6c3454b4
@ -30,9 +30,9 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/property.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/mfd/syscon.h>
|
#include <linux/mfd/syscon.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
@ -259,22 +259,13 @@ static int c_can_plat_probe(struct platform_device *pdev)
|
|||||||
void __iomem *addr;
|
void __iomem *addr;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct c_can_priv *priv;
|
struct c_can_priv *priv;
|
||||||
const struct of_device_id *match;
|
|
||||||
struct resource *mem;
|
struct resource *mem;
|
||||||
int irq;
|
int irq;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
const struct c_can_driver_data *drvdata;
|
const struct c_can_driver_data *drvdata;
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
|
|
||||||
match = of_match_device(c_can_of_table, &pdev->dev);
|
drvdata = device_get_match_data(&pdev->dev);
|
||||||
if (match) {
|
|
||||||
drvdata = match->data;
|
|
||||||
} else if (pdev->id_entry->driver_data) {
|
|
||||||
drvdata = (struct c_can_driver_data *)
|
|
||||||
platform_get_device_id(pdev)->driver_data;
|
|
||||||
} else {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get the appropriate clk */
|
/* get the appropriate clk */
|
||||||
clk = devm_clk_get(&pdev->dev, NULL);
|
clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/pinctrl/consumer.h>
|
#include <linux/pinctrl/consumer.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/can/platform/flexcan.h>
|
#include <linux/can/platform/flexcan.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
#include <linux/property.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/regulator/consumer.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)
|
static int flexcan_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct of_device_id *of_id;
|
|
||||||
const struct flexcan_devtype_data *devtype_data;
|
const struct flexcan_devtype_data *devtype_data;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct flexcan_priv *priv;
|
struct flexcan_priv *priv;
|
||||||
@ -2090,14 +2089,7 @@ static int flexcan_probe(struct platform_device *pdev)
|
|||||||
if (IS_ERR(regs))
|
if (IS_ERR(regs))
|
||||||
return PTR_ERR(regs);
|
return PTR_ERR(regs);
|
||||||
|
|
||||||
of_id = of_match_device(flexcan_of_match, &pdev->dev);
|
devtype_data = device_get_match_data(&pdev->dev);
|
||||||
if (of_id)
|
|
||||||
devtype_data = of_id->data;
|
|
||||||
else if (platform_get_device_id(pdev)->driver_data)
|
|
||||||
devtype_data = (struct flexcan_devtype_data *)
|
|
||||||
platform_get_device_id(pdev)->driver_data;
|
|
||||||
else
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&
|
if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) &&
|
||||||
!((devtype_data->quirks &
|
!((devtype_data->quirks &
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/property.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/can/dev.h>
|
#include <linux/can/dev.h>
|
||||||
|
#include <linux/of.h>
|
||||||
#include <linux/of_address.h>
|
#include <linux/of_address.h>
|
||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/of_platform.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 irq, mscan_clksrc = 0;
|
||||||
int err = -ENOMEM;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
data = of_device_get_match_data(&ofdev->dev);
|
data = device_get_match_data(&ofdev->dev);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -351,13 +353,11 @@ exit_unmap_mem:
|
|||||||
|
|
||||||
static void mpc5xxx_can_remove(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;
|
const struct mpc5xxx_can_data *data;
|
||||||
struct net_device *dev = platform_get_drvdata(ofdev);
|
struct net_device *dev = platform_get_drvdata(ofdev);
|
||||||
struct mscan_priv *priv = netdev_priv(dev);
|
struct mscan_priv *priv = netdev_priv(dev);
|
||||||
|
|
||||||
match = of_match_device(mpc5xxx_can_table, &ofdev->dev);
|
data = device_get_match_data(&ofdev->dev);
|
||||||
data = match ? match->data : NULL;
|
|
||||||
|
|
||||||
unregister_mscandev(dev);
|
unregister_mscandev(dev);
|
||||||
if (data && data->put_clock)
|
if (data && data->put_clock)
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/property.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
@ -1726,8 +1726,7 @@ static int xcan_probe(struct platform_device *pdev)
|
|||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
struct xcan_priv *priv;
|
struct xcan_priv *priv;
|
||||||
struct phy *transceiver;
|
struct phy *transceiver;
|
||||||
const struct of_device_id *of_id;
|
const struct xcan_devtype_data *devtype;
|
||||||
const struct xcan_devtype_data *devtype = &xcan_axi_data;
|
|
||||||
void __iomem *addr;
|
void __iomem *addr;
|
||||||
int ret;
|
int ret;
|
||||||
int rx_max, tx_max;
|
int rx_max, tx_max;
|
||||||
@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
of_id = of_match_device(xcan_of_match, &pdev->dev);
|
devtype = device_get_match_data(&pdev->dev);
|
||||||
if (of_id && of_id->data)
|
|
||||||
devtype = of_id->data;
|
|
||||||
|
|
||||||
hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ?
|
hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ?
|
||||||
"tx-mailbox-count" : "tx-fifo-depth";
|
"tx-mailbox-count" : "tx-fifo-depth";
|
||||||
|
Loading…
Reference in New Issue
Block a user