Skip to content

Commit 71a80d2

Browse files
binbinwu1wenlingz
authored andcommitted
hv: assign: change ptirq vpin source type from enum to macro
This patch fixes the MISRA-C violations on implicit type conversion. For ptirq vpin source type, there is no need to define a enum. Remove enum ptirq_vpin_source. Define two macro: - PTDEV_VPIN_IOAPIC - PTDEV_VPIN_PIC Tracked-On: #861 Signed-off-by: Binbin Wu <binbin.wu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent d586563 commit 71a80d2

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static struct ptirq_remapping_info *add_intx_remapping(struct acrn_vm *vm, uint8
283283
uint8_t phys_pin, bool pic_pin)
284284
{
285285
struct ptirq_remapping_info *entry = NULL;
286-
enum ptirq_vpin_source vpin_src = pic_pin ? PTDEV_VPIN_PIC : PTDEV_VPIN_IOAPIC;
286+
uint8_t vpin_src = pic_pin ? PTDEV_VPIN_PIC : PTDEV_VPIN_IOAPIC;
287287
DEFINE_IOAPIC_SID(phys_sid, phys_pin, 0);
288288
DEFINE_IOAPIC_SID(virt_sid, virt_pin, vpin_src);
289289
uint32_t phys_irq = pin_to_irq(phys_pin);
@@ -475,7 +475,7 @@ void ptirq_softirq(uint16_t pcpu_id)
475475
}
476476

477477
void ptirq_intx_ack(struct acrn_vm *vm, uint8_t virt_pin,
478-
enum ptirq_vpin_source vpin_src)
478+
uint8_t vpin_src)
479479
{
480480
uint32_t phys_irq;
481481
struct ptirq_remapping_info *entry;
@@ -604,8 +604,7 @@ static void activate_physical_ioapic(struct acrn_vm *vm,
604604
/* Main entry for PCI/Legacy device assignment with INTx, calling from vIOAPIC
605605
* or vPIC
606606
*/
607-
int32_t ptirq_intx_pin_remap(struct acrn_vm *vm, uint8_t virt_pin,
608-
enum ptirq_vpin_source vpin_src)
607+
int32_t ptirq_intx_pin_remap(struct acrn_vm *vm, uint8_t virt_pin, uint8_t vpin_src)
609608
{
610609
int32_t status = 0;
611610
struct ptirq_remapping_info *entry = NULL;
@@ -691,8 +690,8 @@ int32_t ptirq_intx_pin_remap(struct acrn_vm *vm, uint8_t virt_pin,
691690
"IOAPIC pin=%hhu pirq=%u vpin=%d switch from %s to %s vpin=%d for vm%d",
692691
entry->phys_sid.intx_id.pin,
693692
entry->allocated_pirq, entry->virt_sid.intx_id.pin,
694-
(vpin_src == 0) ? "vPIC" : "vIOAPIC",
695-
(vpin_src == 0) ? "vIOPIC" : "vPIC",
693+
(vpin_src == 0U) ? "vPIC" : "vIOAPIC",
694+
(vpin_src == 0U) ? "vIOPIC" : "vPIC",
696695
virt_pin, entry->vm->vm_id);
697696
entry->virt_sid.value = virt_sid.value;
698697
}

hypervisor/include/arch/x86/assign.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @pre vm != NULL
3737
*
3838
*/
39-
void ptirq_intx_ack(struct acrn_vm *vm, uint8_t virt_pin, enum ptirq_vpin_source vpin_src);
39+
void ptirq_intx_ack(struct acrn_vm *vm, uint8_t virt_pin, uint8_t vpin_src);
4040

4141
/**
4242
* @brief MSI/MSI-x remapping for passthrough device.
@@ -81,7 +81,7 @@ int32_t ptirq_msix_remap(struct acrn_vm *vm, uint16_t virt_bdf, uint16_t entry_n
8181
* @pre vm != NULL
8282
*
8383
*/
84-
int32_t ptirq_intx_pin_remap(struct acrn_vm *vm, uint8_t virt_pin, enum ptirq_vpin_source vpin_src);
84+
int32_t ptirq_intx_pin_remap(struct acrn_vm *vm, uint8_t virt_pin, uint8_t vpin_src);
8585

8686
/**
8787
* @brief Add an interrupt remapping entry for INTx as pre-hold mapping.

hypervisor/include/common/ptdev.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
#define INVALID_PTDEV_ENTRY_ID 0xffffU
1616

17-
enum ptirq_vpin_source {
18-
PTDEV_VPIN_IOAPIC,
19-
PTDEV_VPIN_PIC,
20-
};
17+
#define PTDEV_VPIN_IOAPIC 0x0U
18+
#define PTDEV_VPIN_PIC 0x1U
2119

2220
#define DEFINE_MSI_SID(name, a, b) \
2321
union source_id (name) = {.msi_id = {.bdf = (a), .entry_nr = (b)} }

0 commit comments

Comments
 (0)