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: Consolidate calls to pit_*_disable/enable

The difference between the pit_clocksource_enable() and
pit_clocksource_disable() is only setting the TIF flag for the
clockevent. Let's group them and pass the TIF flag parameter to the
function so we save some lines of code. But as the base address is
different regarding if it is a clocksource or a clockevent, we pass
the base address in parameter instead of the struct pit_timer.

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

+13 -21
+13 -21
drivers/clocksource/timer-vf-pit.c
··· 64 64 writel(PITMCR_MDIS, PITMCR(base)); 65 65 } 66 66 67 - static inline void pit_timer_enable(struct pit_timer *pit) 67 + static inline void pit_timer_enable(void __iomem *base, bool tie) 68 68 { 69 - writel(PITTCTRL_TEN | PITTCTRL_TIE, PITTCTRL(pit->clkevt_base)); 69 + u32 val = PITTCTRL_TEN | (tie ? PITTCTRL_TIE : 0); 70 + 71 + writel(val, PITTCTRL(base)); 70 72 } 71 73 72 - static inline void pit_timer_disable(struct pit_timer *pit) 74 + static inline void pit_timer_disable(void __iomem *base) 73 75 { 74 - writel(0, PITTCTRL(pit->clkevt_base)); 76 + writel(0, PITTCTRL(base)); 75 77 } 76 78 77 79 static inline void pit_timer_set_counter(void __iomem *base, unsigned int cnt) 78 80 { 79 81 writel(cnt, PITLDVAL(base)); 80 - } 81 - 82 - static inline void pit_clocksource_enable(struct pit_timer *pit) 83 - { 84 - writel(PITTCTRL_TEN, PITTCTRL(pit->clksrc_base)); 85 - } 86 - 87 - static inline void pit_clocksource_disable(struct pit_timer *pit) 88 - { 89 - pit_timer_disable(pit); 90 82 } 91 83 92 84 static inline void pit_irq_acknowledge(struct pit_timer *pit) ··· 114 122 pit->cs.flags = CLOCK_SOURCE_IS_CONTINUOUS; 115 123 116 124 /* set the max load value and start the clock source counter */ 117 - pit_clocksource_disable(pit); 125 + pit_timer_disable(pit->clksrc_base); 118 126 pit_timer_set_counter(pit->clksrc_base, ~0); 119 - pit_clocksource_enable(pit); 127 + pit_timer_enable(pit->clksrc_base, 0); 120 128 121 129 sched_clock_base = pit->clksrc_base + PITCVAL_OFFSET; 122 130 sched_clock_register(pit_read_sched_clock, 32, rate); ··· 135 143 * and the PITLAVAL should be set to delta minus one according to pit 136 144 * hardware requirement. 137 145 */ 138 - pit_timer_disable(pit); 146 + pit_timer_disable(pit->clkevt_base); 139 147 pit_timer_set_counter(pit->clkevt_base, delta - 1); 140 - pit_timer_enable(pit); 148 + pit_timer_enable(pit->clkevt_base, true); 141 149 142 150 return 0; 143 151 } ··· 146 154 { 147 155 struct pit_timer *pit = ced_to_pit(ced); 148 156 149 - pit_timer_disable(pit); 157 + pit_timer_disable(pit->clkevt_base); 150 158 151 159 return 0; 152 160 } ··· 174 182 * to stop the counter loop in ONESHOT mode. 175 183 */ 176 184 if (likely(clockevent_state_oneshot(ced))) 177 - pit_timer_disable(pit); 185 + pit_timer_disable(pit->clkevt_base); 178 186 179 187 ced->event_handler(ced); 180 188 ··· 193 201 pit->clkevt_base = base + PIT_CH(3); 194 202 pit->cycle_per_jiffy = rate / (HZ); 195 203 196 - pit_timer_disable(pit); 204 + pit_timer_disable(pit->clkevt_base); 197 205 198 206 pit_irq_acknowledge(pit); 199 207