From patchwork Mon Sep 28 16:35:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11804097 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87FAC6CB for ; Mon, 28 Sep 2020 16:42:01 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E0AE208FE for ; Mon, 28 Sep 2020 16:42:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="z9d4AdIu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MIB+37QM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E0AE208FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=uj5+X6taUsQpV9h/p1mScSbMarPSt/XAjOKbqnwW++w=; b=z9d4AdIuQis3X+90jJL8xGcUm YgmjV+2MHTRCkOnOacxRm76X/FohbefwwvYBDLFBKO2J3qOJi0CPxnX9Zup5bZbmn3OxKsXZJs3Px Y12tfgkAsPfXfXQLiIGvcwRekdo4k5/WmrXU87a/sOZQcOjDBwt7+TNxWINBRfIkPIbLIs6VYcici MZO+nmRU8yNXFVn81IdlpN+7pEAefAErLervbJt+Uy46GAwrV/BH0sqLAVlBNrJ7fJZOg+oSEq0R5 60BTurlCUQ5rbWoDMBs+/hYGhdBHBzS0lMf+tzufSpDCTZ6zSf41FcDtvVUBNL6LGEFNsCpDL6TI9 U70mYj4XQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMwBj-0002Be-6g; Mon, 28 Sep 2020 16:39:43 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMw7f-0000bN-RP for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 16:35:37 +0000 Received: by mail-pg1-x542.google.com with SMTP id 7so1307744pgm.11 for ; Mon, 28 Sep 2020 09:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vMwbm6M17eoKIMI3/97ZhWWkuJ53zAySuNIn1r+zO7o=; b=MIB+37QMnkKch3OGAmY/TF8pDjDUOzFVG+pW4cC3/gjdCg7p2YD9kzGItbhRKuIm2t 3TvAZ7sR2kNtnUaPtAdSWgm5mpCgOdpTa8dhRhllIMkSlEMyEKJUmATRUvqzgwMLkl7U Co+BZCZhpTPhXitC9gSAr98vhuOr4a/cS2qkzb2jEgijldq3jCpjuCPX3csNA966edRV O9sB9MBBv5cRDQ7bgVRE2unoaWDbcwyYoexPHvMTCDrUzcCgaQU1LmnUdfusSnfWoHkG SdMp6nfVHe3PSftGHyz2YNEi2rdStKJM8lmc2T0TikeIeeK7SzKDUrAHNTBqDzLAYVfK emTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vMwbm6M17eoKIMI3/97ZhWWkuJ53zAySuNIn1r+zO7o=; b=nZoTkgu8JhJddKWKzFl87LYdfKCk+jGeNPBjutWNn7J8M7EY3QpdGqE4lQf1UhdCcJ 4MFxR7z/qcHXiR5S7htXqEin2qDLB1OEO3iF++CiQRv7Hu0+F/GgBMfcafSdf5ar41Dv wi7/5pnKvHV30hyuLh7XPYbIbwpkbw+5t6BAQowL2/AS+3NZeRYn5+ccZGMrjdPCjefe Uvl5HpKSI5WhFsoEUKsSJuGY7pqtmgIZBc5jD2jxVHzSojyKyuA+oPxxO4+QSYJ1EhvT ZyznTVK6S+AOCrvPUp+fq+MTfJJFd2cAOXwpEhaKs+3T7APQfXiZIj57GL2oGLE6Xura ZYvg== X-Gm-Message-State: AOAM532Cs6MIwc9FClivkFT6zssxXTMC7w/IpsN38yxfvqsczswPejLT ePnOGoPtnc1eTuCr7KtVIILim28C0g6iVA== X-Google-Smtp-Source: ABdhPJw9a0z4zuW2GGmK3wRCFrZbpPgX7Wrp96hGFD20ClnIyJq1ieH/D9WVbPRQ+bV8PB64NtOjYg== X-Received: by 2002:a63:1a66:: with SMTP id a38mr1736255pgm.253.1601310930011; Mon, 28 Sep 2020 09:35:30 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id f19sm2345640pfd.45.2020.09.28.09.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 09:35:29 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 14/25] coresight: funnel: Allow funnel driver to be built as module Date: Mon, 28 Sep 2020 10:35:02 -0600 Message-Id: <20200928163513.70169-15-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928163513.70169-1-mathieu.poirier@linaro.org> References: <20200928163513.70169-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_123531_926333_DA4DD038 X-CRM114-Status: GOOD ( 20.18 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:542 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Kim Phillips Allow to build coresight-funnel as module, for ease of development. - combine static and dynamic funnel init into single module_init/exit call - add funnel_remove functions, for module unload - add a MODULE_DEVICE_TABLE for autoloading on boot Cc: Mathieu Poirier Cc: Leo Yan Cc: Alexander Shishkin Cc: Randy Dunlap Cc: Suzuki K Poulose Cc: Greg Kroah-Hartman Cc: Russell King Co-developed-by: Mian Yousaf Kaukab Signed-off-by: Mian Yousaf Kaukab Signed-off-by: Kim Phillips Signed-off-by: Tingwei Zhang Tested-by: Mike Leach Reviewed-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- .../hwtracing/coresight/coresight-funnel.c | 65 ++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index 900690a9f7f0..af40814ce560 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -274,6 +274,15 @@ static int funnel_probe(struct device *dev, struct resource *res) return ret; } +static int __exit funnel_remove(struct device *dev) +{ + struct funnel_drvdata *drvdata = dev_get_drvdata(dev); + + coresight_unregister(drvdata->csdev); + + return 0; +} + #ifdef CONFIG_PM static int funnel_runtime_suspend(struct device *dev) { @@ -319,29 +328,41 @@ static int static_funnel_probe(struct platform_device *pdev) return ret; } +static int __exit static_funnel_remove(struct platform_device *pdev) +{ + funnel_remove(&pdev->dev); + pm_runtime_disable(&pdev->dev); + return 0; +} + static const struct of_device_id static_funnel_match[] = { {.compatible = "arm,coresight-static-funnel"}, {} }; +MODULE_DEVICE_TABLE(of, static_funnel_match); + #ifdef CONFIG_ACPI static const struct acpi_device_id static_funnel_ids[] = { {"ARMHC9FE", 0}, {}, }; + +MODULE_DEVICE_TABLE(acpi, static_funnel_ids); #endif static struct platform_driver static_funnel_driver = { .probe = static_funnel_probe, + .remove = static_funnel_remove, .driver = { .name = "coresight-static-funnel", + .owner = THIS_MODULE, .of_match_table = static_funnel_match, .acpi_match_table = ACPI_PTR(static_funnel_ids), .pm = &funnel_dev_pm_ops, .suppress_bind_attrs = true, }, }; -builtin_platform_driver(static_funnel_driver); static int dynamic_funnel_probe(struct amba_device *adev, const struct amba_id *id) @@ -349,6 +370,11 @@ static int dynamic_funnel_probe(struct amba_device *adev, return funnel_probe(&adev->dev, &adev->res); } +static int __exit dynamic_funnel_remove(struct amba_device *adev) +{ + return funnel_remove(&adev->dev); +} + static const struct amba_id dynamic_funnel_ids[] = { { .id = 0x000bb908, @@ -362,6 +388,8 @@ static const struct amba_id dynamic_funnel_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, dynamic_funnel_ids); + static struct amba_driver dynamic_funnel_driver = { .drv = { .name = "coresight-dynamic-funnel", @@ -370,6 +398,39 @@ static struct amba_driver dynamic_funnel_driver = { .suppress_bind_attrs = true, }, .probe = dynamic_funnel_probe, + .remove = dynamic_funnel_remove, .id_table = dynamic_funnel_ids, }; -builtin_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; +} + +static void __exit funnel_exit(void) +{ + platform_driver_unregister(&static_funnel_driver); + amba_driver_unregister(&dynamic_funnel_driver); +} + +module_init(funnel_init); +module_exit(funnel_exit); + +MODULE_AUTHOR("Pratik Patel "); +MODULE_AUTHOR("Mathieu Poirier "); +MODULE_DESCRIPTION("Arm CoreSight Funnel Driver"); +MODULE_LICENSE("GPL v2");