[PATCH v5 03/13] coresight: Refactor etm4_config_timestamp_event()
Mike Leach
mike.leach at linaro.org
Thu Nov 20 06:39:06 PST 2025
Hi Leo,
On Thu, 20 Nov 2025 at 14:25, Leo Yan <leo.yan at arm.com> wrote:
>
> On Thu, Nov 20, 2025 at 02:18:21PM +0000, Coresight ML wrote:
>
> [...]
>
> > Maybe define a general macro but with extra checking:
> >
> > #define TRCCNTCTLRn_RLDEVENT_MASK GENMASK(15, 8)
> >
> > #define ETM4_RS_SEL_EVENT(paired, sel) ({ \
> > if (paired) \
> > assert(!(sel & ~GENMASK(3, 0))); \
> > else \
> > assert(!(sel & ~GENMASK(4, 0))); \
> > FIELD_PREP(TRCCNTCTLRn_RLDEVENT_MASK, \
> > ((paird << 7) | sel)); \
> > })
>
> It'd be better to use BUILD_BUG_ON() instead of assert().
That is a decent option - except I would have ETM4_RS_SEL_EVENT(mask,
paired, sel) - so it can be used for every register that has the form
<REGNAME>_<EVENTFIEILD>_MASK
It is slightly vulnerable though if someone passes something that is
not 1/0 for paired - which is why I preferred the two separate macros.
Mike
--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
More information about the linux-arm-kernel
mailing list