Date: Tue, 26 Jan 2016 09:50:23 +0000 (UTC) From: Svatopluk Kraus <skra@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294789 - head/sys/arm/arm Message-ID: <201601260950.u0Q9oNWJ062640@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: skra Date: Tue Jan 26 09:50:23 2016 New Revision: 294789 URL: https://svnweb.freebsd.org/changeset/base/294789 Log: Make code more compact and readable better in pmap_extract() like functions. No functional change. This is a follow up to r294722. Suggested by: kib Modified: head/sys/arm/arm/pmap-v6.c head/sys/arm/arm/pmap.c Modified: head/sys/arm/arm/pmap-v6.c ============================================================================== --- head/sys/arm/arm/pmap-v6.c Tue Jan 26 09:42:13 2016 (r294788) +++ head/sys/arm/arm/pmap-v6.c Tue Jan 26 09:50:23 2016 (r294789) @@ -3446,14 +3446,10 @@ pmap_extract_locked(pmap_t pmap, vm_offs pte = ptep[l2pte_index(va)]; if (pte == 0) return (0); - switch (pte & L2_TYPE_MASK) { - case L2_TYPE_L: + if ((pte & L2_TYPE_MASK) == L2_TYPE_L) pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET); - break; - default: + else pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } } return (pa); } @@ -3515,20 +3511,15 @@ retry: PMAP_UNLOCK(pmap); return (NULL); } else { - switch (pte & L2_TYPE_MASK) { - case L2_TYPE_L: + if ((pte & L2_TYPE_MASK) == L2_TYPE_L) panic("extract and hold section mapping"); - break; - default: + else pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } if (vm_page_pa_tryrelock(pmap, pa & PG_FRAME, &paddr)) goto retry; m = PHYS_TO_VM_PAGE(pa); vm_page_hold(m); } - } PMAP_UNLOCK(pmap); @@ -3567,14 +3558,10 @@ pmap_dump_kextract(vm_offset_t va, pt2_e pa = 0; goto out; } - switch (pte & L2_TYPE_MASK) { - case L2_TYPE_L: + if ((pte & L2_TYPE_MASK) == L2_TYPE_L) pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET); - break; - default: + else pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } } out: if (pte2p != NULL) Modified: head/sys/arm/arm/pmap.c ============================================================================== --- head/sys/arm/arm/pmap.c Tue Jan 26 09:42:13 2016 (r294788) +++ head/sys/arm/arm/pmap.c Tue Jan 26 09:50:23 2016 (r294789) @@ -2787,18 +2787,14 @@ pmap_kremove(vm_offset_t va) pte = &l2b->l2b_kva[l2pte_index(va)]; opte = *pte; if (l2pte_valid(opte)) { - /* pa = vtophs(va) taken from pmap_extract() */ - switch (opte & L2_TYPE_MASK) { - case L2_TYPE_L: + /* pa = vtophs(va) taken from pmap_extract() */ + if ((opte & L2_TYPE_MASK) == L2_TYPE_L) pa = (opte & L2_L_FRAME) | (va & L2_L_OFFSET); - break; - default: + else pa = (opte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } - /* note: should never have to remove an allocation - * before the pvzone is initialized. - */ + /* note: should never have to remove an allocation + * before the pvzone is initialized. + */ rw_wlock(&pvh_global_lock); PMAP_LOCK(pmap_kernel()); if (pvzone != NULL && (m = vm_phys_paddr_to_vm_page(pa)) && @@ -3645,14 +3641,10 @@ pmap_extract_locked(pmap_t pmap, vm_offs pte = ptep[l2pte_index(va)]; if (pte == 0) return (0); - switch (pte & L2_TYPE_MASK) { - case L2_TYPE_L: + if ((pte & L2_TYPE_MASK) == L2_TYPE_L) pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET); - break; - default: + else pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } } return (pa); } @@ -3717,15 +3709,10 @@ retry: return (NULL); } if (pte & L2_S_PROT_W || (prot & VM_PROT_WRITE) == 0) { - switch (pte & L2_TYPE_MASK) { - case L2_TYPE_L: + if ((pte & L2_TYPE_MASK) == L2_TYPE_L) pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET); - break; - - default: + else pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } if (vm_page_pa_tryrelock(pmap, pa & PG_FRAME, &paddr)) goto retry; m = PHYS_TO_VM_PAGE(pa); @@ -3769,14 +3756,10 @@ pmap_dump_kextract(vm_offset_t va, pt2_e pa = 0; goto out; } - switch (pte & L2_TYPE_MASK) { - case L2_TYPE_L: + if ((pte & L2_TYPE_MASK) == L2_TYPE_L) pa = (pte & L2_L_FRAME) | (va & L2_L_OFFSET); - break; - default: + else pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET); - break; - } } out: if (pte2p != NULL)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601260950.u0Q9oNWJ062640>