summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-21 19:57:40 +0000
committerpfg <pfg@FreeBSD.org>2016-04-21 19:57:40 +0000
commit729533413f4e97bb65852c22fb914805e2759b5a (patch)
treecd4dfa8859a5f57124d315ff395b524d7587e1ea /sys/mips
parent0d55061d05ce55d28aff0c06bad831448d172425 (diff)
downloadFreeBSD-src-729533413f4e97bb65852c22fb914805e2759b5a.zip
FreeBSD-src-729533413f4e97bb65852c22fb914805e2759b5a.tar.gz
sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code and when the code has a high indentation level it was not really advantageous to do the replacement. This tries to strike a balance between readability using the macros and flexibility of having the expressions, so not everything is converted.
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/cavium/octopci.c4
-rw-r--r--sys/mips/mips/tlb.c2
-rw-r--r--sys/mips/mips/trap.c2
-rw-r--r--sys/mips/rmi/dev/sec/rmilib.c8
-rw-r--r--sys/mips/sibyte/sb_zbpci.c2
5 files changed, 9 insertions, 9 deletions
diff --git a/sys/mips/cavium/octopci.c b/sys/mips/cavium/octopci.c
index 25bf3b8..48ef7e1 100644
--- a/sys/mips/cavium/octopci.c
+++ b/sys/mips/cavium/octopci.c
@@ -487,7 +487,7 @@ octopci_init_bar(device_t dev, unsigned b, unsigned s, unsigned f, unsigned barn
if (PCI_BAR_IO(bar)) {
size = ~(bar & PCIM_BAR_IO_BASE) + 1;
- sc->sc_io_next = (sc->sc_io_next + size - 1) & ~(size - 1);
+ sc->sc_io_next = roundup2(sc->sc_io_next, size);
if (sc->sc_io_next + size > CVMX_OCT_PCI_IO_SIZE) {
device_printf(dev, "%02x.%02x:%02x: no ports for BAR%u.\n",
b, s, f, barnum);
@@ -527,7 +527,7 @@ octopci_init_bar(device_t dev, unsigned b, unsigned s, unsigned f, unsigned barn
size = ~(bar & (uint32_t)PCIM_BAR_MEM_BASE) + 1;
- sc->sc_mem1_next = (sc->sc_mem1_next + size - 1) & ~(size - 1);
+ sc->sc_mem1_next = roundup2(sc->sc_mem1_next, size);
if (sc->sc_mem1_next + size > CVMX_OCT_PCI_MEM1_SIZE) {
device_printf(dev, "%02x.%02x:%02x: no memory for BAR%u.\n",
b, s, f, barnum);
diff --git a/sys/mips/mips/tlb.c b/sys/mips/mips/tlb.c
index 1ad8a11..f554faa 100644
--- a/sys/mips/mips/tlb.c
+++ b/sys/mips/mips/tlb.c
@@ -215,7 +215,7 @@ tlb_invalidate_range(pmap_t pmap, vm_offset_t start, vm_offset_t end)
* and round the virtual address "end" to an even page frame number.
*/
start &= ~((1 << TLBMASK_SHIFT) - 1);
- end = (end + (1 << TLBMASK_SHIFT) - 1) & ~((1 << TLBMASK_SHIFT) - 1);
+ end = roundup2(end, 1 << TLBMASK_SHIFT);
s = intr_disable();
save_asid = mips_rd_entryhi() & TLBHI_ASID_MASK;
diff --git a/sys/mips/mips/trap.c b/sys/mips/mips/trap.c
index 9467679..f3ef629 100644
--- a/sys/mips/mips/trap.c
+++ b/sys/mips/mips/trap.c
@@ -1576,7 +1576,7 @@ mips_unaligned_load_store(struct trapframe *frame, int mode, register_t addr, re
return (0);
}
- if (!useracc((void *)((vm_offset_t)addr & ~(size - 1)), size * 2, mode))
+ if (!useracc((void *)rounddown2((vm_offset_t)addr, size), size * 2, mode))
return (0);
/*
diff --git a/sys/mips/rmi/dev/sec/rmilib.c b/sys/mips/rmi/dev/sec/rmilib.c
index 014bfc8..f90123d 100644
--- a/sys/mips/rmi/dev/sec/rmilib.c
+++ b/sys/mips/rmi/dev/sec/rmilib.c
@@ -397,7 +397,7 @@ xlr_sec_setup_packet(xlr_sec_io_pt op,
/* physical address of the source buffer */
addr = (uint64_t) vtophys((void *)(unsigned long)op->source_buf);
/* cache-aligned base of the source buffer */
- seg_addr = (addr & ~(SMP_CACHE_BYTES - 1));
+ seg_addr = rounddown2(addr, SMP_CACHE_BYTES);
/* offset in bytes to the source buffer start from the segment base */
byte_offset = addr - seg_addr;
/* global offset: 0-7 bytes */
@@ -417,7 +417,7 @@ xlr_sec_setup_packet(xlr_sec_io_pt op,
len = op->source_buf_size + byte_offset - global_offset;
if (multi_frag_flag) {
next_seg_addr = (uint64_t)vtophys((void *)(uintptr_t)desc->next_src_buf);
- next_seg_addr = (next_seg_addr & ~(SMP_CACHE_BYTES - 1));
+ next_seg_addr = rounddown2(next_seg_addr, SMP_CACHE_BYTES);
next_len = desc->next_src_len;
}
/* length of the whole thing in dwords */
@@ -602,10 +602,10 @@ xlr_sec_setup_packet(xlr_sec_io_pt op,
*/
if (multi_frag_flag) {
next_seg_addr = (uint64_t) vtophys((void *)(unsigned long)(desc->next_dest_buf));
- next_seg_addr = (next_seg_addr & ~(SMP_CACHE_BYTES - 1));
+ next_seg_addr = rounddown2(next_seg_addr, SMP_CACHE_BYTES);
}
addr = (uint64_t) vtophys((void *)(unsigned long)op->dest_buf);
- seg_addr = (addr & ~(SMP_CACHE_BYTES - 1));
+ seg_addr = rounddown2(addr, SMP_CACHE_BYTES);
byte_offset = addr - seg_addr;
global_offset = byte_offset & 0x7;
diff --git a/sys/mips/sibyte/sb_zbpci.c b/sys/mips/sibyte/sb_zbpci.c
index e3d7dde..952fea8 100644
--- a/sys/mips/sibyte/sb_zbpci.c
+++ b/sys/mips/sibyte/sb_zbpci.c
@@ -345,7 +345,7 @@ zbpci_config_space_va(int bus, int slot, int func, int reg, int bytes)
#if _BYTE_ORDER == _BIG_ENDIAN
pa = pa ^ (4 - bytes);
#endif
- pa_page = pa & ~(PAGE_SIZE - 1);
+ pa_page = rounddown2(pa, PAGE_SIZE);
if (zbpci_config_space[cpu].paddr != pa_page) {
pmap_kremove(va_page);
pmap_kenter_attr(va_page, pa_page, PTE_C_UNCACHED);
OpenPOWER on IntegriCloud