diff options
author | James Clark <james.clark@arm.com> | 2024-01-29 15:40:41 +0000 |
---|---|---|
committer | Suzuki K Poulose <suzuki.poulose@arm.com> | 2024-02-12 10:21:38 +0000 |
commit | d724f65218b994da234081df5dfe417c23802a65 (patch) | |
tree | 4e9ffdd813269f25fbdfdbe89ff7e3db5faf744f /include/linux/coresight.h | |
parent | 812265e26ed3ac76d3a131709d8755bafcf31b58 (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 'include/linux/coresight.h')
-rw-r--r-- | include/linux/coresight.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/coresight.h b/include/linux/coresight.h index ecf4b8aecca8..414bcbbdaf62 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -580,6 +580,17 @@ static inline bool coresight_is_percpu_sink(struct coresight_device *csdev) (csdev->subtype.sink_subtype == CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM); } +/* + * Atomically try to take the device and set a new mode. Returns true on + * success, false if the device is already taken by someone else. + */ +static inline bool coresight_take_mode(struct coresight_device *csdev, + enum cs_mode new_mode) +{ + return local_cmpxchg(&csdev->mode, CS_MODE_DISABLED, new_mode) == + CS_MODE_DISABLED; +} + extern struct coresight_device * coresight_register(struct coresight_desc *desc); extern void coresight_unregister(struct coresight_device *csdev); |