Skip to content

Commit b97f029

Browse files
vireshkKAGA-KOKO
authored andcommitted
tick: Remove code duplication in tick_handle_periodic()
tick_handle_periodic() is calling ktime_add() at two places, first before the infinite loop and then at the end of infinite loop. We can rearrange code a bit to fix code duplication here. It looks quite simple and shouldn't break anything, I guess :) Signed-off-by: Viresh Kumar <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/be3481e8f3f71df694a4b43623254fc93ca51b59.1395735873.git.viresh.kumar@linaro.org Signed-off-by: Thomas Gleixner <[email protected]>
1 parent cacb3c7 commit b97f029

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/time/tick-common.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,19 @@ static void tick_periodic(int cpu)
9898
void tick_handle_periodic(struct clock_event_device *dev)
9999
{
100100
int cpu = smp_processor_id();
101-
ktime_t next;
101+
ktime_t next = dev->next_event;
102102

103103
tick_periodic(cpu);
104104

105105
if (dev->mode != CLOCK_EVT_MODE_ONESHOT)
106106
return;
107-
/*
108-
* Setup the next period for devices, which do not have
109-
* periodic mode:
110-
*/
111-
next = ktime_add(dev->next_event, tick_period);
112107
for (;;) {
108+
/*
109+
* Setup the next period for devices, which do not have
110+
* periodic mode:
111+
*/
112+
next = ktime_add(next, tick_period);
113+
113114
if (!clockevents_program_event(dev, next, false))
114115
return;
115116
/*
@@ -123,7 +124,6 @@ void tick_handle_periodic(struct clock_event_device *dev)
123124
*/
124125
if (timekeeping_valid_for_hres())
125126
tick_periodic(cpu);
126-
next = ktime_add(next, tick_period);
127127
}
128128
}
129129

0 commit comments

Comments
 (0)