Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1089138imm; Wed, 25 Jul 2018 11:16:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcwqczcTXt6YbL1z52XGKVx7XZoMK3BrZ+uwMJv3Ejvi2aS3H+GMz91RBAo4week2lvL1Of X-Received: by 2002:a63:647:: with SMTP id 68-v6mr21700992pgg.205.1532542619730; Wed, 25 Jul 2018 11:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532542619; cv=none; d=google.com; s=arc-20160816; b=xNdJTHzphhRKomXWqiQU7huLZ+ak9ZBm7qu14Os4Wp6mVaSZvi7MqCfY6kcOOpcyWX HhWI5KCAsGe88XXXWFvfxNbzg04Fxfnsrv8twIVJnW7ZHFVFkXU/Q7rgbZWXKHm25KuX CTmJ46OsFDu5wzQHy4CIenMv8KtZmu4DIlu31xmZDsSO5k0kJyQnv6rBsWb41/zn0s8q xWTiA+VYyxeKuboPMOR5ExplujFlqJ+mKCXZjp4cV8mSPHhKLT3dtW8AVODwpoiewLsf KXoqdFfNHQ+VuWMGS4q+kCrxzfJU6f0nKpUuVKH6SK0Dbzo+BSrthCIf03llLa03bCTt 81pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Tg+CyQpxImFLHsB7ysju/i/ueXX+08mQfl+CjJJaxbM=; b=XohxITVWWTwvFIQ4Qhj+TT+oPjULJzYaPfHT5cNuMJrYn7lTpUeN5eMr9aCi/6AIo8 hJTfVUEfTat0txO1zLnuYdt9TWANc8wo+/YY8+2tPL2zPy1BaDihe7KSjdu6PeWi+n1X ReeTHhLmsj4vABxhqpKQ28Q9Wm41Hs+4Ry/2oM3Pc+OOXt1aNiLVSen3dbNEozAi2GD5 xQdJOXN7fMbhbx3zhGDAIJOID5EJGNyGiwJ9R5yKhHpAkWkUeXIt4L72s7ZlKwMbiWzj L+C/WE3dUgMLRfqmlE9OKEVVkd5ztIx24bW4Zlt+yIdqM6aUCNMMCBEaMPN1Iiapyd5A MV0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TbvujUBL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14-v6si14130787pgc.368.2018.07.25.11.16.45; Wed, 25 Jul 2018 11:16:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TbvujUBL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730445AbeGYT2N (ORCPT + 99 others); Wed, 25 Jul 2018 15:28:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:46264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729337AbeGYT2I (ORCPT ); Wed, 25 Jul 2018 15:28:08 -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 AE2C520844; Wed, 25 Jul 2018 18:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532542518; bh=uRauyaYBWk+7MwhDWR51ysz7M4nAzSvFGseMv2gE3ho=; h=From:To:Cc:Subject:Date:From; b=TbvujUBLNtkGCJxfMFYXXZ9xXSvwyPfVilXXY2EDJVH9mZvtgMFkoLqr9PHB9miMP ZAuNXJ+CqviSwWpuNz+dO/n1fvGt/gGMWs2jB6XggdYmxaIGiuWmf3MLy6KfkfyuNM 9BKCK3cetI8jkyZYQ4RLUaDk+rfKC54egk/YN3JM= From: Alan Tull To: Moritz Fischer Cc: Alan Tull , Florian Fainelli , Federico Vaga , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH 1/2] fpga: Document when fpga_blah_free functions should be used Date: Wed, 25 Jul 2018 13:15:13 -0500 Message-Id: <20180725181514.3501-1-atull@kernel.org> X-Mailer: git-send-email 2.16.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clarify when fpga_(mgr|bridge|region)_free functions should be used. The class's dev_release will handle cleanup when the device is released so once the mgr/brige/region has been successfully registered, it would be a bug to call fpga_(mgr|bridge|region)_free. Signed-off-by: Alan Tull Suggested-by: Florian Fainelli Suggested-by: Federico Vaga --- drivers/fpga/fpga-bridge.c | 10 +++++++++- drivers/fpga/fpga-mgr.c | 10 +++++++++- drivers/fpga/fpga-region.c | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index 24b8f98..528d2149 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -379,7 +379,11 @@ EXPORT_SYMBOL_GPL(fpga_bridge_create); /** * fpga_bridge_free - free a fpga bridge and its id - * @bridge: FPGA bridge struct created by fpga_bridge_create + * @bridge: FPGA bridge struct created by fpga_bridge_create() + * + * Free a FPGA bridge. This function should only be called for + * freeing a bridge that has not been registered yet (such as in error + * paths in a probe function). */ void fpga_bridge_free(struct fpga_bridge *bridge) { @@ -414,6 +418,10 @@ EXPORT_SYMBOL_GPL(fpga_bridge_register); /** * fpga_bridge_unregister - unregister and free a fpga bridge * @bridge: FPGA bridge struct created by fpga_bridge_create + * + * Unregister the bridge device. The class's dev_release will handle + * freeing the bridge struct when the device is released so don't + * call fpga_bridge_free() after calling fpga_bridge_unregister(). */ void fpga_bridge_unregister(struct fpga_bridge *bridge) { diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index a41b07e..9632cbd 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -619,7 +619,11 @@ EXPORT_SYMBOL_GPL(fpga_mgr_create); /** * fpga_mgr_free - deallocate a FPGA manager - * @mgr: fpga manager struct created by fpga_mgr_create + * @mgr: fpga manager struct created by fpga_mgr_create() + * + * Free a FPGA manager struct. This function should only be called + * for freeing a manager that has not been registered yet (such as in + * error paths in a probe function). */ void fpga_mgr_free(struct fpga_manager *mgr) { @@ -663,6 +667,10 @@ EXPORT_SYMBOL_GPL(fpga_mgr_register); /** * fpga_mgr_unregister - unregister and free a FPGA manager * @mgr: fpga manager struct + * + * Unregister the manager device. The class's dev_release will handle + * freeing the manager struct when the device is released so don't + * call fpga_mgr_free() after calling fpga_mgr_unregister(). */ void fpga_mgr_unregister(struct fpga_manager *mgr) { diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index 0d65220..7335fa9 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -231,7 +231,11 @@ EXPORT_SYMBOL_GPL(fpga_region_create); /** * fpga_region_free - free a struct fpga_region - * @region: FPGA region created by fpga_region_create + * @region: FPGA region created by fpga_region_create() + * + * Free a FPGA region struct. This function should only be called for + * freeing a region that has not been registered yet (such as in error + * paths in a probe function). */ void fpga_region_free(struct fpga_region *region) { @@ -255,6 +259,10 @@ EXPORT_SYMBOL_GPL(fpga_region_register); /** * fpga_region_unregister - unregister and free a FPGA region * @region: FPGA region + * + * Unregister the region device. The class's dev_release will handle + * freeing the region so don't call fpga_region_free() after calling + * fpga_region_unregister(). */ void fpga_region_unregister(struct fpga_region *region) { -- 2.7.4