blob: 56d9c95b4aab20b8c37834da75b6e5b7118b7a8e [file] [log] [blame]
From 0ccd9979d2a8dc42a4c4dba68e1116dd71c4bbab Mon Sep 17 00:00:00 2001
From: Alan Tull <atull@kernel.org>
Date: Wed, 15 Nov 2017 14:20:17 -0600
Subject: [PATCH 1666/1795] fpga: region: check for child regions before
allocing image info
During a device tree overlay pre-apply notification, the check
for child FPGA regions can happen slightly earlier. This saves
us from allocating the FPGA image info that just gets thrown
away.
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>
(cherry picked from commit 1743df83ae5a949037eb86a12f225abd4374d176)
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/fpga/fpga-region.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
index 8c0d7bc572ed..a921c3c035db 100644
--- a/drivers/fpga/fpga-region.c
+++ b/drivers/fpga/fpga-region.c
@@ -362,15 +362,19 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region,
const char *firmware_name;
int ret;
- info = fpga_image_info_alloc(dev);
- if (!info)
- return -ENOMEM;
-
- /* Reject overlay if child FPGA Regions have firmware-name property */
+ /*
+ * Reject overlay if child FPGA Regions added in the overlay have
+ * firmware-name property (would mean that an FPGA region that has
+ * not been added to the live tree yet is doing FPGA programming).
+ */
ret = child_regions_with_firmware(nd->overlay);
if (ret)
return ret;
+ info = fpga_image_info_alloc(dev);
+ if (!info)
+ return -ENOMEM;
+
/* Read FPGA region properties from the overlay */
if (of_property_read_bool(nd->overlay, "partial-fpga-config"))
info->flags |= FPGA_MGR_PARTIAL_RECONFIG;
--
2.19.0