Skip to content

Commit 8b0cf82

Browse files
Tingwei Zhanggregkh
authored andcommitted
coresight: stm: Allow to build coresight-stm as a module
- Kconfig becomes a tristate, to allow =m - add a stm_remove function, for module unload - add a MODULE_DEVICE_TABLE for autoloading on boot Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Suzuki K Poulose <Suzuki.Poulose@arm.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Russell King <linux@armlinux.org.uk> Tested-by: Mike Leach <mike.leach@linaro.org> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Kim Phillips <kim.phillips@arm.com> Signed-off-by: Tingwei Zhang <tingwei@codeaurora.org> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/20200928163513.70169-8-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 32b0707 commit 8b0cf82

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎drivers/hwtracing/coresight/Kconfig‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ config CORESIGHT_SOURCE_ETM4X
8686
data tracing may also be available.
8787

8888
config CORESIGHT_STM
89-
bool "CoreSight System Trace Macrocell driver"
89+
tristate "CoreSight System Trace Macrocell driver"
9090
depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64
9191
select CORESIGHT_LINKS_AND_SINKS
9292
select STM
@@ -96,6 +96,9 @@ config CORESIGHT_STM
9696
logging useful software events or data coming from various entities
9797
in the system, possibly running different OSs
9898

99+
To compile this driver as a module, choose M here: the
100+
module will be called coresight-stm.
101+
99102
config CORESIGHT_CPU_DEBUG
100103
tristate "CoreSight CPU Debug driver"
101104
depends on ARM || ARM64

‎drivers/hwtracing/coresight/coresight-stm.c‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,17 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
951951
return ret;
952952
}
953953

954+
static int __exit stm_remove(struct amba_device *adev)
955+
{
956+
struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
957+
958+
coresight_unregister(drvdata->csdev);
959+
960+
stm_unregister_device(&drvdata->stm);
961+
962+
return 0;
963+
}
964+
954965
#ifdef CONFIG_PM
955966
static int stm_runtime_suspend(struct device *dev)
956967
{
@@ -983,6 +994,8 @@ static const struct amba_id stm_ids[] = {
983994
{ 0, 0},
984995
};
985996

997+
MODULE_DEVICE_TABLE(amba, stm_ids);
998+
986999
static struct amba_driver stm_driver = {
9871000
.drv = {
9881001
.name = "coresight-stm",
@@ -991,7 +1004,12 @@ static struct amba_driver stm_driver = {
9911004
.suppress_bind_attrs = true,
9921005
},
9931006
.probe = stm_probe,
1007+
.remove = stm_remove,
9941008
.id_table = stm_ids,
9951009
};
9961010

997-
builtin_amba_driver(stm_driver);
1011+
module_amba_driver(stm_driver);
1012+
1013+
MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
1014+
MODULE_DESCRIPTION("Arm CoreSight System Trace Macrocell driver");
1015+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)