linux/drivers/fpga/of-fpga-region.c
/**
 * of_fpga_region_get_bridges - create a list of bridges
 * @region: FPGA region
 *
 * Create a list of bridges including the parent bridge and the bridges
 * specified by "fpga-bridges" property.  Note that the
 * fpga_bridges_enable/disable/put functions are all fine with an empty list
 * if that happens.
 *
 * Caller should call fpga_bridges_put(&region->bridge_list) when
 * done with the bridges.
 *
 * Return 0 for success (even if there are no bridges specified)
 * or -EBUSY if any of the bridges are in use.
 */
create a list of bridges
@region: FPGA region

Create a list of bridges including the parent bridge and the bridges
specified by "fpga-bridges" property.  Note that the
fpga_bridges_enable/disable/put functions are all fine with an empty list
if that happens.

Caller should call fpga_bridges_put(&region->bridge_list) when
done with the bridges.

Return 0 for success (even if there are no bridges specified)
or -EBUSY if any of the bridges are in use.
create a list of bridges @region : FPGA region Create a list of bridges including the parent bridge and the bridges specified by " fpga - bridges " property . Note that the fpga_bridges_enable / disable / put functions are all fine with an empty list if that happens . Caller should call fpga_bridges_put ( &region - > bridge_list ) when done with the bridges . Return 0 for success ( even if there are no bridges specified ) or - EBUSY if any of the bridges are in use .
static int of_fpga_region_get_bridges(struct fpga_region *region)
{
	struct device *dev = &region->dev;
	struct device_node *region_np = dev->of_node;
	struct fpga_image_info *info = region->info;
	struct device_node *br, *np, *parent_br = NULL;
	int i, ret;
	ret = of_fpga_bridge_get_to_list(region_np->parent, info,
					 &region->bridge_list);
	if (ret == -EBUSY)
		return ret;
	if (!ret)
		parent_br = region_np->parent;
	br = of_parse_phandle(info->overlay, "fpga-bridges", 0);
	if (br) {
		of_node_put(br);
		np = info->overlay;
	} else {
		np = region_np;
	}
	for (i = 0; ; i++) {
		br = of_parse_phandle(np, "fpga-bridges", i);
		if (!br)
			break;
		if (br == parent_br) {
			of_node_put(br);
			continue;
		}
		ret = of_fpga_bridge_get_to_list(br, info,
						 &region->bridge_list);
		of_node_put(br);
		if (ret == -EBUSY) {
			fpga_bridges_put(&region->bridge_list);
			return -EBUSY;
		}
	}
	return 0;
}
static int of_fpga_region_get_bridges ( struct fpga_region * region ) { struct device * dev = & region -> dev ; struct device_node * region_np = dev -> of_node ; struct fpga_image_info * info = region -> info ; struct device_node * br , * np , * parent_br = NULL ; int i , ret ; ret = of_fpga_bridge_get_to_list ( region_np -> parent , info , & region -> bridge_list ) ; if ( ret == - EBUSY ) return ret ; if ( ! ret ) parent_br = region_np -> parent ; br = of_parse_phandle ( info -> overlay , " " , 0 ) ; if ( br ) { of_node_put ( br ) ; np = info -> overlay ; } else { np = region_np ; } for ( i = 0 ; ; i ++ ) { br = of_parse_phandle ( np , " " , i ) ; if ( ! br ) break ; if ( br == parent_br ) { of_node_put ( br ) ; continue ; } ret = of_fpga_bridge_get_to_list ( br , info , & region -> bridge_list ) ; of_node_put ( br ) ; if ( ret == - EBUSY ) { fpga_bridges_put ( & region -> bridge_list ) ; return - EBUSY ; } } return 0 ; }
of_fpga_region_get_bridges - create a list of bridges
 @region: FPGA region
of_fpga_region_get_bridges - create a list of bridges @region : FPGA region
/* If parent is a bridge, add to list */ /* -EBUSY means parent is a bridge that is under use. Give up. */ /* Zero return code means parent was a bridge and was added to list. */ /* If overlay has a list of bridges, use it. */ /* If parent bridge is in list, skip it. */ /* If node is a bridge, get it and add to list */ /* If any of the bridges are in use, give up */