Skip to content

Commit 7e38829

Browse files
coresight: moving coresight_simple_func() to header file
Macro "coresight_simple_func()" can be used by several drivers. As such making the structure type generic and moving to a globally available header file. That way individual drivers can use the functionality by simply specifying the structure they need to work with. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 154f3520fe1cdef9009909dc62828eb2d7635631)
1 parent a77728f commit 7e38829

3 files changed

Lines changed: 51 additions & 55 deletions

File tree

drivers/hwtracing/coresight/coresight-etm3x-sysfs.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,26 +1221,19 @@ static struct attribute *coresight_etm_attrs[] = {
12211221
NULL,
12221222
};
12231223

1224-
#define coresight_simple_func(name, offset) \
1225-
static ssize_t name##_show(struct device *_dev, \
1226-
struct device_attribute *attr, char *buf) \
1227-
{ \
1228-
struct etm_drvdata *drvdata = dev_get_drvdata(_dev->parent); \
1229-
return scnprintf(buf, PAGE_SIZE, "0x%x\n", \
1230-
readl_relaxed(drvdata->base + offset)); \
1231-
} \
1232-
DEVICE_ATTR_RO(name)
1233-
1234-
coresight_simple_func(etmccr, ETMCCR);
1235-
coresight_simple_func(etmccer, ETMCCER);
1236-
coresight_simple_func(etmscr, ETMSCR);
1237-
coresight_simple_func(etmidr, ETMIDR);
1238-
coresight_simple_func(etmcr, ETMCR);
1239-
coresight_simple_func(etmtraceidr, ETMTRACEIDR);
1240-
coresight_simple_func(etmteevr, ETMTEEVR);
1241-
coresight_simple_func(etmtssvr, ETMTSSCR);
1242-
coresight_simple_func(etmtecr1, ETMTECR1);
1243-
coresight_simple_func(etmtecr2, ETMTECR2);
1224+
#define coresight_etm3x_simple_func(name, offset) \
1225+
coresight_simple_func(struct etm_drvdata, name, offset)
1226+
1227+
coresight_etm3x_simple_func(etmccr, ETMCCR);
1228+
coresight_etm3x_simple_func(etmccer, ETMCCER);
1229+
coresight_etm3x_simple_func(etmscr, ETMSCR);
1230+
coresight_etm3x_simple_func(etmidr, ETMIDR);
1231+
coresight_etm3x_simple_func(etmcr, ETMCR);
1232+
coresight_etm3x_simple_func(etmtraceidr, ETMTRACEIDR);
1233+
coresight_etm3x_simple_func(etmteevr, ETMTEEVR);
1234+
coresight_etm3x_simple_func(etmtssvr, ETMTSSCR);
1235+
coresight_etm3x_simple_func(etmtecr1, ETMTECR1);
1236+
coresight_etm3x_simple_func(etmtecr2, ETMTECR2);
12441237

12451238
static struct attribute *coresight_etm_mgmt_attrs[] = {
12461239
&dev_attr_etmccr.attr,

drivers/hwtracing/coresight/coresight-etm4x-sysfs.c

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,29 +2039,22 @@ static struct attribute *coresight_etmv4_attrs[] = {
20392039
NULL,
20402040
};
20412041

2042-
#define coresight_simple_func(name, offset) \
2043-
static ssize_t name##_show(struct device *_dev, \
2044-
struct device_attribute *attr, char *buf) \
2045-
{ \
2046-
struct etmv4_drvdata *drvdata = dev_get_drvdata(_dev->parent); \
2047-
return scnprintf(buf, PAGE_SIZE, "0x%x\n", \
2048-
readl_relaxed(drvdata->base + offset)); \
2049-
} \
2050-
DEVICE_ATTR_RO(name)
2051-
2052-
coresight_simple_func(trcoslsr, TRCOSLSR);
2053-
coresight_simple_func(trcpdcr, TRCPDCR);
2054-
coresight_simple_func(trcpdsr, TRCPDSR);
2055-
coresight_simple_func(trclsr, TRCLSR);
2056-
coresight_simple_func(trcconfig, TRCCONFIGR);
2057-
coresight_simple_func(trctraceid, TRCTRACEIDR);
2058-
coresight_simple_func(trcauthstatus, TRCAUTHSTATUS);
2059-
coresight_simple_func(trcdevid, TRCDEVID);
2060-
coresight_simple_func(trcdevtype, TRCDEVTYPE);
2061-
coresight_simple_func(trcpidr0, TRCPIDR0);
2062-
coresight_simple_func(trcpidr1, TRCPIDR1);
2063-
coresight_simple_func(trcpidr2, TRCPIDR2);
2064-
coresight_simple_func(trcpidr3, TRCPIDR3);
2042+
#define coresight_etm4x_simple_func(name, offset) \
2043+
coresight_simple_func(struct etmv4_drvdata, name, offset)
2044+
2045+
coresight_etm4x_simple_func(trcoslsr, TRCOSLSR);
2046+
coresight_etm4x_simple_func(trcpdcr, TRCPDCR);
2047+
coresight_etm4x_simple_func(trcpdsr, TRCPDSR);
2048+
coresight_etm4x_simple_func(trclsr, TRCLSR);
2049+
coresight_etm4x_simple_func(trcconfig, TRCCONFIGR);
2050+
coresight_etm4x_simple_func(trctraceid, TRCTRACEIDR);
2051+
coresight_etm4x_simple_func(trcauthstatus, TRCAUTHSTATUS);
2052+
coresight_etm4x_simple_func(trcdevid, TRCDEVID);
2053+
coresight_etm4x_simple_func(trcdevtype, TRCDEVTYPE);
2054+
coresight_etm4x_simple_func(trcpidr0, TRCPIDR0);
2055+
coresight_etm4x_simple_func(trcpidr1, TRCPIDR1);
2056+
coresight_etm4x_simple_func(trcpidr2, TRCPIDR2);
2057+
coresight_etm4x_simple_func(trcpidr3, TRCPIDR3);
20652058

20662059
static struct attribute *coresight_etmv4_mgmt_attrs[] = {
20672060
&dev_attr_trcoslsr.attr,
@@ -2080,19 +2073,19 @@ static struct attribute *coresight_etmv4_mgmt_attrs[] = {
20802073
NULL,
20812074
};
20822075

2083-
coresight_simple_func(trcidr0, TRCIDR0);
2084-
coresight_simple_func(trcidr1, TRCIDR1);
2085-
coresight_simple_func(trcidr2, TRCIDR2);
2086-
coresight_simple_func(trcidr3, TRCIDR3);
2087-
coresight_simple_func(trcidr4, TRCIDR4);
2088-
coresight_simple_func(trcidr5, TRCIDR5);
2076+
coresight_etm4x_simple_func(trcidr0, TRCIDR0);
2077+
coresight_etm4x_simple_func(trcidr1, TRCIDR1);
2078+
coresight_etm4x_simple_func(trcidr2, TRCIDR2);
2079+
coresight_etm4x_simple_func(trcidr3, TRCIDR3);
2080+
coresight_etm4x_simple_func(trcidr4, TRCIDR4);
2081+
coresight_etm4x_simple_func(trcidr5, TRCIDR5);
20892082
/* trcidr[6,7] are reserved */
2090-
coresight_simple_func(trcidr8, TRCIDR8);
2091-
coresight_simple_func(trcidr9, TRCIDR9);
2092-
coresight_simple_func(trcidr10, TRCIDR10);
2093-
coresight_simple_func(trcidr11, TRCIDR11);
2094-
coresight_simple_func(trcidr12, TRCIDR12);
2095-
coresight_simple_func(trcidr13, TRCIDR13);
2083+
coresight_etm4x_simple_func(trcidr8, TRCIDR8);
2084+
coresight_etm4x_simple_func(trcidr9, TRCIDR9);
2085+
coresight_etm4x_simple_func(trcidr10, TRCIDR10);
2086+
coresight_etm4x_simple_func(trcidr11, TRCIDR11);
2087+
coresight_etm4x_simple_func(trcidr12, TRCIDR12);
2088+
coresight_etm4x_simple_func(trcidr13, TRCIDR13);
20962089

20972090
static struct attribute *coresight_etmv4_trcidr_attrs[] = {
20982091
&dev_attr_trcidr0.attr,

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
#define ETM_MODE_EXCL_KERN BIT(30)
3838
#define ETM_MODE_EXCL_USER BIT(31)
3939

40+
#define coresight_simple_func(type, name, offset) \
41+
static ssize_t name##_show(struct device *_dev, \
42+
struct device_attribute *attr, char *buf) \
43+
{ \
44+
type *drvdata = dev_get_drvdata(_dev->parent); \
45+
return scnprintf(buf, PAGE_SIZE, "0x%x\n", \
46+
readl_relaxed(drvdata->base + offset)); \
47+
} \
48+
static DEVICE_ATTR_RO(name)
49+
4050
enum cs_mode {
4151
CS_MODE_DISABLED,
4252
CS_MODE_SYSFS,

0 commit comments

Comments
 (0)