Skip to content

Commit 61c3210

Browse files
atull-alteragregkh
authored andcommitted
fpga: region: use image info as parameter for programming region
Use FPGA image info (region->info) when region code is programming the FPGA to pass in multiple parameters. This is a baby step in refactoring the FPGA region code to separate out common FPGA region code from FPGA region Device Tree overlay support. Signed-off-by: Alan Tull <atull@kernel.org> Acked-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ed81f5f commit 61c3210

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎drivers/fpga/fpga-region.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,13 @@ static int fpga_region_get_bridges(struct fpga_region *region,
223223
/**
224224
* fpga_region_program_fpga - program FPGA
225225
* @region: FPGA region
226-
* @overlay: device node of the overlay
227-
* Program an FPGA using information in the region's fpga image info.
226+
* Program an FPGA using fpga image info (region->info).
228227
* Return 0 for success or negative error code.
229228
*/
230-
static int fpga_region_program_fpga(struct fpga_region *region,
231-
struct device_node *overlay)
229+
static int fpga_region_program_fpga(struct fpga_region *region)
232230
{
233231
struct device *dev = &region->dev;
232+
struct fpga_image_info *info = region->info;
234233
int ret;
235234

236235
region = fpga_region_get(region);
@@ -245,7 +244,7 @@ static int fpga_region_program_fpga(struct fpga_region *region,
245244
goto err_put_region;
246245
}
247246

248-
ret = fpga_region_get_bridges(region, overlay);
247+
ret = fpga_region_get_bridges(region, info->overlay);
249248
if (ret) {
250249
dev_err(dev, "failed to get FPGA bridges\n");
251250
goto err_unlock_mgr;
@@ -257,7 +256,7 @@ static int fpga_region_program_fpga(struct fpga_region *region,
257256
goto err_put_br;
258257
}
259258

260-
ret = fpga_mgr_load(region->mgr, region->info);
259+
ret = fpga_mgr_load(region->mgr, info);
261260
if (ret) {
262261
dev_err(dev, "failed to load FPGA image\n");
263262
goto err_put_br;
@@ -373,6 +372,8 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
373372
if (!info)
374373
return -ENOMEM;
375374

375+
info->overlay = nd->overlay;
376+
376377
/* Read FPGA region properties from the overlay */
377378
if (of_property_read_bool(nd->overlay, "partial-fpga-config"))
378379
info->flags |= FPGA_MGR_PARTIAL_RECONFIG;
@@ -421,7 +422,8 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
421422
}
422423

423424
region->info = info;
424-
ret = fpga_region_program_fpga(region, nd->overlay);
425+
426+
ret = fpga_region_program_fpga(region);
425427
if (ret) {
426428
fpga_image_info_free(info);
427429
region->info = NULL;

‎include/linux/fpga/fpga-mgr.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ enum fpga_mgr_states {
8989
* @buf: contiguous buffer containing FPGA image
9090
* @count: size of buf
9191
* @dev: device that owns this
92+
* @overlay: Device Tree overlay
9293
*/
9394
struct fpga_image_info {
9495
u32 flags;
@@ -100,6 +101,9 @@ struct fpga_image_info {
100101
const char *buf;
101102
size_t count;
102103
struct device *dev;
104+
#ifdef CONFIG_OF
105+
struct device_node *overlay;
106+
#endif
103107
};
104108

105109
/**

0 commit comments

Comments
 (0)