pgprot_val() likes an empty operation, and all three checking statements
are related with oldprot, so only check once is enough, the reason is:

 - if both "oldprot == pgprot_noncached(oldprot)" and "oldprot ==
   pgprot_writecombine(oldprot)" are satisfied.

 - So "pgprot_noncached(oldprot) == pgprot_writecombine(oldprot)", too.

 - So as the result, it is still equal to check once (for pgprot_device
   can get the same result).

Then can return directly.

Signed-off-by: Chen Gang <gang.chen.5...@gmail.com>
---
 include/asm-generic/pgtable.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 069536a..cd9e7c4 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -306,11 +306,11 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
 {
        if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
-               newprot = pgprot_noncached(newprot);
+               return pgprot_noncached(newprot);
        if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
-               newprot = pgprot_writecombine(newprot);
+               return pgprot_writecombine(newprot);
        if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
-               newprot = pgprot_device(newprot);
+               return pgprot_device(newprot);
        return newprot;
 }
 #endif
-- 
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to