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

Configure Feed

Select the types of activity you want to include in your feed.

clocksource/drivers/vf-pit: Register the clocksource from the driver

The function clocksource_mmio_init() uses its own global static
clocksource variable making no possible to have several instances of a
clocksource using this function. In order to support that, let's add
the clocksource structure to the pit structure and use the
clocksource_register_hz() function instead.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20250804152344.1109310-10-daniel.lezcano@linaro.org

+18 -2
+18 -2
drivers/clocksource/timer-vf-pit.c
··· 44 44 return container_of(ced, struct pit_timer, ced); 45 45 } 46 46 47 + static inline struct pit_timer *cs_to_pit(struct clocksource *cs) 48 + { 49 + return container_of(cs, struct pit_timer, cs); 50 + } 51 + 47 52 static inline void pit_timer_enable(struct pit_timer *pit) 48 53 { 49 54 writel(PITTCTRL_TEN | PITTCTRL_TIE, pit->clkevt_base + PITTCTRL); ··· 69 64 return ~readl(clksrc_base + PITCVAL); 70 65 } 71 66 67 + static u64 pit_timer_clocksource_read(struct clocksource *cs) 68 + { 69 + struct pit_timer *pit = cs_to_pit(cs); 70 + 71 + return (u64)~readl(pit->clksrc_base + PITCVAL); 72 + } 73 + 72 74 static int __init pit_clocksource_init(struct pit_timer *pit, void __iomem *base, 73 75 unsigned long rate) 74 76 { ··· 85 73 * the channels 0 and 1 unused for anyone else who needs them 86 74 */ 87 75 pit->clksrc_base = base + PIT_CH(2); 76 + pit->cs.name = "vf-pit"; 77 + pit->cs.rating = 300; 78 + pit->cs.read = pit_timer_clocksource_read; 79 + pit->cs.mask = CLOCKSOURCE_MASK(32); 80 + pit->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS; 88 81 89 82 /* set the max load value and start the clock source counter */ 90 83 writel(0, pit->clksrc_base + PITTCTRL); ··· 100 83 101 84 sched_clock_register(pit_read_sched_clock, 32, rate); 102 85 103 - return clocksource_mmio_init(pit->clksrc_base + PITCVAL, "vf-pit", rate, 104 - 300, 32, clocksource_mmio_readl_down); 86 + return clocksource_register_hz(&pit->cs, rate); 105 87 } 106 88 107 89 static int pit_set_next_event(unsigned long delta, struct clock_event_device *ced)