On 08/21/2020 04:44 AM, Tingwei Zhang wrote:
From: Kim Phillips <[email protected]>

Allow to build coresight-etm3x 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-etm3x by the Makefile
- add an etm_remove function, for module unload
- add a MODULE_DEVICE_TABLE for autoloading on boot

Cc: Mathieu Poirier <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Suzuki K Poulose <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Russell King <[email protected]>
Signed-off-by: Kim Phillips <[email protected]>
Signed-off-by: Tingwei Zhang <[email protected]>
Reviewed-by: Mike Leach <[email protected]>


diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c 
b/drivers/hwtracing/coresight/coresight-etm3x-core.c
similarity index 97%
rename from drivers/hwtracing/coresight/coresight-etm3x.c
rename to drivers/hwtracing/coresight/coresight-etm3x-core.c
index bf22dcfd3327..ba9c86497acb 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c
@@ -895,6 +895,23 @@ static int etm_probe(struct amba_device *adev, const 
struct amba_id *id)
        return ret;
  }
+static int __exit etm_remove(struct amba_device *adev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       etm_perf_symlink(drvdata->csdev, false);
+
+       if (--etm_count == 0) {
+               cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
+               if (hp_online)
+                       cpuhp_remove_state_nocalls(hp_online);
+       }
+
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+

Don't we need to fix the races like we did for ETMv4 ?

Suzuki

Reply via email to