Allow to build coresight as modules. This greatly enhances developer
efficiency by allowing the development to take place exclusively on the
target, and without needing to reboot in between changes.
- Kconfig bools become tristates, to allow =m
- use -objs to denote merge object directives in Makefile, adds a
coresight-core nomenclature for the base module.
- Export core functions so as to be able to be used by
non-core modules.
- add a coresight_exit() that unregisters the coresight bus, add
remove fns for most others.
- fix up modules with ID tables for autoloading on boot
Cc: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Signed-off-by: Kim Phillips <kim.phillips@xxxxxxx>
diff --git a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c
index fc742215ab05..bc42b8022556 100644
--- a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c
@@ -37,7 +37,12 @@ struct replicator_state {
static int replicator_enable(struct coresight_device *csdev, int inport,
int outport)
{
- struct replicator_state *drvdata = dev_get_drvdata(csdev->dev.parent);
+ struct device *parent_dev = csdev->dev.parent;
+ struct replicator_state *drvdata = dev_get_drvdata(parent_dev);
+ struct module *module = parent_dev->driver->owner;
+
+ if (!try_module_get(module))
+ return -ENODEV;
CS_UNLOCK(drvdata->base);
+MODULE_DEVICE_TABLE(amba, replicator_ids);
+
static struct amba_driver replicator_driver = {
.drv = {
.name = "coresight-dynamic-replicator",
@@ -207,9 +226,10 @@ static struct amba_driver replicator_driver = {
.suppress_bind_attrs = true,
},
.probe = replicator_probe,
+ .remove = replicator_remove,
.id_table = replicator_ids,
};
+MODULE_DEVICE_TABLE(amba, etm4_ids);
+
static struct amba_driver etm4x_driver = {
.drv = {
.name = "coresight-etm4x",
+ .owner = THIS_MODULE,
.suppress_bind_attrs = true,
},
.probe = etm4_probe,
+ .remove = etm4_remove,
.id_table = etm4_ids,
};
-builtin_amba_driver(etm4x_driver);
+module_amba_driver(etm4x_driver);