HV: rename vdev_pt_cfgwrite_bar to vdev_pt_write_vbar and some misra-c fix

Rename vdev_pt_cfgwrite_bar to vdev_pt_write_vbar

Misra-c violation fix:
 Add missing else for find_vdev()
 Fix more than one exit (return) in function
 vdev_pt_cfgwrite_bar/vdev_pt_write_vbar

Tracked-On: #3022
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen 2019-05-20 14:26:53 -07:00 committed by ACRN System Integration
parent aba357dd36
commit 4cdaa519a0
2 changed files with 33 additions and 33 deletions

View File

@ -203,18 +203,15 @@ static void vdev_pt_remap_generic_bar(const struct pci_vdev *vdev, uint32_t idx,
/** /**
* @pre vdev != NULL * @pre vdev != NULL
*/ */
static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset, static void vdev_pt_write_vbar(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t new_bar_uos)
uint32_t bytes, uint32_t new_bar_uos)
{ {
uint32_t idx; uint32_t idx;
uint32_t new_bar, mask; uint32_t new_bar, mask;
bool bar_update_normal; bool bar_update_normal;
bool is_msix_table_bar; bool is_msix_table_bar;
if ((bytes != 4U) || ((offset & 0x3U) != 0U)) { /* Bar access must be 4 bytes aligned */
return; if ((bytes == 4U) && ((offset & 0x3U) == 0U)) {
}
new_bar = 0U; new_bar = 0U;
idx = (offset - pci_bar_offset(0U)) >> 2U; idx = (offset - pci_bar_offset(0U)) >> 2U;
mask = ~(vdev->bar[idx].size - 1U); mask = ~(vdev->bar[idx].size - 1U);
@ -248,6 +245,7 @@ static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset,
pci_vdev_write_cfg_u32(vdev, offset, new_bar); pci_vdev_write_cfg_u32(vdev, offset, new_bar);
} }
}
/** /**
* @pre vdev != NULL * @pre vdev != NULL
@ -261,7 +259,7 @@ int32_t vdev_pt_write_cfg(struct pci_vdev *vdev, uint32_t offset,
/* PCI BARs are emulated */ /* PCI BARs are emulated */
if (is_prelaunched_vm(vdev->vpci->vm) && pci_bar_access(offset)) { if (is_prelaunched_vm(vdev->vpci->vm) && pci_bar_access(offset)) {
vdev_pt_cfgwrite_bar(vdev, offset, bytes, val); vdev_pt_write_vbar(vdev, offset, bytes, val);
ret = 0; ret = 0;
} }

View File

@ -317,12 +317,14 @@ static struct pci_vdev *find_vdev_for_sos(union pci_bdf bdf)
*/ */
static struct pci_vdev *find_vdev(const struct acrn_vpci *vpci, union pci_bdf bdf) static struct pci_vdev *find_vdev(const struct acrn_vpci *vpci, union pci_bdf bdf)
{ {
struct pci_vdev *vdev = NULL; struct pci_vdev *vdev;
if (is_prelaunched_vm(vpci->vm)) { if (is_prelaunched_vm(vpci->vm)) {
vdev = pci_find_vdev_by_vbdf(vpci, bdf); vdev = pci_find_vdev_by_vbdf(vpci, bdf);
} else if (is_sos_vm(vpci->vm)) { } else if (is_sos_vm(vpci->vm)) {
vdev = find_vdev_for_sos(bdf); vdev = find_vdev_for_sos(bdf);
} else {
vdev = NULL;
} }
return vdev; return vdev;