static DEFINE_PER_CPU(struct clock_event_device, gic_clockevent_device);
 static int gic_timer_irq;
 static unsigned int gic_frequency;
+static unsigned int gic_count_width;
 static bool __read_mostly gic_clock_unstable;
 
 static void gic_clocksource_unstable(char *reason);
 
 static int __init __gic_clocksource_init(void)
 {
-       unsigned int count_width;
        int ret;
 
        /* Set clocksource mask. */
-       count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
-       count_width >>= __ffs(GIC_CONFIG_COUNTBITS);
-       count_width *= 4;
-       count_width += 32;
-       gic_clocksource.mask = CLOCKSOURCE_MASK(count_width);
+       gic_count_width = read_gic_config() & GIC_CONFIG_COUNTBITS;
+       gic_count_width >>= __ffs(GIC_CONFIG_COUNTBITS);
+       gic_count_width *= 4;
+       gic_count_width += 32;
+       gic_clocksource.mask = CLOCKSOURCE_MASK(gic_count_width);
 
        /* Calculate a somewhat reasonable rating value. */
        if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ))
        if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) {
                sched_clock_register(mips_cm_is64 ?
                                     gic_read_count_64 : gic_read_count_2x32,
-                                    64, gic_frequency);
+                                    gic_count_width, gic_frequency);
        }
 
        return 0;