Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mathieu Poirier and committed by
Greg Kroah-Hartman
154f3520 37fbbdbd

+49 -53
+12 -19
drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
··· 1221 1221 NULL, 1222 1222 }; 1223 1223 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) 1224 + #define coresight_etm3x_simple_func(name, offset) \ 1225 + coresight_simple_func(struct etm_drvdata, name, offset) 1233 1226 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); 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); 1244 1237 1245 1238 static struct attribute *coresight_etm_mgmt_attrs[] = { 1246 1239 &dev_attr_etmccr.attr,
+27 -34
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
··· 2039 2039 NULL, 2040 2040 }; 2041 2041 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) 2042 + #define coresight_etm4x_simple_func(name, offset) \ 2043 + coresight_simple_func(struct etmv4_drvdata, name, offset) 2051 2044 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); 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); 2065 2058 2066 2059 static struct attribute *coresight_etmv4_mgmt_attrs[] = { 2067 2060 &dev_attr_trcoslsr.attr, ··· 2073 2080 NULL, 2074 2081 }; 2075 2082 2076 - coresight_simple_func(trcidr0, TRCIDR0); 2077 - coresight_simple_func(trcidr1, TRCIDR1); 2078 - coresight_simple_func(trcidr2, TRCIDR2); 2079 - coresight_simple_func(trcidr3, TRCIDR3); 2080 - coresight_simple_func(trcidr4, TRCIDR4); 2081 - coresight_simple_func(trcidr5, TRCIDR5); 2083 + coresight_etm4x_simple_func(trcidr0, TRCIDR0); 2084 + coresight_etm4x_simple_func(trcidr1, TRCIDR1); 2085 + coresight_etm4x_simple_func(trcidr2, TRCIDR2); 2086 + coresight_etm4x_simple_func(trcidr3, TRCIDR3); 2087 + coresight_etm4x_simple_func(trcidr4, TRCIDR4); 2088 + coresight_etm4x_simple_func(trcidr5, TRCIDR5); 2082 2089 /* trcidr[6,7] are reserved */ 2083 - coresight_simple_func(trcidr8, TRCIDR8); 2084 - coresight_simple_func(trcidr9, TRCIDR9); 2085 - coresight_simple_func(trcidr10, TRCIDR10); 2086 - coresight_simple_func(trcidr11, TRCIDR11); 2087 - coresight_simple_func(trcidr12, TRCIDR12); 2088 - coresight_simple_func(trcidr13, TRCIDR13); 2090 + coresight_etm4x_simple_func(trcidr8, TRCIDR8); 2091 + coresight_etm4x_simple_func(trcidr9, TRCIDR9); 2092 + coresight_etm4x_simple_func(trcidr10, TRCIDR10); 2093 + coresight_etm4x_simple_func(trcidr11, TRCIDR11); 2094 + coresight_etm4x_simple_func(trcidr12, TRCIDR12); 2095 + coresight_etm4x_simple_func(trcidr13, TRCIDR13); 2089 2096 2090 2097 static struct attribute *coresight_etmv4_trcidr_attrs[] = { 2091 2098 &dev_attr_trcidr0.attr,
+10
drivers/hwtracing/coresight/coresight-priv.h
··· 37 37 #define ETM_MODE_EXCL_KERN BIT(30) 38 38 #define ETM_MODE_EXCL_USER BIT(31) 39 39 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 + 40 50 enum cs_mode { 41 51 CS_MODE_DISABLED, 42 52 CS_MODE_SYSFS,