From patchwork Wed Sep 13 20:48:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 9952107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 992D360360 for ; Wed, 13 Sep 2017 20:52:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C3E828B0D for ; Wed, 13 Sep 2017 20:52:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8157828C00; Wed, 13 Sep 2017 20:52:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E68428B0D for ; Wed, 13 Sep 2017 20:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbdIMUwc (ORCPT ); Wed, 13 Sep 2017 16:52:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbdIMUs7 (ORCPT ); Wed, 13 Sep 2017 16:48:59 -0400 Received: from localhost.localdomain (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2D4F21A92; Wed, 13 Sep 2017 20:48:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2D4F21A92 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=atull@kernel.org From: Alan Tull To: Moritz Fischer Cc: Alan Tull , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v4 07/18] fpga: region: check for child regions before allocing image info Date: Wed, 13 Sep 2017 15:48:30 -0500 Message-Id: <20170913204841.2730-8-atull@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913204841.2730-1-atull@kernel.org> References: <20170913204841.2730-1-atull@kernel.org> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Moritz Fischer --- v2: split out from another patch v3: s/dev/®ion->dev/ in one place add Moritz' ack v4: no change to this patch in this version of patchset --- 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 d78f444..afac543 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(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;