From 3446e84ea58419e33e583e789bfea3fc18e35c95 Mon Sep 17 00:00:00 2001 From: Xiangyang Wu Date: Fri, 27 Jul 2018 15:15:49 +0800 Subject: [PATCH] HV:treewide:rename struct timer as struct hv_timer The variable timer's name is identical with struct timer s name. This MISRA C violation is detected by static analysis tool. According to naming convention rule: If the data structure type is used by multi modules, its corresponding logic resource is only used by hypervisor/host and isn't exposed to external components (such as SOS, UOS), its name meaning is simplistic (such as timer), its name needs prefix "hv_". Rename struct timer as struct hv_timer. Replace regular expression:s/struct timer\([ ),;\t\*]\+\) /struct hv_timer\1 Signed-off-by: Xiangyang Wu Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vlapic.c | 8 ++++---- hypervisor/arch/x86/guest/vlapic_priv.h | 2 +- hypervisor/arch/x86/timer.c | 20 ++++++++++---------- hypervisor/debug/console.c | 2 +- hypervisor/include/arch/x86/timer.h | 8 ++++---- hypervisor/include/debug/console.h | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hypervisor/arch/x86/guest/vlapic.c b/hypervisor/arch/x86/guest/vlapic.c index fe9d7de31..9d25f7c41 100644 --- a/hypervisor/arch/x86/guest/vlapic.c +++ b/hypervisor/arch/x86/guest/vlapic.c @@ -280,7 +280,7 @@ static void vlapic_create_timer(struct acrn_vlapic *vlapic) static void vlapic_reset_timer(struct acrn_vlapic *vlapic) { - struct timer *timer; + struct hv_timer *timer; if (vlapic == NULL) { return; @@ -299,7 +299,7 @@ set_expiration(struct acrn_vlapic *vlapic) uint64_t now = rdtsc(); uint64_t delta; struct vlapic_timer *vtimer; - struct timer *timer; + struct hv_timer *timer; uint32_t tmicr, divisor_shift; vtimer = &vlapic->vtimer; @@ -328,7 +328,7 @@ static void vlapic_update_lvtt(struct acrn_vlapic *vlapic, struct vlapic_timer *vtimer = &vlapic->vtimer; if (vtimer->mode != timer_mode) { - struct timer *timer = &vtimer->timer; + struct hv_timer *timer = &vtimer->timer; /* * A write to the LVT Timer Register that changes @@ -411,7 +411,7 @@ static uint64_t vlapic_get_tsc_deadline_msr(struct acrn_vlapic *vlapic) static void vlapic_set_tsc_deadline_msr(struct acrn_vlapic *vlapic, uint64_t val_arg) { - struct timer *timer; + struct hv_timer *timer; uint64_t val = val_arg; if (!vlapic_lvtt_tsc_deadline(vlapic)) { diff --git a/hypervisor/arch/x86/guest/vlapic_priv.h b/hypervisor/arch/x86/guest/vlapic_priv.h index e49805dbc..eac404274 100644 --- a/hypervisor/arch/x86/guest/vlapic_priv.h +++ b/hypervisor/arch/x86/guest/vlapic_priv.h @@ -109,7 +109,7 @@ struct vlapic_ops { }; struct vlapic_timer { - struct timer timer; + struct hv_timer timer; uint32_t mode; uint32_t tmicr; uint32_t divisor_shift; diff --git a/hypervisor/arch/x86/timer.c b/hypervisor/arch/x86/timer.c index 14ec495db..dca04fbd1 100644 --- a/hypervisor/arch/x86/timer.c +++ b/hypervisor/arch/x86/timer.c @@ -13,7 +13,7 @@ uint32_t tsc_khz = 0U; -static void run_timer(struct timer *timer) +static void run_timer(struct hv_timer *timer) { /* deadline = 0 means stop timer, we should skip */ if ((timer->func != NULL) && timer->fire_tsc != 0UL) { @@ -32,12 +32,12 @@ static int tsc_deadline_handler(__unused int irq, __unused void *data) static inline void update_physical_timer(struct per_cpu_timers *cpu_timer) { - struct timer *timer = NULL; + struct hv_timer *timer = NULL; /* find the next event timer */ if (!list_empty(&cpu_timer->timer_list)) { timer = list_entry((&cpu_timer->timer_list)->next, - struct timer, node); + struct hv_timer, node); /* it is okay to program a expired time */ msr_write(MSR_IA32_TSC_DEADLINE, timer->fire_tsc); @@ -45,16 +45,16 @@ static inline void update_physical_timer(struct per_cpu_timers *cpu_timer) } static void __add_timer(struct per_cpu_timers *cpu_timer, - struct timer *timer, + struct hv_timer *timer, bool *need_update) { struct list_head *pos, *prev; - struct timer *tmp; + struct hv_timer *tmp; uint64_t tsc = timer->fire_tsc; prev = &cpu_timer->timer_list; list_for_each(pos, &cpu_timer->timer_list) { - tmp = list_entry(pos, struct timer, node); + tmp = list_entry(pos, struct hv_timer, node); if (tmp->fire_tsc < tsc) { prev = &tmp->node; } @@ -71,7 +71,7 @@ static void __add_timer(struct per_cpu_timers *cpu_timer, } } -int add_timer(struct timer *timer) +int add_timer(struct hv_timer *timer) { struct per_cpu_timers *cpu_timer; uint16_t pcpu_id; @@ -100,7 +100,7 @@ int add_timer(struct timer *timer) } -void del_timer(struct timer *timer) +void del_timer(struct hv_timer *timer) { if ((timer != NULL) && !list_empty(&timer->node)) { list_del_init(&timer->node); @@ -184,7 +184,7 @@ void timer_cleanup(void) void timer_softirq(uint16_t pcpu_id) { struct per_cpu_timers *cpu_timer; - struct timer *timer; + struct hv_timer *timer; struct list_head *pos, *n; int tries = MAX_TIMER_ACTIONS; uint64_t current_tsc = rdtsc(); @@ -199,7 +199,7 @@ void timer_softirq(uint16_t pcpu_id) * already passed due to previously func()'s delay. */ list_for_each_safe(pos, n, &cpu_timer->timer_list) { - timer = list_entry(pos, struct timer, node); + timer = list_entry(pos, struct hv_timer, node); /* timer expried */ tries--; if (timer->fire_tsc <= current_tsc && tries > 0) { diff --git a/hypervisor/debug/console.c b/hypervisor/debug/console.c index b2268b63c..bcfebedae 100644 --- a/hypervisor/debug/console.c +++ b/hypervisor/debug/console.c @@ -10,7 +10,7 @@ static spinlock_t lock; static uint32_t serial_handle = SERIAL_INVALID_HANDLE; -struct timer console_timer; +struct hv_timer console_timer; #define CONSOLE_KICK_TIMER_TIMEOUT 40 /* timeout is 40ms*/ diff --git a/hypervisor/include/arch/x86/timer.h b/hypervisor/include/arch/x86/timer.h index cdfa44777..d0868bab2 100644 --- a/hypervisor/include/arch/x86/timer.h +++ b/hypervisor/include/arch/x86/timer.h @@ -18,7 +18,7 @@ struct per_cpu_timers { struct list_head timer_list; /* it's for runtime active timer list */ }; -struct timer { +struct hv_timer { struct list_head node; /* link all timers */ int mode; /* timer mode: one-shot or periodic */ uint64_t fire_tsc; /* tsc deadline to interrupt */ @@ -31,7 +31,7 @@ struct timer { * Don't initialize a timer twice if it has been add to the timer list * after call add_timer. If u want, delete the timer from the list first. */ -static inline void initialize_timer(struct timer *timer, +static inline void initialize_timer(struct hv_timer *timer, timer_handle_t func, void *priv_data, uint64_t fire_tsc, @@ -51,8 +51,8 @@ static inline void initialize_timer(struct timer *timer, /* * Don't call add_timer/del_timer in the timer callback function. */ -int add_timer(struct timer *timer); -void del_timer(struct timer *timer); +int add_timer(struct hv_timer *timer); +void del_timer(struct hv_timer *timer); void timer_softirq(uint16_t pcpu_id); void timer_init(void); diff --git a/hypervisor/include/debug/console.h b/hypervisor/include/debug/console.h index 4a3ddeac1..47a2f600d 100644 --- a/hypervisor/include/debug/console.h +++ b/hypervisor/include/debug/console.h @@ -8,7 +8,7 @@ #define CONSOLE_H #ifdef HV_DEBUG -extern struct timer console_timer; +extern struct hv_timer console_timer; /** Initializes the console module. *