Skip to content

Commit 3c3fd1a

Browse files
Tingwei Zhanggregkh
authored andcommitted
coresight: cti: Allow cti to be built as a module
Allow to build coresight-cti as a module, for ease of development. - Kconfig becomes a tristate, to allow =m - append -core to source file name to allow module to be called coresight-cti by the Makefile - add an cti_remove function, for module unload - add a MODULE_DEVICE_TABLE for autoloading on boot - move cti_remove_conn_xrefs to cti_remove since all sysfs links have gone when system calls device_release. Reviewed-by Mike Leach <mike.leach@linaro.org> Tested-by: Mike Leach <mike.leach@linaro.org> 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-22-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f02b089 commit 3c3fd1a

5 files changed

Lines changed: 28 additions & 5 deletions

File tree

‎drivers/hwtracing/coresight/Kconfig‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ config CORESIGHT_CPU_DEBUG
136136
module will be called coresight-cpu-debug.
137137

138138
config CORESIGHT_CTI
139-
bool "CoreSight Cross Trigger Interface (CTI) driver"
139+
tristate "CoreSight Cross Trigger Interface (CTI) driver"
140140
depends on ARM || ARM64
141141
help
142142
This driver provides support for CoreSight CTI and CTM components.
@@ -147,6 +147,9 @@ config CORESIGHT_CTI
147147
halt compared to disabling sources and sinks normally in driver
148148
software.
149149

150+
To compile this driver as a module, choose M here: the
151+
module will be called coresight-cti.
152+
150153
config CORESIGHT_CTI_INTEGRATION_REGS
151154
bool "Access CTI CoreSight Integration Registers"
152155
depends on CORESIGHT_CTI

‎drivers/hwtracing/coresight/Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o
1919
obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o
2020
obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o
2121
obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o
22-
obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \
23-
coresight-cti-platform.o \
24-
coresight-cti-sysfs.o
22+
obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o
23+
coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \
24+
coresight-cti-sysfs.o

drivers/hwtracing/coresight/coresight-cti.c renamed to drivers/hwtracing/coresight/coresight-cti-core.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@ static void cti_device_release(struct device *dev)
822822
struct cti_drvdata *ect_item, *ect_tmp;
823823

824824
mutex_lock(&ect_mutex);
825-
cti_remove_conn_xrefs(drvdata);
826825
cti_pm_release(drvdata);
827826

828827
/* remove from the list */
@@ -837,6 +836,18 @@ static void cti_device_release(struct device *dev)
837836
if (drvdata->csdev_release)
838837
drvdata->csdev_release(dev);
839838
}
839+
static int __exit cti_remove(struct amba_device *adev)
840+
{
841+
struct cti_drvdata *drvdata = dev_get_drvdata(&adev->dev);
842+
843+
mutex_lock(&ect_mutex);
844+
cti_remove_conn_xrefs(drvdata);
845+
mutex_unlock(&ect_mutex);
846+
847+
coresight_unregister(drvdata->csdev);
848+
849+
return 0;
850+
}
840851

841852
static int cti_probe(struct amba_device *adev, const struct amba_id *id)
842853
{
@@ -957,13 +968,16 @@ static const struct amba_id cti_ids[] = {
957968
{ 0, 0},
958969
};
959970

971+
MODULE_DEVICE_TABLE(amba, cti_ids);
972+
960973
static struct amba_driver cti_driver = {
961974
.drv = {
962975
.name = "coresight-cti",
963976
.owner = THIS_MODULE,
964977
.suppress_bind_attrs = true,
965978
},
966979
.probe = cti_probe,
980+
.remove = cti_remove,
967981
.id_table = cti_ids,
968982
};
969983

@@ -986,3 +1000,7 @@ static void __exit cti_exit(void)
9861000

9871001
module_init(cti_init);
9881002
module_exit(cti_exit);
1003+
1004+
MODULE_AUTHOR("Mike Leach <mike.leach@linaro.org>");
1005+
MODULE_DESCRIPTION("Arm CoreSight CTI Driver");
1006+
MODULE_LICENSE("GPL v2");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode)
7575
}
7676
return csdev;
7777
}
78+
EXPORT_SYMBOL_GPL(coresight_find_csdev_by_fwnode);
7879

7980
#ifdef CONFIG_OF
8081
static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep)

‎drivers/hwtracing/coresight/coresight.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev,
288288
csdev->ect_dev = ect_csdev;
289289
mutex_unlock(&coresight_mutex);
290290
}
291+
EXPORT_SYMBOL_GPL(coresight_set_assoc_ectdev_mutex);
291292

292293
static int coresight_enable_sink(struct coresight_device *csdev,
293294
u32 mode, void *data)

0 commit comments

Comments
 (0)