mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Colberg <peter.colberg@intel.com>
To: hao.wu@intel.com, yilun.xu@intel.com, gregkh@linuxfoundation.org,
	linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: aaron.j.grier@intel.com, tianfei.zhang@intel.com,
	russell.h.weight@intel.com, matthew.gerlach@linux.intel.com,
	marpagan@redhat.com, lgoncalv@redhat.com,
	Peter Colberg <peter.colberg@intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v3] fpga: dfl: afu: use PFN_DOWN() helper macro
Date: Wed, 28 Jun 2023 20:22:55 -0400	[thread overview]
Message-ID: <20230629002255.25262-1-peter.colberg@intel.com> (raw)
In-Reply-To: <ZJvLlHpJwr/tv3gq@yilunxu-OptiPlex-7050>

Replace right shifts by PAGE_SHIFT with PFN_DOWN() helper macro to convert
from physical addresses to page frame numbers.

These changes are cosmetic only; no functional changes.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Peter Colberg <peter.colberg@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v3:
- Revert afu_mmap(), which calculates file offsets, not physical pages
v2:
- Comment in commit message that changes are cosmetic only
---
 drivers/fpga/dfl-afu-dma-region.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c
index 02b60fde0430..e8d54cfbb301 100644
--- a/drivers/fpga/dfl-afu-dma-region.c
+++ b/drivers/fpga/dfl-afu-dma-region.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/dma-mapping.h>
+#include <linux/pfn.h>
 #include <linux/sched/signal.h>
 #include <linux/uaccess.h>
 #include <linux/mm.h>
@@ -34,7 +35,7 @@ void afu_dma_region_init(struct dfl_feature_platform_data *pdata)
 static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
 			     struct dfl_afu_dma_region *region)
 {
-	int npages = region->length >> PAGE_SHIFT;
+	int npages = PFN_DOWN(region->length);
 	struct device *dev = &pdata->dev->dev;
 	int ret, pinned;
 
@@ -82,7 +83,7 @@ static int afu_dma_pin_pages(struct dfl_feature_platform_data *pdata,
 static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
 				struct dfl_afu_dma_region *region)
 {
-	long npages = region->length >> PAGE_SHIFT;
+	long npages = PFN_DOWN(region->length);
 	struct device *dev = &pdata->dev->dev;
 
 	unpin_user_pages(region->pages, npages);
@@ -101,7 +102,7 @@ static void afu_dma_unpin_pages(struct dfl_feature_platform_data *pdata,
  */
 static bool afu_dma_check_continuous_pages(struct dfl_afu_dma_region *region)
 {
-	int npages = region->length >> PAGE_SHIFT;
+	int npages = PFN_DOWN(region->length);
 	int i;
 
 	for (i = 0; i < npages - 1; i++)
-- 
2.28.0


  reply	other threads:[~2023-06-29  0:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 22:42 [PATCH] fpga: dfl: afu: use PFN_DOWN() and PFN_PHYS() helper macros Peter Colberg
2023-06-19 13:46 ` Greg KH
2023-06-19 13:54   ` Andy Shevchenko
2023-06-19 14:05     ` Greg KH
2023-06-19 19:56       ` [PATCH v2] " Peter Colberg
2023-06-27  6:26         ` Xu Yilun
2023-06-27 18:23           ` Andy Shevchenko
2023-06-28  5:56             ` Xu Yilun
2023-06-29  0:22               ` Peter Colberg [this message]
2023-07-10  6:35                 ` [PATCH v3] fpga: dfl: afu: use PFN_DOWN() helper macro Xu Yilun

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=20230629002255.25262-1-peter.colberg@intel.com \
    --to=peter.colberg@intel.com \
    --cc=aaron.j.grier@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hao.wu@intel.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marpagan@redhat.com \
    --cc=matthew.gerlach@linux.intel.com \
    --cc=russell.h.weight@intel.com \
    --cc=tianfei.zhang@intel.com \
    --cc=yilun.xu@intel.com \
    /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

Powered by JetHome