Re: [PATCH v2] clocksource: Add node counter timer driver for MIPS/Loongson64

From: Thomas Gleixner
Date: Mon May 27 2024 - 11:51:34 EST


Jiaxun!

On Fri, May 17 2024 at 18:13, Jiaxun Yang wrote:

> +static void __iomem *nodecnt_reg;
> +static u64 (*nodecnt_read_fn)(void);
> +
> +static u64 notrace nodecnt_read_2x32(void)
> +{
> + unsigned int hi, hi2, lo;
> +
> + do {
> + hi = readl_relaxed(nodecnt_reg + 4);
> + lo = readl_relaxed(nodecnt_reg);
> + hi2 = readl_relaxed(nodecnt_reg + 4);
> + } while (hi2 != hi);
> +
> + return (((u64) hi) << 32) + lo;
> +}
> +
> +static u64 notrace nodecnt_read_64(void)
> +{
> + return readq_relaxed(nodecnt_reg);
> +}
> +
> +static u64 notrace nodecnt_read_csr(void)
> +{
> + return csr_readq(LOONGSON_CSR_NODECNT);
> +}
> +
> +static u64 nodecnt_clocksource_read(struct clocksource *cs)
> +{
> + return nodecnt_read_fn();

What's this indirection for? Why dont you update

> +static struct clocksource nodecnt_clocksource = {
> + .name = "nodecnt",
> + .read = nodecnt_clocksource_read,

the read function pointer here and spare the indirection?

Thanks

tglx