diff options
| author | Wu Hao <[email protected]> | 2019-08-04 10:20:15 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2019-08-05 16:01:24 +0000 |
| commit | 15bbb300fcef4e62e4f6063cc29e698796027b98 (patch) | |
| tree | fa0e0c6ef9da511c4b53d9a447116717956341fa /drivers/fpga/dfl.c | |
| parent | fpga: dfl: afu: add AFU state related sysfs interfaces (diff) | |
| download | kernel-15bbb300fcef4e62e4f6063cc29e698796027b98.tar.gz kernel-15bbb300fcef4e62e4f6063cc29e698796027b98.zip | |
fpga: dfl: add id_table for dfl private feature driver
This patch adds id_table for each dfl private feature driver,
it allows to reuse same private feature driver to match and support
multiple dfl private features.
Signed-off-by: Xu Yilun <[email protected]>
Signed-off-by: Wu Hao <[email protected]>
Acked-by: Moritz Fischer <[email protected]>
Acked-by: Alan Tull <[email protected]>
Signed-off-by: Moritz Fischer <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'drivers/fpga/dfl.c')
| -rw-r--r-- | drivers/fpga/dfl.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index b9137044b667..87eaef6d2723 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -281,6 +281,21 @@ static int dfl_feature_instance_init(struct platform_device *pdev, return ret; } +static bool dfl_feature_drv_match(struct dfl_feature *feature, + struct dfl_feature_driver *driver) +{ + const struct dfl_feature_id *ids = driver->id_table; + + if (ids) { + while (ids->id) { + if (ids->id == feature->id) + return true; + ids++; + } + } + return false; +} + /** * dfl_fpga_dev_feature_init - init for sub features of dfl feature device * @pdev: feature device. @@ -301,8 +316,7 @@ int dfl_fpga_dev_feature_init(struct platform_device *pdev, while (drv->ops) { dfl_fpga_dev_for_each_feature(pdata, feature) { - /* match feature and drv using id */ - if (feature->id == drv->id) { + if (dfl_feature_drv_match(feature, drv)) { ret = dfl_feature_instance_init(pdev, pdata, feature, drv); if (ret) |
