Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sh3/sh3 Redo a part of rev 1.89:



details:   https://anonhg.NetBSD.org/src/rev/bbba4d164f3d
branches:  trunk
changeset: 1023452:bbba4d164f3d
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Sep 08 07:22:56 2021 +0000

description:
Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.

diffstat:

 sys/arch/sh3/sh3/pmap.c |  102 ++++++++++++++++++++++-------------------------
 1 files changed, 47 insertions(+), 55 deletions(-)

diffs (truncated from 390 to 300 lines):

diff -r 325305d4083c -r bbba4d164f3d sys/arch/sh3/sh3/pmap.c
--- a/sys/arch/sh3/sh3/pmap.c   Wed Sep 08 07:13:18 2021 +0000
+++ b/sys/arch/sh3/sh3/pmap.c   Wed Sep 08 07:22:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $    */
+/*     $NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $    */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2021/09/08 07:22:56 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -153,7 +153,7 @@
        va = SH3_PHYS_TO_P1SEG(pa);
        memset((void *)va, 0, size);
 
-       return (va);
+       return va;
 }
 
 vaddr_t
@@ -162,7 +162,7 @@
        int i, n;
 
        if (maxkvaddr <= __pmap_kve)
-               return (__pmap_kve);
+               return __pmap_kve;
 
        i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
        __pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,7 +190,7 @@
                }
        }
 
-       return (__pmap_kve);
+       return __pmap_kve;
  error:
        panic("pmap_growkernel: out of memory.");
        /* NOTREACHED */
@@ -248,7 +248,7 @@
                    uvm_pagealloc(NULL, 0, NULL,
                        UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-       return (pmap);
+       return pmap;
 }
 
 void
@@ -271,7 +271,7 @@
                        for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
                                KDASSERT(*pte == 0);
                }
-#endif /* DEBUG */
+#endif
                /* Purge cache entry for next use of this page. */
                if (SH_HAS_VIRTUAL_ALIAS)
                        sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@
        struct vm_page *pg;
        struct vm_page_md *pvh;
        pt_entry_t entry, *pte;
-       bool kva = (pmap == pmap_kernel());
+       bool kva = pmap == pmap_kernel();
 
        /* "flags" never exceed "prot" */
        KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,7 +362,7 @@
 
                /* Check for existing mapping */
                if (__pmap_map_change(pmap, va, pa, prot, entry))
-                       return (0);
+                       return 0;
 
                /* Add to physical-virtual map list of this page */
                if (__pmap_pv_enter(pmap, pg, va)) {
@@ -371,15 +371,14 @@
                        panic("%s: __pmap_pv_enter failed", __func__);
                }
        } else {        /* bus-space (always uncached map) */
-               if (kva) {
+               if (kva)
                        entry |= PG_V | PG_SH |
                            ((prot & VM_PROT_WRITE) ?
                            (PG_PR_KRW | PG_D) : PG_PR_KRO);
-               } else {
+               else
                        entry |= PG_V |
                            ((prot & VM_PROT_WRITE) ?
                            (PG_PR_URW | PG_D) : PG_PR_URO);
-               }
        }
 
        /* Register to page table */
@@ -410,7 +409,7 @@
                pmap->pm_stats.wired_count++;
        pmap->pm_stats.resident_count++;
 
-       return (0);
+       return 0;
 }
 
 /*
@@ -428,13 +427,13 @@
        vaddr_t eva = va + PAGE_SIZE;
 
        if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-           ((oentry = *pte) == 0))
-               return (false);         /* no mapping exists. */
+           (oentry = *pte) == 0)
+               return false;           /* no mapping exists. */
 
        if (pa != (oentry & PG_PPN)) {
                /* Enter a mapping at a mapping to another physical page. */
                pmap_remove(pmap, va, eva);
-               return (false);
+               return false;
        }
 
        /* Pre-existing mapping */
@@ -454,10 +453,10 @@
        } else if (entry & _PG_WIRED) {
                /* unwired -> wired. make sure to reflect "flags" */
                pmap_remove(pmap, va, eva);
-               return (false);
+               return false;
        }
 
-       return (true);  /* mapping was changed. */
+       return true;    /* mapping was changed. */
 }
 
 /*
@@ -575,7 +574,7 @@
 #ifdef DEBUG
        /* Check duplicated map. */
        SLIST_FOREACH(pv, &pvh->pvh_head, pv_link)
-           KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
+               KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
 #endif
        splx(s);
 }
@@ -638,17 +637,17 @@
        if (pmap == pmap_kernel() && (va >> 30) == 2) {
                if (pap != NULL)
                        *pap = va & SH3_PHYS_MASK;
-               return (true);
+               return true;
        }
 
        pte = __pmap_pte_lookup(pmap, va);
        if (pte == NULL || *pte == 0)
-               return (false);
+               return false;
 
        if (pap != NULL)
                *pap = (*pte & PG_PPN) | (va & PGOFSET);
 
-       return (true);
+       return true;
 }
 
 void
@@ -670,20 +669,17 @@
                panic("pmap_protect: invalid protection mode %x", prot);
                /* NOTREACHED */
        case VM_PROT_READ:
-               /* FALLTHROUGH */
        case VM_PROT_READ | VM_PROT_EXECUTE:
                protbits = kernel ? PG_PR_KRO : PG_PR_URO;
                break;
        case VM_PROT_READ | VM_PROT_WRITE:
-               /* FALLTHROUGH */
        case VM_PROT_ALL:
                protbits = kernel ? PG_PR_KRW : PG_PR_URW;
                break;
        }
 
        for (va = sva; va < eva; va += PAGE_SIZE) {
-
-               if (((pte = __pmap_pte_lookup(pmap, va)) == NULL) ||
+               if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
                    (entry = *pte) == 0)
                        continue;
 
@@ -713,12 +709,10 @@
 
        switch (prot) {
        case VM_PROT_READ | VM_PROT_WRITE:
-               /* FALLTHROUGH */
        case VM_PROT_ALL:
                break;
 
        case VM_PROT_READ:
-               /* FALLTHROUGH */
        case VM_PROT_READ | VM_PROT_EXECUTE:
                s = splvm();
                SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) {
@@ -781,9 +775,8 @@
                /* sync cache since we access via P2. */
                sh_dcache_wbinv_all();
                memset((void *)SH3_PHYS_TO_P2SEG(phys), 0, PAGE_SIZE);
-       } else {
+       } else
                memset((void *)SH3_PHYS_TO_P1SEG(phys), 0, PAGE_SIZE);
-       }
 }
 
 void
@@ -795,10 +788,9 @@
                sh_dcache_wbinv_all();
                memcpy((void *)SH3_PHYS_TO_P2SEG(dst),
                    (void *)SH3_PHYS_TO_P2SEG(src), PAGE_SIZE);
-       } else {
+       } else
                memcpy((void *)SH3_PHYS_TO_P1SEG(dst),
                    (void *)SH3_PHYS_TO_P1SEG(src), PAGE_SIZE);
-       }
 }
 
 bool
@@ -806,7 +798,7 @@
 {
        struct vm_page_md *pvh = VM_PAGE_TO_MD(pg);
 
-       return ((pvh->pvh_flags & PVH_REFERENCED) ? true : false);
+       return (pvh->pvh_flags & PVH_REFERENCED) ? true : false;
 }
 
 bool
@@ -841,7 +833,7 @@
        }
        splx(s);
 
-       return (true);
+       return true;
 }
 
 bool
@@ -849,7 +841,7 @@
 {
        struct vm_page_md *pvh = VM_PAGE_TO_MD(pg);
 
-       return ((pvh->pvh_flags & PVH_MODIFIED) ? true : false);
+       return (pvh->pvh_flags & PVH_MODIFIED) ? true : false;
 }
 
 bool
@@ -865,14 +857,14 @@
 
        modified = pvh->pvh_flags & PVH_MODIFIED;
        if (!modified)
-               return (false);
+               return false;
 
        pvh->pvh_flags &= ~PVH_MODIFIED;
 
        s = splvm();
        if (SLIST_EMPTY(&pvh->pvh_head)) {/* no map on this page */
                splx(s);
-               return (true);
+               return true;
        }
 
        /* Write-back and invalidate TLB entry */
@@ -897,14 +889,14 @@
        }
        splx(s);
 
-       return (true);
+       return true;
 }
 
 paddr_t
 pmap_phys_address(paddr_t cookie)
 {
 
-       return (sh3_ptob(cookie));
+       return sh3_ptob(cookie);
 }
 
 #ifdef SH4
@@ -945,9 +937,9 @@
 
        pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE);
        if (pg == NULL)
-               return (NULL);
+               return NULL;
 
-       return ((void *)SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg)));
+       return (void *)SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg));
 }
 
 void
@@ -973,7 +965,7 @@



Home | Main Index | Thread Index | Old Index