Skip to content

Commit

Permalink
fpga: dfl: add dfl_fpga_check_port_id function.
Browse files Browse the repository at this point in the history
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 <hao.wu@intel.com>
Acked-by: Alan Tull <atull@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
WuHao270 authored and gregkh committed Jul 15, 2018
1 parent 6e8fd6e commit d06b004
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/fpga/dfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,28 @@ void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops)
}
EXPORT_SYMBOL_GPL(dfl_fpga_port_ops_del);

/**
* dfl_fpga_check_port_id - check the port id
* @pdev: port platform device.
* @pport_id: port id to compare.
*
* Return: 1 if port device matches with given port id, otherwise 0.
*/
int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id)
{
struct dfl_fpga_port_ops *port_ops = dfl_fpga_port_ops_get(pdev);
int port_id;

if (!port_ops || !port_ops->get_id)
return 0;

port_id = port_ops->get_id(pdev);
dfl_fpga_port_ops_put(port_ops);

return port_id == *(int *)pport_id;
}
EXPORT_SYMBOL_GPL(dfl_fpga_check_port_id);

/**
* dfl_fpga_dev_feature_uinit - uinit for sub features of dfl feature device
* @pdev: feature device.
Expand Down
1 change: 1 addition & 0 deletions drivers/fpga/dfl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void dfl_fpga_port_ops_add(struct dfl_fpga_port_ops *ops);
void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops);
struct dfl_fpga_port_ops *dfl_fpga_port_ops_get(struct platform_device *pdev);
void dfl_fpga_port_ops_put(struct dfl_fpga_port_ops *ops);
int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id);

/**
* struct dfl_feature_driver - sub feature's driver
Expand Down

0 comments on commit d06b004

Please sign in to comment.