aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwtracing/coresight/coresight-priv.h
diff options
context:
space:
mode:
authorGravatar James Clark <james.clark@arm.com> 2022-08-30 18:26:11 +0100
committerGravatar Mathieu Poirier <mathieu.poirier@linaro.org> 2022-08-31 10:55:28 -0600
commit08e9fa5f3663eaab20ea3430023d1dfbf60d29f5 (patch)
tree6af73141bab067c0afe70892410597f342a60d32 /drivers/hwtracing/coresight/coresight-priv.h
parentcoresight: Simplify sysfs accessors by using csdev_access abstraction (diff)
downloadlinux-08e9fa5f3663eaab20ea3430023d1dfbf60d29f5.tar.gz
linux-08e9fa5f3663eaab20ea3430023d1dfbf60d29f5.tar.bz2
linux-08e9fa5f3663eaab20ea3430023d1dfbf60d29f5.zip
coresight: Re-use same function for similar sysfs register accessors
Currently each accessor macro creates an identical function which wastes space in the text area and pollutes the ftrace function names. Change it so that the same function is used, but the register to access is passed in as parameter rather than baked into each function. Signed-off-by: James Clark <james.clark@arm.com> Reviewed-by: Mike Leach <mike.leach@linaro.org> Link: https://lore.kernel.org/r/20220830172614.340962-4-james.clark@arm.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'drivers/hwtracing/coresight/coresight-priv.h')
-rw-r--r--drivers/hwtracing/coresight/coresight-priv.h40
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h
index cf8ae768106e..07b392bfdbcd 100644
--- a/drivers/hwtracing/coresight/coresight-priv.h
+++ b/drivers/hwtracing/coresight/coresight-priv.h
@@ -39,24 +39,30 @@
#define ETM_MODE_EXCL_KERN BIT(30)
#define ETM_MODE_EXCL_USER BIT(31)
+struct cs_pair_attribute {
+ struct device_attribute attr;
+ s32 lo_off;
+ s32 hi_off;
+};
-#define __coresight_simple_show(name, lo_off, hi_off) \
-static ssize_t name##_show(struct device *_dev, \
- struct device_attribute *attr, char *buf) \
-{ \
- struct coresight_device *csdev = container_of(_dev, struct coresight_device, dev); \
- u64 val; \
- pm_runtime_get_sync(_dev->parent); \
- val = csdev_access_relaxed_read_pair(&csdev->access, lo_off, hi_off); \
- pm_runtime_put_sync(_dev->parent); \
- return scnprintf(buf, PAGE_SIZE, "0x%llx\n", val); \
-} \
-static DEVICE_ATTR_RO(name)
-
-#define coresight_simple_reg32(name, offset) \
- __coresight_simple_show(name, offset, -1)
-#define coresight_simple_reg64(name, lo_off, hi_off) \
- __coresight_simple_show(name, lo_off, hi_off)
+extern ssize_t coresight_simple_show(struct device *_dev,
+ struct device_attribute *attr, char *buf);
+
+#define coresight_simple_reg32(name, offset) \
+ (&((struct cs_pair_attribute[]) { \
+ { \
+ __ATTR(name, 0444, coresight_simple_show, NULL), \
+ offset, -1 \
+ } \
+ })[0].attr.attr)
+
+#define coresight_simple_reg64(name, lo_off, hi_off) \
+ (&((struct cs_pair_attribute[]) { \
+ { \
+ __ATTR(name, 0444, coresight_simple_show, NULL), \
+ lo_off, hi_off \
+ } \
+ })[0].attr.attr)
extern const u32 coresight_barrier_pkt[4];
#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt))