if (!mutex_trylock(&bridge->mutex)) return ERR_PTR(-EBUSY);
if (!try_module_get(bridge->br_ops_owner)) {
mutex_unlock(&bridge->mutex); return ERR_PTR(-ENODEV);
}
dev_dbg(&bridge->dev, "get\n");
return bridge;
}
/** * of_fpga_bridge_get - get an exclusive reference to an fpga bridge * * @np: node pointer of an FPGA bridge. * @info: fpga image specific information. * * Return: * * fpga_bridge struct pointer if successful. * * -EBUSY if someone already has a reference to the bridge. * * -ENODEV if @np is not an FPGA Bridge or can't take parent driver refcount.
*/ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np, struct fpga_image_info *info)
{ struct fpga_bridge *bridge; struct device *bridge_dev;
bridge_dev = class_find_device_by_of_node(&fpga_bridge_class, np); if (!bridge_dev) return ERR_PTR(-ENODEV);
bridge = __fpga_bridge_get(bridge_dev, info); if (IS_ERR(bridge))
put_device(bridge_dev);
/** * fpga_bridge_get - get an exclusive reference to an fpga bridge * @dev: parent device that fpga bridge was registered with * @info: fpga image specific information * * Given a device, get an exclusive reference to an fpga bridge. * * Return: fpga bridge struct or IS_ERR() condition containing error code.
*/ struct fpga_bridge *fpga_bridge_get(struct device *dev, struct fpga_image_info *info)
{ struct fpga_bridge *bridge; struct device *bridge_dev;
bridge_dev = class_find_device(&fpga_bridge_class, NULL, dev,
fpga_bridge_dev_match); if (!bridge_dev) return ERR_PTR(-ENODEV);
bridge = __fpga_bridge_get(bridge_dev, info); if (IS_ERR(bridge))
put_device(bridge_dev);
/** * fpga_bridges_enable - enable bridges in a list * @bridge_list: list of FPGA bridges * * Enable each bridge in the list. If list is empty, do nothing. * * Return: 0 for success or empty bridge list or an error code otherwise.
*/ int fpga_bridges_enable(struct list_head *bridge_list)
{ struct fpga_bridge *bridge; int ret;
list_for_each_entry(bridge, bridge_list, node) {
ret = fpga_bridge_enable(bridge); if (ret) return ret;
}
/** * fpga_bridges_disable - disable bridges in a list * * @bridge_list: list of FPGA bridges * * Disable each bridge in the list. If list is empty, do nothing. * * Return: 0 for success or empty bridge list or an error code otherwise.
*/ int fpga_bridges_disable(struct list_head *bridge_list)
{ struct fpga_bridge *bridge; int ret;
list_for_each_entry(bridge, bridge_list, node) {
ret = fpga_bridge_disable(bridge); if (ret) return ret;
}
/** * fpga_bridges_put - put bridges * * @bridge_list: list of FPGA bridges * * For each bridge in the list, put the bridge and remove it from the list. * If list is empty, do nothing.
*/ void fpga_bridges_put(struct list_head *bridge_list)
{ struct fpga_bridge *bridge, *next; unsignedlong flags;
/** * of_fpga_bridge_get_to_list - get a bridge, add it to a list * * @np: node pointer of an FPGA bridge * @info: fpga image specific information * @bridge_list: list of FPGA bridges * * Get an exclusive reference to the bridge and it to the list. * * Return: 0 for success, error code from of_fpga_bridge_get() otherwise.
*/ int of_fpga_bridge_get_to_list(struct device_node *np, struct fpga_image_info *info, struct list_head *bridge_list)
{ struct fpga_bridge *bridge; unsignedlong flags;
bridge = of_fpga_bridge_get(np, info); if (IS_ERR(bridge)) return PTR_ERR(bridge);
/** * fpga_bridge_get_to_list - given device, get a bridge, add it to a list * * @dev: FPGA bridge device * @info: fpga image specific information * @bridge_list: list of FPGA bridges * * Get an exclusive reference to the bridge and it to the list. * * Return: 0 for success, error code from fpga_bridge_get() otherwise.
*/ int fpga_bridge_get_to_list(struct device *dev, struct fpga_image_info *info, struct list_head *bridge_list)
{ struct fpga_bridge *bridge; unsignedlong flags;
bridge = fpga_bridge_get(dev, info); if (IS_ERR(bridge)) return PTR_ERR(bridge);
/** * fpga_bridge_unregister - unregister an FPGA bridge * * @bridge: FPGA bridge struct * * This function is intended for use in an FPGA bridge driver's remove function.
*/ void fpga_bridge_unregister(struct fpga_bridge *bridge)
{ /* * If the low level driver provides a method for putting bridge into * a desired state upon unregister, do it.
*/ if (bridge->br_ops->fpga_bridge_remove)
bridge->br_ops->fpga_bridge_remove(bridge);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.