From patchwork Wed May 22 10:34:56 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: 164795 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp694527ili; Wed, 22 May 2019 03:36:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzk+B7/ouaqBCLvb5PJla9yA9JohFqh61oBI8Q2fDrXcBb8eq2yiRyiRoOv6kCDPIUDeHJp X-Received: by 2002:a17:902:6a83:: with SMTP id n3mr90208264plk.109.1558521387338; Wed, 22 May 2019 03:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558521387; cv=none; d=google.com; s=arc-20160816; b=T1m+FaYYTi+pRVVx6NSl7kxa+4SmEJGWeTHBcoCupadbvAokoe50iThynrxColu4Ds q5S28iQiBlo/KIHwdGwZASK5cZpLwUEuPMconSo7In5TmE5fKBlOu2Mzpc99AeMuDO2J rRcEfpu1dV08kaRYZouIsx6sB25hz/Tk2psf/hXEu4bu44v+Xm0gSUQ/oPhWDKanqjAy ZrFv6mzpjb36F1wSfQagBv5Z5CZwfzl7BVSqWykHIrdZPl1Ury0Ki2pFbjuZziMQvoCG gBaAGZEuwNMk3wkgaeDhpxcRi+0WkcRMr/osVxN+t++zk2yDOXThe5fUvoOJEC5BMXCz 2n0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=sywiU9uQ2Lyz3SYUfs5YEI6L1toAWtr7MITOvXp312s=; b=A4hF700C+GvbPmVxOpoLVAPXBBzY74KZP6Df9Eyu4QWFpYHoAYTHVclhC6DQH8EYeY WARqTpWajIec4jFLVZXTvtNERknvzYxY08E7da1ehAqNg+zW85nEQM9ZLqK1rmfqmJEZ JCbzr5nsJ4m2aYr2qCuxa87/vjfFU8QGCNpb0gNopIILtmYfaQO4tA+IGXaAlHy6giS9 T+lNksb4nTv2CKgGIxvp9W9q6VRXZu35LmUkg4TjlrOC0tPuByhuim9HYWrOM6061LoH 6N/kmxQ0sTbPp4hQbp/HJpebEK8t9kwBmEKQ5PvZZrWpp8GgQBPnVGIZ9KYcQljjtxRu HHLw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h68si25312309pgc.270.2019.05.22.03.36.26; Wed, 22 May 2019 03:36:27 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729582AbfEVKg0 (ORCPT + 30 others); Wed, 22 May 2019 06:36:26 -0400 Received: from foss.arm.com ([217.140.101.70]:47158 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728942AbfEVKfs (ORCPT ); Wed, 22 May 2019 06:35:48 -0400 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 3D9DB169E; Wed, 22 May 2019 03:35:48 -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 2CF943F575; Wed, 22 May 2019 03:35:47 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH v4 23/30] coresight: Add support for releasing platform specific data Date: Wed, 22 May 2019 11:34:56 +0100 Message-Id: <1558521304-27469-24-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558521304-27469-1-git-send-email-suzuki.poulose@arm.com> References: <1558521304-27469-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-platform.c | 6 +++++- drivers/hwtracing/coresight/coresight-priv.h | 4 ++++ drivers/hwtracing/coresight/coresight.c | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index f500de6..53d6eed 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. @@ -311,7 +312,7 @@ struct coresight_platform_data * coresight_get_platform_data(struct device *dev) { int ret = -ENOENT; - struct coresight_platform_data *pdata; + struct coresight_platform_data *pdata = NULL; struct fwnode_handle *fwnode = dev_fwnode(dev); if (IS_ERR_OR_NULL(fwnode)) @@ -329,6 +330,9 @@ coresight_get_platform_data(struct device *dev) if (!ret) return pdata; error: + if (!IS_ERR_OR_NULL(pdata)) + /* Cleanup the connection information */ + coresight_release_platform_data(pdata); return ERR_PTR(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 96e1515..526141c 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1250,6 +1250,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); @@ -1259,6 +1261,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);