* [PATCH V2] cma: use macro PFN_DOWN when converting size to pages
@ 2013-08-05 9:09 Xishi Qiu
2013-08-05 19:58 ` Johannes Weiner
0 siblings, 1 reply; 2+ messages in thread
From: Xishi Qiu @ 2013-08-05 9:09 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Andrew Morton, linux-mm, LKML
Use "PFN_DOWN(r->size)" instead of "r->size >> PAGE_SHIFT".
Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>
---
drivers/base/dma-contiguous.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 0ca5442..b3d711d 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -206,8 +206,7 @@ static int __init cma_init_reserved_areas(void)
for (; i; --i, ++r) {
struct cma *cma;
- cma = cma_create_area(PFN_DOWN(r->start),
- r->size >> PAGE_SHIFT);
+ cma = cma_create_area(PFN_DOWN(r->start), PFN_DOWN(r->size));
if (!IS_ERR(cma))
dev_set_cma_area(r->dev, cma);
}
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH V2] cma: use macro PFN_DOWN when converting size to pages
2013-08-05 9:09 [PATCH V2] cma: use macro PFN_DOWN when converting size to pages Xishi Qiu
@ 2013-08-05 19:58 ` Johannes Weiner
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Weiner @ 2013-08-05 19:58 UTC (permalink / raw)
To: Xishi Qiu; +Cc: Greg Kroah-Hartman, Andrew Morton, linux-mm, LKML
On Mon, Aug 05, 2013 at 05:09:17PM +0800, Xishi Qiu wrote:
> Use "PFN_DOWN(r->size)" instead of "r->size >> PAGE_SHIFT".
>
> Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>
> ---
> drivers/base/dma-contiguous.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
> index 0ca5442..b3d711d 100644
> --- a/drivers/base/dma-contiguous.c
> +++ b/drivers/base/dma-contiguous.c
> @@ -206,8 +206,7 @@ static int __init cma_init_reserved_areas(void)
>
> for (; i; --i, ++r) {
> struct cma *cma;
> - cma = cma_create_area(PFN_DOWN(r->start),
> - r->size >> PAGE_SHIFT);
> + cma = cma_create_area(PFN_DOWN(r->start), PFN_DOWN(r->size));
PFN_DOWN(r->start) makes sense because you are dividing and rounding a
byte-granular address to a PFN.
r->size >> PAGE_SHIFT translates number of bytes into number of pages.
It ends up being the same arithmetic operation to do both things, but
the units are different; the result of the second expression is not a
PFN. I think this change actually worsens readability of the code.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-05 19:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-05 9:09 [PATCH V2] cma: use macro PFN_DOWN when converting size to pages Xishi Qiu
2013-08-05 19:58 ` Johannes Weiner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox