From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032226AbdDTOKu (ORCPT ); Thu, 20 Apr 2017 10:10:50 -0400 Received: from mail.kernel.org ([198.145.29.136]:60028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032172AbdDTOKl (ORCPT ); Thu, 20 Apr 2017 10:10:41 -0400 From: Alan Tull To: Moritz Fischer Cc: Alan Tull , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v2 08/16] fpga: region: check for child regions before allocing image info Date: Thu, 20 Apr 2017 09:09:53 -0500 Message-Id: <1492697401-11211-9-git-send-email-atull@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492697401-11211-1-git-send-email-atull@kernel.org> References: <1492697401-11211-1-git-send-email-atull@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v2: split out from another patch --- 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 7ff5426..c2730a8 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -355,15 +355,19 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region, const char *firmware_name; int ret; - info = fpga_image_info_alloc(®ion->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.7.4