mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-11 21:59:26 +00:00
hv: code clean up regarding to % and / operations
- Clean up some code regarding to % and / operations since bit operations are faster. x % 64U ---> x & 0x3fU x % 32U ---> x & 0x1fU x % 16U ---> x & 0xfU x % 8U ---> x & 0x7U x % 4U ---> x & 0x3U x % 2U ---> x & 0x1U x / 64U ---> x >> 6U x / 32U ---> x >> 5U x / 16U ---> x >> 4U x / 8U ---> x >> 3U x / 4U ---> x >> 2U x / 2U ---> x >> 1U - Minor changes regarding to coding styles Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -259,9 +259,9 @@ vioapic_indirect_read(struct vioapic *vioapic, uint32_t addr)
|
||||
if ((regnum >= IOAPIC_REDTBL) &&
|
||||
(regnum < (IOAPIC_REDTBL + (pincount * 2U)))) {
|
||||
uint32_t addr_offset = regnum - IOAPIC_REDTBL;
|
||||
uint32_t rte_offset = addr_offset / 2U;
|
||||
uint32_t rte_offset = addr_offset >> 1U;
|
||||
pin = rte_offset;
|
||||
if ((addr_offset % 2U) != 0U) {
|
||||
if ((addr_offset & 0x1U) != 0U) {
|
||||
return vioapic->rtbl[pin].u.hi_32;
|
||||
} else {
|
||||
return vioapic->rtbl[pin].u.lo_32;
|
||||
|
@@ -242,7 +242,7 @@ static void vdev_pt_cfgwrite_bar(struct pci_vdev *vdev, uint32_t offset,
|
||||
bool do_map;
|
||||
int error;
|
||||
|
||||
idx = (offset - PCIR_BAR(0U)) / 4U;
|
||||
idx = (offset - PCIR_BAR(0U)) >> 2U;
|
||||
mask = ~(vdev->bar[idx].size - 1U);
|
||||
bar_update_normal = (new_bar_uos != (uint32_t)~0U);
|
||||
new_bar = new_bar_uos & mask;
|
||||
|
Reference in New Issue
Block a user