@@ -162,6 +162,26 @@ int fpga_region_program_fpga(struct fpga_region *region)
}
EXPORT_SYMBOL_GPL(fpga_region_program_fpga);
+/**
+ * fpga_region_free
+ * Undo some of what fpga_region_program_fpga() did to free up
+ * region to be reprogrammed.
+ * @region: FPGA region
+ */
+void fpga_region_free(struct fpga_region *region)
+{
+ if (!region->info)
+ return;
+
+ fpga_bridges_disable(®ion->bridge_list);
+ if (region->get_bridges)
+ fpga_bridges_put(®ion->bridge_list);
+
+ fpga_image_info_free(region->info);
+ region->info = NULL;
+}
+EXPORT_SYMBOL_GPL(fpga_region_free);
+
int fpga_region_register(struct device *dev, struct fpga_region *region)
{
int id, ret = 0;
@@ -333,10 +333,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
static void of_fpga_region_notify_post_remove(struct fpga_region *region,
struct of_overlay_notify_data *nd)
{
- fpga_bridges_disable(®ion->bridge_list);
- fpga_bridges_put(®ion->bridge_list);
- fpga_image_info_free(region->info);
- region->info = NULL;
+ fpga_region_free(region);
}
/**
@@ -32,6 +32,8 @@ struct fpga_region *fpga_region_class_find(
int (*match)(struct device *, const void *));
int fpga_region_program_fpga(struct fpga_region *region);
+void fpga_region_free(struct fpga_region *region);
+
int fpga_region_register(struct device *dev, struct fpga_region *region);
int fpga_region_unregister(struct fpga_region *region);
Add FPGA region API function fpga_region_free() that undoes some of what fpga_region_program_fpga() does to free up a region to be reprogrammed. Signed-off-by: Alan Tull <atull@kernel.org> --- drivers/fpga/fpga-region.c | 20 ++++++++++++++++++++ drivers/fpga/of-fpga-region.c | 5 +---- include/linux/fpga/fpga-region.h | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-)