Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4dbe87d5 authored by Nitin Gupta's avatar Nitin Gupta Committed by David S. Miller
Browse files

sparc64: Cleanup hugepage table walk functions



Flatten out nested code structure in huge_pte_offset()
and huge_pte_alloc().

Signed-off-by: default avatarNitin Gupta <nitin.m.gupta@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent df7b2155
Loading
Loading
Loading
Loading
+20 −34
Original line number Diff line number Diff line
@@ -266,27 +266,19 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
	pgd_t *pgd;
	pud_t *pud;
	pmd_t *pmd;
	pte_t *pte = NULL;

	pgd = pgd_offset(mm, addr);
	pud = pud_alloc(mm, pgd, addr);
	if (!pud)
		return NULL;

	if (sz >= PUD_SIZE)
		pte = (pte_t *)pud;
	else {
		return (pte_t *)pud;
	pmd = pmd_alloc(mm, pud, addr);
	if (!pmd)
		return NULL;

	if (sz >= PMD_SIZE)
			pte = (pte_t *)pmd;
		else
			pte = pte_alloc_map(mm, pmd, addr);
	}

	return pte;
		return (pte_t *)pmd;
	return pte_alloc_map(mm, pmd, addr);
}

pte_t *huge_pte_offset(struct mm_struct *mm,
@@ -295,27 +287,21 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
	pgd_t *pgd;
	pud_t *pud;
	pmd_t *pmd;
	pte_t *pte = NULL;

	pgd = pgd_offset(mm, addr);
	if (!pgd_none(*pgd)) {
	if (pgd_none(*pgd))
		return NULL;
	pud = pud_offset(pgd, addr);
		if (!pud_none(*pud)) {
	if (pud_none(*pud))
		return NULL;
	if (is_hugetlb_pud(*pud))
				pte = (pte_t *)pud;
			else {
		return (pte_t *)pud;
	pmd = pmd_offset(pud, addr);
				if (!pmd_none(*pmd)) {
	if (pmd_none(*pmd))
		return NULL;
	if (is_hugetlb_pmd(*pmd))
						pte = (pte_t *)pmd;
					else
						pte = pte_offset_map(pmd, addr);
				}
			}
		}
	}

	return pte;
		return (pte_t *)pmd;
	return pte_offset_map(pmd, addr);
}

void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,