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: Enable and disable module on error

Encapsulate the calls to writel to enable and disable the PIT module
and make use of them. Add the missing module disablement in case of
error.

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

+17 -4
+17 -4
drivers/clocksource/timer-vf-pit.c
··· 13 13 /* 14 14 * Each pit takes 0x10 Bytes register space 15 15 */ 16 - #define PITMCR 0x00 17 16 #define PIT0_OFFSET 0x100 18 17 #define PIT_CH(n) (PIT0_OFFSET + 0x10 * (n)) 19 18 19 + #define PITMCR(__base) (__base) 20 + 21 + #define PITMCR_FRZ BIT(0) 20 22 #define PITMCR_MDIS BIT(1) 21 23 22 24 #define PITLDVAL(__base) (__base) ··· 52 50 static inline struct pit_timer *cs_to_pit(struct clocksource *cs) 53 51 { 54 52 return container_of(cs, struct pit_timer, cs); 53 + } 54 + 55 + static inline void pit_module_enable(void __iomem *base) 56 + { 57 + writel(0, PITMCR(base)); 58 + } 59 + 60 + static inline void pit_module_disable(void __iomem *base) 61 + { 62 + writel(PITMCR_MDIS, PITMCR(base)); 55 63 } 56 64 57 65 static inline void pit_timer_enable(struct pit_timer *pit) ··· 266 254 clk_rate = clk_get_rate(pit_clk); 267 255 268 256 /* enable the pit module */ 269 - writel(~PITMCR_MDIS, timer_base + PITMCR); 257 + pit_module_enable(timer_base); 270 258 271 259 ret = pit_clocksource_init(pit, name, timer_base, clk_rate); 272 260 if (ret) 273 - goto out_disable_unprepare; 261 + goto out_pit_module_disable; 274 262 275 263 ret = pit_clockevent_init(pit, name, timer_base, clk_rate, irq, 0); 276 264 if (ret) ··· 280 268 281 269 out_pit_clocksource_unregister: 282 270 clocksource_unregister(&pit->cs); 283 - out_disable_unprepare: 271 + out_pit_module_disable: 272 + pit_module_disable(timer_base); 284 273 clk_disable_unprepare(pit_clk); 285 274 out_clk_put: 286 275 clk_put(pit_clk);