Commit 4e807eb0 authored by Rob Herring's avatar Rob Herring Committed by Xu Yilun

fpga: 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.

Also drop of_match_ptr for xlnx_pr_decoupler_of_match, which is not
necessary because DT is always used for this driver.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarXu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20231006224633.445035-1-robh@kernel.org
[yilun.xu@intel.com: merge the fix 20231012192149.1546368-1-robh@kernel.org]
Link: https://lore.kernel.org/r/20231012192149.1546368-1-robh@kernel.orgSigned-off-by: default avatarXu Yilun <yilun.xu@linux.intel.com>
parent 6465e260
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_platform.h> #include <linux/of.h>
#include <linux/property.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -127,18 +128,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev) ...@@ -127,18 +128,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct altera_hps2fpga_data *priv; struct altera_hps2fpga_data *priv;
const struct of_device_id *of_id;
struct fpga_bridge *br; struct fpga_bridge *br;
u32 enable; u32 enable;
int ret; int ret;
of_id = of_match_device(altera_fpga_of_match, dev); priv = (struct altera_hps2fpga_data *)device_get_match_data(dev);
if (!of_id) {
dev_err(dev, "failed to match device\n");
return -ENODEV;
}
priv = (struct altera_hps2fpga_data *)of_id->data;
priv->bridge_reset = of_reset_control_get_exclusive_by_index(dev->of_node, priv->bridge_reset = of_reset_control_get_exclusive_by_index(dev->of_node,
0); 0);
......
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/of_device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/fpga/fpga-bridge.h> #include <linux/fpga/fpga-bridge.h>
#define CTRL_CMD_DECOUPLE BIT(0) #define CTRL_CMD_DECOUPLE BIT(0)
...@@ -81,7 +83,6 @@ static const struct fpga_bridge_ops xlnx_pr_decoupler_br_ops = { ...@@ -81,7 +83,6 @@ static const struct fpga_bridge_ops xlnx_pr_decoupler_br_ops = {
.enable_show = xlnx_pr_decoupler_enable_show, .enable_show = xlnx_pr_decoupler_enable_show,
}; };
#ifdef CONFIG_OF
static const struct xlnx_config_data decoupler_config = { static const struct xlnx_config_data decoupler_config = {
.name = "Xilinx PR Decoupler", .name = "Xilinx PR Decoupler",
}; };
...@@ -100,11 +101,9 @@ static const struct of_device_id xlnx_pr_decoupler_of_match[] = { ...@@ -100,11 +101,9 @@ static const struct of_device_id xlnx_pr_decoupler_of_match[] = {
{}, {},
}; };
MODULE_DEVICE_TABLE(of, xlnx_pr_decoupler_of_match); MODULE_DEVICE_TABLE(of, xlnx_pr_decoupler_of_match);
#endif
static int xlnx_pr_decoupler_probe(struct platform_device *pdev) static int xlnx_pr_decoupler_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node;
struct xlnx_pr_decoupler_data *priv; struct xlnx_pr_decoupler_data *priv;
struct fpga_bridge *br; struct fpga_bridge *br;
int err; int err;
...@@ -113,13 +112,7 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev) ...@@ -113,13 +112,7 @@ static int xlnx_pr_decoupler_probe(struct platform_device *pdev)
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
if (np) { priv->ipconfig = device_get_match_data(&pdev->dev);
const struct of_device_id *match;
match = of_match_node(xlnx_pr_decoupler_of_match, np);
if (match && match->data)
priv->ipconfig = match->data;
}
priv->io_base = devm_platform_ioremap_resource(pdev, 0); priv->io_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->io_base)) if (IS_ERR(priv->io_base))
...@@ -174,7 +167,7 @@ static struct platform_driver xlnx_pr_decoupler_driver = { ...@@ -174,7 +167,7 @@ static struct platform_driver xlnx_pr_decoupler_driver = {
.remove = xlnx_pr_decoupler_remove, .remove = xlnx_pr_decoupler_remove,
.driver = { .driver = {
.name = "xlnx_pr_decoupler", .name = "xlnx_pr_decoupler",
.of_match_table = of_match_ptr(xlnx_pr_decoupler_of_match), .of_match_table = xlnx_pr_decoupler_of_match,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment