fpga: of-fpga-region: accept overlays that don't program FPGA
authorAlan Tull <atull@kernel.org>
Wed, 15 Nov 2017 20:20:26 +0000 (14:20 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2017 15:30:38 +0000 (16:30 +0100)
The FPGA may already have a static image programmed when
Linux boots.  In that case a DT overlay may be used to add
the devices that already exist.  This commit allows that
by shuffling the order of some checks.

Signed-off-by: Alan Tull <atull@kernel.org>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/fpga/of-fpga-region.c

index 1533506ef0e42ecba457409c1e2e920a5452ff38..c6b21194dcbcf8b132c27881e2a36e53bbb90046 100644 (file)
@@ -298,18 +298,19 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region,
        struct fpga_image_info *info;
        int ret;
 
-       if (region->info) {
-               dev_err(dev, "Region already has overlay applied.\n");
-               return -EINVAL;
-       }
-
        info = of_fpga_region_parse_ov(region, nd->overlay);
        if (IS_ERR(info))
                return PTR_ERR(info);
 
+       /* If overlay doesn't program the FPGA, accept it anyway. */
        if (!info)
                return 0;
 
+       if (region->info) {
+               dev_err(dev, "Region already has overlay applied.\n");
+               return -EINVAL;
+       }
+
        region->info = info;
        ret = fpga_region_program_fpga(region);
        if (ret) {