Skip to content

Commit d06b004

Browse files
WuHao270gregkh
authored andcommitted
fpga: dfl: add dfl_fpga_check_port_id function.
This patch adds one common function in DFL framework. It uses port_ops get_id callback to get port id and compare it with given value. This function could be used as match function of the dfl_fpga_cdev_find_port function. Signed-off-by: Wu Hao <[email protected]> Acked-by: Alan Tull <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6e8fd6e commit d06b004

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

drivers/fpga/dfl.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,28 @@ void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops)
215215
}
216216
EXPORT_SYMBOL_GPL(dfl_fpga_port_ops_del);
217217

218+
/**
219+
* dfl_fpga_check_port_id - check the port id
220+
* @pdev: port platform device.
221+
* @pport_id: port id to compare.
222+
*
223+
* Return: 1 if port device matches with given port id, otherwise 0.
224+
*/
225+
int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id)
226+
{
227+
struct dfl_fpga_port_ops *port_ops = dfl_fpga_port_ops_get(pdev);
228+
int port_id;
229+
230+
if (!port_ops || !port_ops->get_id)
231+
return 0;
232+
233+
port_id = port_ops->get_id(pdev);
234+
dfl_fpga_port_ops_put(port_ops);
235+
236+
return port_id == *(int *)pport_id;
237+
}
238+
EXPORT_SYMBOL_GPL(dfl_fpga_check_port_id);
239+
218240
/**
219241
* dfl_fpga_dev_feature_uinit - uinit for sub features of dfl feature device
220242
* @pdev: feature device.

drivers/fpga/dfl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ void dfl_fpga_port_ops_add(struct dfl_fpga_port_ops *ops);
151151
void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops);
152152
struct dfl_fpga_port_ops *dfl_fpga_port_ops_get(struct platform_device *pdev);
153153
void dfl_fpga_port_ops_put(struct dfl_fpga_port_ops *ops);
154+
int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id);
154155

155156
/**
156157
* struct dfl_feature_driver - sub feature's driver

0 commit comments

Comments
 (0)