From patchwork Tue May 7 10:52:50 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: 163504 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp1185023ilm; Tue, 7 May 2019 03:55:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl5VdMgom9gB3mOj9GAmb9u5YqS6vZySLAy6yZHsh0iD3IF3wxqeX+bb+kS8fAezTgUicH X-Received: by 2002:a62:e117:: with SMTP id q23mr40481464pfh.60.1557226518522; Tue, 07 May 2019 03:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557226518; cv=none; d=google.com; s=arc-20160816; b=azBVHrwWyhvsoAH76EspoKXpjGXy1SgXCZcFnrRNnDUcLR0QHBjP3RQvVvzT6lgHns J7YPsmTo+dcocmaYIU1tHT055Xznv+A51ls6XqS3+DCzKvZpVV5iLzsC8AeNms0Y+2ZM Uh4CKNPTEg6gXpnuwwjR0tTGtyz06r4kF147gxPV8YlG8ru0IlBEDI9ANtuVXgCQ/pEh 5gzkmhAa5bXPaAeY8jZw9D2E7SUaSBSZVPQJRL3ywcxKLi4p8o3DbaBBvAven5fekx/5 w/8RugmAp18Y5MT988HRq4Hjoki9RvkNDBBeyoXbnyd2l0mdNqMp7ygVmC0fGWQaShc+ VNOw== 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=9YkYSzmz1n+Daw72u6Xw5h6ar2Dv1ZtfCTTKcwG2afI=; b=1DbN1oKQ9OobKE2VD2yS/hQLCFGf9Iv1uvQ03HpkWhGzfvRMnoeeK2UFXQMXqJQfwF M76m6b2U7ULhcNXGuPZ6tZ3isgZvSIxzO6L8PJnTfFFWG1BegnnORV6EMs6x58gsu9UF yJDM6csBqaz2lZIW16BYIPao+t9BXtbmHwnQXhWrhd5xzG3s6Es3dPMPHAqvcfSuctd0 StirkucxPFUUl+S3Q40d6efWS5payYkejudsjJ2S8W+VzSpX2Sl9n+q1gu4pnYkBwvuW sMqTNDAjplc71Vtt0kPjE+NAj57XXCqa0o+KPXfJHQZDx2wtr1ZHCEKNNF73aby8tRPE 2ZBA== 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 x12si12148361pgg.531.2019.05.07.03.55.18; Tue, 07 May 2019 03:55:18 -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 S1727381AbfEGKzM (ORCPT + 30 others); Tue, 7 May 2019 06:55:12 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50300 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfEGKyO (ORCPT ); Tue, 7 May 2019 06:54:14 -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 844E01713; Tue, 7 May 2019 03:54:14 -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 50F843F5AF; Tue, 7 May 2019 03:54:13 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, rjw@rjwysocki.net, mathieu.poirier@linaro.org, Suzuki K Poulose Subject: [PATCH v3 23/30] coresight: Add support for releasing platform specific data Date: Tue, 7 May 2019 11:52:50 +0100 Message-Id: <1557226378-10131-24-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557226378-10131-1-git-send-email-suzuki.poulose@arm.com> References: <1557226378-10131-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. Cc: 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 Reviewed-by: Mathieu Poirier 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);