summaryrefslogtreecommitdiff
path: root/drivers/hwtracing/coresight/coresight-etm3x-core.c
diff options
context:
space:
mode:
authorJames Clark <james.clark@arm.com>2024-01-29 15:40:41 +0000
committerSuzuki K Poulose <suzuki.poulose@arm.com>2024-02-12 10:21:38 +0000
commitd724f65218b994da234081df5dfe417c23802a65 (patch)
tree4e9ffdd813269f25fbdfdbe89ff7e3db5faf744f /drivers/hwtracing/coresight/coresight-etm3x-core.c
parent812265e26ed3ac76d3a131709d8755bafcf31b58 (diff)
coresight: Add helper for atomically taking the device
Now that mode is in struct coresight_device, this pattern can be wrapped in a helper. Signed-off-by: James Clark <james.clark@arm.com> Link: https://lore.kernel.org/r/20240129154050.569566-11-james.clark@arm.com Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Diffstat (limited to 'drivers/hwtracing/coresight/coresight-etm3x-core.c')
-rw-r--r--drivers/hwtracing/coresight/coresight-etm3x-core.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c
index de53c3e8db29..c301f6a5f065 100644
--- a/drivers/hwtracing/coresight/coresight-etm3x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c
@@ -556,14 +556,12 @@ static int etm_enable(struct coresight_device *csdev, struct perf_event *event,
enum cs_mode mode)
{
int ret;
- u32 val;
struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
- val = local_cmpxchg(&drvdata->csdev->mode, CS_MODE_DISABLED, mode);
-
- /* Someone is already using the tracer */
- if (val)
+ if (!coresight_take_mode(csdev, mode)) {
+ /* Someone is already using the tracer */
return -EBUSY;
+ }
switch (mode) {
case CS_MODE_SYSFS: