From patchwork Mon Apr 15 16:04:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 10901223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA2C014DB for ; Mon, 15 Apr 2019 16:33:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AC1428971 for ; Mon, 15 Apr 2019 16:33:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F70328972; Mon, 15 Apr 2019 16:33:31 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5ABE128938 for ; Mon, 15 Apr 2019 16:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UWxinlWuat/t53xv8pnkOCOMQfwugkbFnRorGOcH4z0=; b=W6Qp5nIPwVchlgo79BC3qFcZBZ e7wtexGhZXhrCfhkOL7UI/zlWukQY+Xuaypim+cC5yJr9v3HhCIiTmf1z02UFfPS+wOgaEvLTOqMc ue/7KMJBiHOKoH1YgbpHi+iF35qTl43VP4K6r/RAVEt6+up3A3/0vrCOSU7EE5KNBglxwyIjbAeHc eft+ttfDQ1J2bmuvJbFfHSNFuw2NC7ZViiAe7F4nCJSCcBg6Ot7wqMaoVznJglvwZl4U+vbrQKXfu 2VWaTZRK/i4RFQTt80T1FNA+AhwTqamI+JU8FqIZ8T7HHrjfzdGo4j4/i5e7qJC79JXEJcJOLHw6/ cRCULN6A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG4Xt-0006cQ-82; Mon, 15 Apr 2019 16:33:25 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG4Vn-0003me-HD for linux-arm-kernel@bombadil.infradead.org; Mon, 15 Apr 2019 16:31:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=414eQZsJ77Z2tzyFUkhQQCqxRqawI5Xu1zmqOoIbDBU=; b=FSpa0U9wpxUVGu49qeRW/3xIV KInwl880iQ6BUaSE0VdRQ+EIA2CQw9DQNkahz6zb/Q0PmnxBaWqMh36RzuycEy8jNdNJOLdOY6npC kfPun4tp8VW09FJYyeL6JKRQd0pT/P0BnYaLh4A+3LWQJorE1HYCaPiNweaiu7BGquIJrGaxfIFFp XmufGTE2C3Gv/7/TsA9pDzMg7483iPc6mPDiew5Er8JIv43BgsM/jYJoJrHvwk/8JVAk2QYkrNN99 UF9ZivN8uPAURN1jbSCEgmNt2CBmtmJ0skGn7tbqHVra/0kmGAwflMNZFbgafYpKl1Cz6zJxc2I9j vZ4e+OaJQ==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG47q-0002hu-J0 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2019 16:06:31 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 709461A25; Mon, 15 Apr 2019 09:06:30 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EA0573F68F; Mon, 15 Apr 2019 09:06:28 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 26/36] coresight: Add support for releasing platform specific data Date: Mon, 15 Apr 2019 17:04:09 +0100 Message-Id: <1555344260-12375-27-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> References: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190415_120630_910253_C49CFE46 X-CRM114-Status: GOOD ( 17.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mathieu.poirier@linaro.org, Suzuki K Poulose , coresight@lists.linaro.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, robert.walker@arm.com, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a helper to clean up the platform specific data provided by the firmware. This will be later used for dropping the necessary references when we switch to the fwnode handles for tracking connections. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 12 +++++++++--- drivers/hwtracing/coresight/coresight-priv.h | 4 ++++ drivers/hwtracing/coresight/coresight.c | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 0415fff..a408b01 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -17,6 +17,7 @@ #include #include +#include "coresight-priv.h" /* * coresight_alloc_conns: Allocate connections record for each output * port from the device. @@ -304,7 +305,7 @@ EXPORT_SYMBOL_GPL(coresight_get_cpu); struct coresight_platform_data * coresight_get_platform_data(struct device *dev) { - struct coresight_platform_data *pdata; + struct coresight_platform_data *pdata, *ret = NULL; struct fwnode_handle *fwnode = dev_fwnode(dev); if (IS_ERR_OR_NULL(fwnode)) @@ -315,8 +316,13 @@ coresight_get_platform_data(struct device *dev) return ERR_PTR(-ENOMEM); if (is_of_node(fwnode)) - return of_get_coresight_platform_data(dev, pdata); + ret = of_get_coresight_platform_data(dev, pdata); - return ERR_PTR(-ENOENT); + if (!IS_ERR_OR_NULL(ret)) + return pdata; + + /* Cleanup the connection information */ + coresight_release_platform_data(pdata); + return ret; } EXPORT_SYMBOL_GPL(coresight_get_platform_data); diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index e0684d0..c216421 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -200,4 +200,8 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) return 0; } +static inline void +coresight_release_platform_data(struct coresight_platform_data *pdata) +{} + #endif diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index f6c5244..82fb411 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1248,6 +1248,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) err_free_csdev: kfree(csdev); err_out: + /* Cleanup the connection information */ + coresight_release_platform_data(desc->pdata); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(coresight_register); @@ -1257,6 +1259,7 @@ void coresight_unregister(struct coresight_device *csdev) etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ coresight_remove_conns(csdev); + coresight_release_platform_data(csdev->pdata); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister);