Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp186757lqk; Wed, 13 Mar 2024 23:03:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGFQeRM+Iy1qERXcxd93/x1QLOWlhHPHLEOiBQGv1m3x2n6E65JqtCH0v/SrVDJC2OiMjRjtMwupyRUh+p0YIpaOdz7gRIr0yLtdSnPw== X-Google-Smtp-Source: AGHT+IHV7W9g9meXq0i5LyQw3e7m2lw/FsCltilLXUGbXvjV5BaAQbwUM4ibNcFAnxY5N8FboYUQ X-Received: by 2002:a17:903:2284:b0:1dd:6fc5:1c5c with SMTP id b4-20020a170903228400b001dd6fc51c5cmr1088616plh.52.1710396206182; Wed, 13 Mar 2024 23:03:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710396206; cv=pass; d=google.com; s=arc-20160816; b=Py44ZoZs3IEAl0zoH6R9t1WOq1t2FCW3LXDceWS4Xqnrszw49GWdC+0Srvys+nOtUK +H0zeDchKvhuxaDfhWOd2DwywYuNjixOefoy8LdszAI6kbRpCE2h451b4ERUJDFBIpGM Fl8kMo8XXvpAVkD5NeRR+9gcN3QfQVuqswOeSJiQDM48UcTf1UwbhpZDZoLHleWB0Ub9 Q5cs5f0EEd703TxRZlX7j97fH8ToaMgz3wpfdS8YbuMK0CZMykMWKcQBNIbQG795Z6cb JwsXmN6jfiENF+Erh+WxUF7y/5QY2P72hvTZe5Q3+wif7lWf4DrzxH5aQXh0lVKPTMbt b48A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=cMH59kvDDykQilRnlZ1X9fWg9G7cLzkH8HLtbTcin5Q=; fh=z4RmidW4C/H6Wukz35Ay3Y7gZc5eNYlbqbLWbc/zZ2Y=; b=o8tPnLiddvOhfwGt6yVvucEY8V5waOlXsUlkX7asESFcyFqlrFvbyoZ1wFFTIqXwpg //c/KYbZcSOjwO7HVPg2AW2r+Wwlwkt4t4iMsPN+5TSEyu+RgFIN27a4xUVqo5sLSLUQ 4zhxWdKQM4KufOKngXkeqQiBl96JG9ZjUUjGlriq7ljKWL0Wgqqj/EgQ5cdPAgXXbXhE yCyTkoJFERn0H4ron19eUbPpFxrQGFddhceIRDZKzy3HNGu50fTJPwhDQOzN+wYYb11K O9Sgk7EuFu1tiV9cvejBJQ5+aGrkKUei8mS6Kv6vCkO+GQmZyDjDPGQgDbT1byy2FtLl QjFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-102835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q13-20020a170902dacd00b001dbcc3280f3si860314plx.232.2024.03.13.23.03.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 23:03:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-102835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102835-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0F2F9B217C9 for ; Thu, 14 Mar 2024 06:03:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BB0F28E3C; Thu, 14 Mar 2024 05:59:41 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EF3110979; Thu, 14 Mar 2024 05:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710395980; cv=none; b=kPTK7jJWlFLhoIIJmvFHyWkoznvjnIgRpiDvZ5xvGEe6GO4CkqSCtDAUKj2ns/vVHllmEGZ1Lhj1d0bfQKptJ4oOa8N1Xw/Aajp2Kr2YKN5es0MOgIS/XbypVsmMk9s3HuydzF/C/iIGs7U/Ru5o8H+TrH9qbA3ac0WR3/3d8JI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710395980; c=relaxed/simple; bh=OpLaZbtp+WBO3m+PzveXLptrfgHrJ/P+34zDvkbnGLY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nQ2h2hR8AZzAQ6od5/GQI3cJo+GRW+Z7Xb3vSJc5bcb1JvoQhHWa4hDapBex7+PtZPHGjjzHEYJYbS4tghaQ4vS86hquA0cK87RGv8sfvKXxJEXJ2r5T4xfI4lya1h5FD0QS7Pf65sBViqO4PRo5FDN8bz5h086F+QDilJtXXSs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8FBDB1007; Wed, 13 Mar 2024 23:00:13 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.53.138]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 004B03F73F; Wed, 13 Mar 2024 22:59:31 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Cc: Anshuman Khandual , Lorenzo Pieralisi , Sudeep Holla , Mike Leach , James Clark , Maxime Coquelin , Alexandre Torgue , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-stm32@st-md-mailman.stormreply.com, Leo Yan , Alexander Shishkin Subject: [PATCH V7 04/11] coresight: Add helpers registering/removing both AMBA and platform drivers Date: Thu, 14 Mar 2024 11:28:36 +0530 Message-Id: <20240314055843.2625883-5-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240314055843.2625883-1-anshuman.khandual@arm.com> References: <20240314055843.2625883-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This adds two different helpers i.e coresight_init_driver()/remove_driver() enabling coresight devices to register or remove AMBA and platform drivers. This changes replicator and funnel devices to use above new helpers. Cc: Suzuki K Poulose Cc: Mike Leach Cc: James Clark Cc: Leo Yan Cc: Alexander Shishkin Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: coresight@lists.linaro.org Reviewed-by: James Clark Signed-off-by: Anshuman Khandual --- drivers/hwtracing/coresight/coresight-core.c | 29 +++++++++++++++++++ .../hwtracing/coresight/coresight-funnel.c | 19 ++---------- .../coresight/coresight-replicator.c | 20 ++----------- include/linux/coresight.h | 7 +++++ 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index b83613e34289..9fc6f6b863e0 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1398,6 +1398,35 @@ static void __exit coresight_exit(void) module_init(coresight_init); module_exit(coresight_exit); +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv, + struct platform_driver *pdev_drv) +{ + int ret; + + ret = amba_driver_register(amba_drv); + if (ret) { + pr_err("%s: error registering AMBA driver\n", drv); + return ret; + } + + ret = platform_driver_register(pdev_drv); + if (!ret) + return 0; + + pr_err("%s: error registering platform driver\n", drv); + amba_driver_unregister(amba_drv); + return ret; +} +EXPORT_SYMBOL_GPL(coresight_init_driver); + +void coresight_remove_driver(struct amba_driver *amba_drv, + struct platform_driver *pdev_drv) +{ + amba_driver_unregister(amba_drv); + platform_driver_unregister(pdev_drv); +} +EXPORT_SYMBOL_GPL(coresight_remove_driver); + MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Pratik Patel "); MODULE_AUTHOR("Mathieu Poirier "); diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index ef1a0abfee4e..ff3ea0670a5b 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -410,27 +410,12 @@ static struct amba_driver dynamic_funnel_driver = { static int __init funnel_init(void) { - int ret; - - ret = platform_driver_register(&static_funnel_driver); - if (ret) { - pr_info("Error registering platform driver\n"); - return ret; - } - - ret = amba_driver_register(&dynamic_funnel_driver); - if (ret) { - pr_info("Error registering amba driver\n"); - platform_driver_unregister(&static_funnel_driver); - } - - return ret; + return coresight_init_driver("funnel", &dynamic_funnel_driver, &static_funnel_driver); } static void __exit funnel_exit(void) { - platform_driver_unregister(&static_funnel_driver); - amba_driver_unregister(&dynamic_funnel_driver); + coresight_remove_driver(&dynamic_funnel_driver, &static_funnel_driver); } module_init(funnel_init); diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 73452d9dc13b..ddb530a8436f 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -416,27 +416,13 @@ static struct amba_driver dynamic_replicator_driver = { static int __init replicator_init(void) { - int ret; - - ret = platform_driver_register(&static_replicator_driver); - if (ret) { - pr_info("Error registering platform driver\n"); - return ret; - } - - ret = amba_driver_register(&dynamic_replicator_driver); - if (ret) { - pr_info("Error registering amba driver\n"); - platform_driver_unregister(&static_replicator_driver); - } - - return ret; + return coresight_init_driver("replicator", &dynamic_replicator_driver, + &static_replicator_driver); } static void __exit replicator_exit(void) { - platform_driver_unregister(&static_replicator_driver); - amba_driver_unregister(&dynamic_replicator_driver); + coresight_remove_driver(&dynamic_replicator_driver, &static_replicator_driver); } module_init(replicator_init); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 5f288d475490..653f1712eb77 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -12,6 +12,8 @@ #include #include #include +#include +#include /* Peripheral id registers (0xFD0-0xFEC) */ #define CORESIGHT_PERIPHIDR4 0xfd0 @@ -658,4 +660,9 @@ coresight_find_output_type(struct coresight_platform_data *pdata, enum coresight_dev_type type, union coresight_dev_subtype subtype); +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv, + struct platform_driver *pdev_drv); + +void coresight_remove_driver(struct amba_driver *amba_drv, + struct platform_driver *pdev_drv); #endif /* _LINUX_COREISGHT_H */ -- 2.25.1