Skip to content

Commit be9f4ee

Browse files
lifeixjren1
authored andcommitted
hv: timer: pass timer callback function parameter by pointer
Signed-off-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent dace32e commit be9f4ee

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ vlapic_msr(uint32_t msr)
19081908
}
19091909

19101910
/* interrupt context */
1911-
static int tsc_periodic_time(uint64_t data)
1911+
static int tsc_periodic_time(void *data)
19121912
{
19131913
struct vcpu *vcpu = (struct vcpu *)data;
19141914
struct vlapic *vlapic;
@@ -1979,7 +1979,7 @@ vlapic_wrmsr(struct vcpu *vcpu, uint32_t msr, uint64_t val)
19791979

19801980
vlapic->last_timer = update_timer(vlapic->last_timer,
19811981
tsc_periodic_time,
1982-
(long)vcpu,
1982+
(void *)vcpu,
19831983
val);
19841984

19851985
if (vlapic->last_timer < 0) {

hypervisor/arch/x86/timer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ uint64_t tsc_hz = 1000000000;
4141

4242
struct timer {
4343
timer_handle_t func; /* callback if time reached */
44-
uint64_t priv_data; /* func private data */
4544
uint64_t deadline; /* tsc deadline to interrupt */
4645
long handle; /* unique handle for user */
4746
int pcpu_id; /* armed on which CPU */
4847
int id; /* timer ID, used by release */
4948
struct list_head node; /* link all timers */
49+
void *priv_data; /* func private data */
5050
};
5151

5252
struct per_cpu_timers {
@@ -95,7 +95,7 @@ static void release_timer(struct timer *timer)
9595
struct per_cpu_timers *cpu_timer;
9696

9797
cpu_timer = &per_cpu(cpu_timers, timer->pcpu_id);
98-
timer->priv_data = 0;
98+
timer->priv_data = NULL;
9999
timer->func = NULL;
100100
timer->deadline = 0;
101101
bitmap_set(timer->id, &cpu_timer->free_bitmap);
@@ -243,7 +243,7 @@ static void init_timer_pool(void)
243243
for (j = 0; j < MAX_TIMER_ACTIONS; j++) {
244244
timers_pool[j].id = j;
245245
timers_pool[j].pcpu_id = i;
246-
timers_pool[j].priv_data = 0;
246+
timers_pool[j].priv_data = NULL;
247247
timers_pool[j].func = NULL;
248248
timers_pool[j].deadline = 0;
249249
timers_pool[j].handle = -1UL;
@@ -323,7 +323,7 @@ int timer_softirq(int pcpu_id)
323323
* return: handle, this handle is unique and can be used to find back
324324
* this added timer. handle will be invalid after timer expired
325325
*/
326-
long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline)
326+
long add_timer(timer_handle_t func, void *data, uint64_t deadline)
327327
{
328328
struct timer *timer;
329329
struct per_cpu_timers *cpu_timer;
@@ -357,7 +357,7 @@ long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline)
357357
* update_timer existing timer. if not found, add new timer
358358
*/
359359
long
360-
update_timer(long handle, timer_handle_t func, uint64_t data,
360+
update_timer(long handle, timer_handle_t func, void *data,
361361
uint64_t deadline)
362362
{
363363
struct timer *timer;

hypervisor/debug/console.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void console_handler(void)
216216
shell_kick_session();
217217
}
218218

219-
static int console_timer_callback(__unused uint64_t data)
219+
static int console_timer_callback(__unused void *data)
220220
{
221221
/* Kick HV-Shell and Uart-Console tasks */
222222
console_handler();
@@ -230,7 +230,7 @@ static int console_timer_callback(__unused uint64_t data)
230230
void console_setup_timer(void)
231231
{
232232
/* Start an one-shot timer */
233-
if (add_timer(console_timer_callback, 0,
233+
if (add_timer(console_timer_callback, NULL,
234234
rdtsc() + CYCLES_PER_MS * CONSOLE_KICK_TIMER_TIMEOUT) < 0)
235235
pr_err("Failed to add console kick timer");
236236
}

hypervisor/include/arch/x86/timer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
#ifndef TIMER_H
3232
#define TIMER_H
3333

34-
typedef int (*timer_handle_t)(uint64_t);
34+
typedef int (*timer_handle_t)(void *);
3535

36-
long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline);
36+
long add_timer(timer_handle_t func, void *data, uint64_t deadline);
3737
bool cancel_timer(long handle, int pcpu_id);
38-
long update_timer(long handle, timer_handle_t func, uint64_t data,
38+
long update_timer(long handle, timer_handle_t func, void *data,
3939
uint64_t deadline);
4040

4141
int timer_softirq(int pcpu_id);

0 commit comments

Comments
 (0)