Minor refactoring to use macro for index mask.

Signed-off-by: Leo Yan <[email protected]>
---
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 2 +-
 tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c 
b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
index bbc8b0178f67..ad8797f12d36 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
@@ -133,7 +133,7 @@ static int arm_spe_get_context(const unsigned char *buf, 
size_t len,
                               struct arm_spe_pkt *packet)
 {
        packet->type = ARM_SPE_CONTEXT;
-       packet->index = buf[0] & 0x3;
+       packet->index = buf[0] & SPE_CTX_PKT_HDR_INDEX_MASK;
        return arm_spe_get_payload(buf, len, 0, packet);
 }
 
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h 
b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
index d09082fc9853..db9f124fb1f4 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
@@ -82,6 +82,9 @@ struct arm_spe_pkt {
 #define SPE_ADDR_PKT_INST_VA_EL2               (2)
 #define SPE_ADDR_PKT_INST_VA_EL3               (3)
 
+/* Context packet header */
+#define SPE_CTX_PKT_HDR_INDEX_MASK             (0x3)
+
 const char *arm_spe_pkt_name(enum arm_spe_pkt_type);
 
 int arm_spe_get_packet(const unsigned char *buf, size_t len,
-- 
2.17.1

Reply via email to