From patchwork Mon Jul 24 19:49:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 9860189 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 D1C9D60385 for ; Mon, 24 Jul 2017 19:49:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C523F27861 for ; Mon, 24 Jul 2017 19:49:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA47E28592; Mon, 24 Jul 2017 19:49:49 +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 58FFB27861 for ; Mon, 24 Jul 2017 19:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752071AbdGXTtr (ORCPT ); Mon, 24 Jul 2017 15:49:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:33160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751783AbdGXTtX (ORCPT ); Mon, 24 Jul 2017 15:49:23 -0400 Received: from localhost.localdomain (user-0ccsrjt.cable.mindspring.com [24.206.110.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3700A22CAB; Mon, 24 Jul 2017 19:49:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3700A22CAB 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: [RFC 4/5] fpga-region: new function fpga_region_free Date: Mon, 24 Jul 2017 14:49:14 -0500 Message-Id: <1500925755-5727-5-git-send-email-atull@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500925755-5727-1-git-send-email-atull@kernel.org> References: <1500925755-5727-1-git-send-email-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 Add FPGA region API function fpga_region_free() that undoes some of what fpga_region_program_fpga() does to free up a region to be reprogrammed. Signed-off-by: Alan Tull --- drivers/fpga/fpga-region.c | 20 ++++++++++++++++++++ drivers/fpga/of-fpga-region.c | 5 +---- include/linux/fpga/fpga-region.h | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index afc6188..944d24a 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -162,6 +162,26 @@ int fpga_region_program_fpga(struct fpga_region *region) } EXPORT_SYMBOL_GPL(fpga_region_program_fpga); +/** + * fpga_region_free + * Undo some of what fpga_region_program_fpga() did to free up + * region to be reprogrammed. + * @region: FPGA region + */ +void fpga_region_free(struct fpga_region *region) +{ + if (!region->info) + return; + + fpga_bridges_disable(®ion->bridge_list); + if (region->get_bridges) + fpga_bridges_put(®ion->bridge_list); + + fpga_image_info_free(region->info); + region->info = NULL; +} +EXPORT_SYMBOL_GPL(fpga_region_free); + int fpga_region_register(struct device *dev, struct fpga_region *region) { int id, ret = 0; diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index 6bb5799..019ca37 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -333,10 +333,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region, static void of_fpga_region_notify_post_remove(struct fpga_region *region, struct of_overlay_notify_data *nd) { - fpga_bridges_disable(®ion->bridge_list); - fpga_bridges_put(®ion->bridge_list); - fpga_image_info_free(region->info); - region->info = NULL; + fpga_region_free(region); } /** diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h index f2eecdd..3b6f0b0 100644 --- a/include/linux/fpga/fpga-region.h +++ b/include/linux/fpga/fpga-region.h @@ -32,6 +32,8 @@ struct fpga_region *fpga_region_class_find( int (*match)(struct device *, const void *)); int fpga_region_program_fpga(struct fpga_region *region); +void fpga_region_free(struct fpga_region *region); + int fpga_region_register(struct device *dev, struct fpga_region *region); int fpga_region_unregister(struct fpga_region *region);