From patchwork Mon Jul 24 19:49:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Tull X-Patchwork-Id: 9860191 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 8239560385 for ; Mon, 24 Jul 2017 19:49:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75C5427861 for ; Mon, 24 Jul 2017 19:49:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AABE28592; Mon, 24 Jul 2017 19:49:51 +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 0805527861 for ; Mon, 24 Jul 2017 19:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752095AbdGXTtu (ORCPT ); Mon, 24 Jul 2017 15:49:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:33158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbdGXTtW (ORCPT ); Mon, 24 Jul 2017 15:49:22 -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 77C0B22CA1; Mon, 24 Jul 2017 19:49:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77C0B22CA1 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 3/5] fpga: add dev to fpga_image_info Date: Mon, 24 Jul 2017 14:49:13 -0500 Message-Id: <1500925755-5727-4-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 This patch should be rolled into the next version of my "non-dt support for FPGA regions" patchset. Add a pointer to the device that owns the fpga_image_info to fpga_image_info. That way the fpga_image_info_free can drop the 'dev' parameter and we are left with: struct fpga_image_info *fpga_image_info_alloc(struct device *dev); void fpga_image_info_free(struct fpga_image_info *info); Signed-off-by: Alan Tull --- drivers/fpga/fpga-mgr.c | 14 ++++++++++---- drivers/fpga/of-fpga-region.c | 6 +++--- include/linux/fpga/fpga-mgr.h | 4 +++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index be13cce..af33310 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -40,20 +40,26 @@ struct fpga_image_info *fpga_image_info_alloc(struct device *dev) if (!info) return ERR_PTR(-ENOMEM); + get_device(dev); + info->dev = dev; + return info; } EXPORT_SYMBOL_GPL(fpga_image_info_alloc); -void fpga_image_info_free(struct device *dev, - struct fpga_image_info *info) +void fpga_image_info_free(struct fpga_image_info *info) { + struct device *dev; + if (!info) return; if (info->firmware_name) - devm_kfree(dev, info->firmware_name); + devm_kfree(info->dev, info->firmware_name); - devm_kfree(dev, info); + dev = info->dev; + devm_kfree(info->dev, info); + put_device(dev); } EXPORT_SYMBOL_GPL(fpga_image_info_free); diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index c2ea9b6..6bb5799 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -273,7 +273,7 @@ static struct fpga_image_info *of_fpga_region_parse_ov( return info; ret_no_info: - fpga_image_info_free(dev, info); + fpga_image_info_free(info); return ERR_PTR(ret); } @@ -314,7 +314,7 @@ static int of_fpga_region_notify_pre_apply(struct fpga_region *region, ret = fpga_region_program_fpga(region); if (ret) { /* error; reject overlay */ - fpga_image_info_free(dev, info); + fpga_image_info_free(info); region->info = NULL; } @@ -335,7 +335,7 @@ static void of_fpga_region_notify_post_remove(struct fpga_region *region, { fpga_bridges_disable(®ion->bridge_list); fpga_bridges_put(®ion->bridge_list); - fpga_image_info_free(®ion->dev, region->info); + fpga_image_info_free(region->info); region->info = NULL; } diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 50954cb..ddc56c0 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -79,6 +79,7 @@ enum fpga_mgr_states { /** * struct fpga_image_info - information specific to a FPGA image + * @dev: device that owns this info * @flags: boolean flags as defined above * @enable_timeout_us: maximum time to enable traffic through bridge (uSec) * @disable_timeout_us: maximum time to disable traffic through bridge (uSec) @@ -91,6 +92,7 @@ enum fpga_mgr_states { * @overlay: Device Tree overlay */ struct fpga_image_info { + struct device *dev; u32 flags; u32 enable_timeout_us; u32 disable_timeout_us; @@ -153,7 +155,7 @@ struct fpga_manager { struct fpga_image_info *fpga_image_info_alloc(struct device *dev); -void fpga_image_info_free(struct device *dev, struct fpga_image_info *info); +void fpga_image_info_free(struct fpga_image_info *info); int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info);