aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fpga/dfl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/fpga/dfl.c')
-rw-r--r--drivers/fpga/dfl.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index b56933c64371..68e0b45617b2 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -813,6 +813,38 @@ void dfl_fpga_feature_devs_remove(struct dfl_fpga_cdev *cdev)
813} 813}
814EXPORT_SYMBOL_GPL(dfl_fpga_feature_devs_remove); 814EXPORT_SYMBOL_GPL(dfl_fpga_feature_devs_remove);
815 815
816/**
817 * __dfl_fpga_cdev_find_port - find a port under given container device
818 *
819 * @cdev: container device
820 * @data: data passed to match function
821 * @match: match function used to find specific port from the port device list
822 *
823 * Find a port device under container device. This function needs to be
824 * invoked with lock held.
825 *
826 * Return: pointer to port's platform device if successful, NULL otherwise.
827 *
828 * NOTE: you will need to drop the device reference with put_device() after use.
829 */
830struct platform_device *
831__dfl_fpga_cdev_find_port(struct dfl_fpga_cdev *cdev, void *data,
832 int (*match)(struct platform_device *, void *))
833{
834 struct dfl_feature_platform_data *pdata;
835 struct platform_device *port_dev;
836
837 list_for_each_entry(pdata, &cdev->port_dev_list, node) {
838 port_dev = pdata->dev;
839
840 if (match(port_dev, data) && get_device(&port_dev->dev))
841 return port_dev;
842 }
843
844 return NULL;
845}
846EXPORT_SYMBOL_GPL(__dfl_fpga_cdev_find_port);
847
816static int __init dfl_fpga_init(void) 848static int __init dfl_fpga_init(void)
817{ 849{
818 int ret; 850 int ret;