From: Chen Gang <chengang@emindsoft.com.cn>
To: arnd@arndb.de, Andrew Morton <akpm@linux-foundation.org>
Cc: Linux-Arch <linux-arch@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Chen Gang <gang.chen.5i5j@gmail.com>,
chenwei@emindsoft.com.cn
Subject: [PATCH] include/asm-generic/pgtable.h: Check once and return for pgprot_modify
Date: Sun, 13 Dec 2015 17:12:02 +0800 [thread overview]
Message-ID: <566D3662.6080804@emindsoft.com.cn> (raw)
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.5i5j@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
next reply other threads:[~2015-12-13 9:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-13 9:12 Chen Gang [this message]
2015-12-13 15:46 ` [PATCH] include/asm-generic/pgtable.h: Check once and return for pgprot_modify Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=566D3662.6080804@emindsoft.com.cn \
--to=chengang@emindsoft.com.cn \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=chenwei@emindsoft.com.cn \
--cc=gang.chen.5i5j@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox