Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp199735rdb; Thu, 22 Feb 2024 00:23:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMRTM4eJIQZ9HsTOVbQF2mSuJ6y9dSNYD+sJbOWlu/z37Ws3dErV3PcsFpjt9k8Lw0CxUBazXLO9PB0oXyrGxGx0dMqEssdo8K7c6tMg== X-Google-Smtp-Source: AGHT+IGvAITiz/uHzDDOh0dRU9j1tRrIw4ROVR3y7SlHms0pmDAGXKtLUSq61d9mqtZvwhJkHpS1 X-Received: by 2002:a05:6870:700e:b0:21e:d175:e749 with SMTP id u14-20020a056870700e00b0021ed175e749mr14047158oae.40.1708590214298; Thu, 22 Feb 2024 00:23:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708590214; cv=pass; d=google.com; s=arc-20160816; b=jtFBpV1UdBrZHiz50TfSgjaqIdFZYABc2xKsoA0qESt+t/HNkhRXIm9RrA1fu7wRcs qPerfceLd8DNKUln0d20TY2bApHnott611CZFVZgY9hTgkc3orYQamOD8ce50ZuVUier kGyBNbHL96V8a0QITlwLGMyS+qD735EPlsAzd2gUOcphBUEQniPWig8ixGQX335+FWC4 taVIvcy+2rOlo1a/ktk/q4JdoH4gXB8YvScHZHahPlq/Gu+O1BDF/PQCMknpAXk889/j 8vQdrt2eqFc14uPvwqQu15Pnnxd2ryO8LhAvKvdCXGMO+TncTOeDU0zlZWRqhlzdTWZV /czA== 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=n5ignOF8GhfJLvFC+7JlkpTQRlbtXWqSee/TXYncv90=; fh=z4RmidW4C/H6Wukz35Ay3Y7gZc5eNYlbqbLWbc/zZ2Y=; b=Ot4BLf0ZScFFkOviBt7D6EJkxlun3gOuY+LMaMalpUsK+p7803nvcUymGfsaxbzlpy YccYrTp99NMzRPxvWQZ/xSdb1Ae6GJFi/e68rbuZSdsiCMDygDPJURZsVuhPmkCvfxEa QdS51fzNR6+x6WxZ0MevpWj7BUhlQJj7DggzO7gd6bCSF4gocJfwjz1wEbl1jWG/3Btt 6WrqPdq/ElcJK1vSZzV0Sd8Q52pP4fj7g5Lebk8MJjU1La8w1gf2YZBUbtyuijtWIwql nCrsT1N5nFCLue9764Q12ayfszHzlkh0F7h35NhzD+bniMYcc0yyvZ+4Usc+MaU+SCvZ yqZw==; 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-76085-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76085-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. [147.75.48.161]) by mx.google.com with ESMTPS id bz25-20020a056a02061900b005dbf27229f6si10305560pgb.343.2024.02.22.00.23.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 00:23:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76085-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-76085-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76085-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 B28C2B23FE4 for ; Thu, 22 Feb 2024 08:23:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 551721B7E8; Thu, 22 Feb 2024 08:22:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FCA9224F1; Thu, 22 Feb 2024 08:22:22 +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=1708590144; cv=none; b=WmCdx9lhmPXRJlEYLC21edkbjDVWKDgCADI3GnlFe7WAuXqbzQuhfW/k9ZzcZX7usXUpSmqn2FD6ASKZo61TY9C86LvvSSPDMPDQANJRPcRVnoc7h8chEqDdSBcdsCXL5JEIXL5V/QlpDo0OknVOo2N79x5/y856Ahy+m0fGADg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708590144; c=relaxed/simple; bh=jGIbbOE99EZBa8dJK15RCZFZMqliA/pI0s/dt+f/Y30=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mG5HEDwzSgUpFNBabdl/qOg733BrN0hb7aXQHpXOAbPPY3NhHc9P0LjAUkuAK6k3ubB+HylqHtYrD4Fq31NprEDuJVGlrkkwrKrUprlRe09APDpBtawrhXRMhbcRBcQgAtjpIZZajy/wek3ZsdrCl45G7xLZ7sPbc1wd7uMHCWc= 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 A76711007; Thu, 22 Feb 2024 00:23:00 -0800 (PST) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.42.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A01733F762; Thu, 22 Feb 2024 00:22:17 -0800 (PST) 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 V5 04/11] coresight: Add helpers registering/removing both AMBA and platform drivers Date: Thu, 22 Feb 2024 13:51:35 +0530 Message-Id: <20240222082142.3663983-5-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240222082142.3663983-1-anshuman.khandual@arm.com> References: <20240222082142.3663983-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 --- Changes in V5: - Changed replicator and funnel devices to use the new helpers 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 d7f0e231feb9..4e897cc5da81 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1836,6 +1836,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 a5b1fc787766..004cb63f9cbc 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 91d93060dda5..b82cf9906cfb 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 a4cb7dd6ca23..7e1646d4863c 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 @@ -598,6 +600,11 @@ void coresight_relaxed_write64(struct coresight_device *csdev, u64 val, u32 offset); void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset); +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); #else static inline struct coresight_device * coresight_register(struct coresight_desc *desc) { return NULL; } -- 2.25.1