[PATCH 3/4] vfio-ccw: Make use of PAGE_MASK/PFN_UP helper macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



it's a refactor to make use of PAGE_MASK/PFN_UP helper macro

Signed-off-by: Cai Huoqing <caihuoqing@xxxxxxxxx>
---
 drivers/s390/cio/vfio_ccw_cp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
index 8d1b2771c1aa..178ff71d5cfd 100644
--- a/drivers/s390/cio/vfio_ccw_cp.c
+++ b/drivers/s390/cio/vfio_ccw_cp.c
@@ -65,7 +65,7 @@ static int pfn_array_alloc(struct pfn_array *pa, u64 iova, unsigned int len)
 
 	pa->pa_iova = iova;
 
-	pa->pa_nr = ((iova & ~PAGE_MASK) + len + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
+	pa->pa_nr = PFN_UP((iova & ~PAGE_MASK) + len);
 	if (!pa->pa_nr)
 		return -EINVAL;
 
@@ -161,7 +161,7 @@ static inline void pfn_array_idal_create_words(
 		idaws[i] = pa->pa_pfn[i] << PAGE_SHIFT;
 
 	/* Adjust the first IDAW, since it may not start on a page boundary */
-	idaws[0] += pa->pa_iova & (PAGE_SIZE - 1);
+	idaws[0] += pa->pa_iova & ~PAGE_MASK;
 }
 
 static void convert_ccw0_to_ccw1(struct ccw1 *source, unsigned long len)
@@ -214,8 +214,8 @@ static long copy_from_iova(struct device *mdev,
 		from = pa.pa_pfn[i] << PAGE_SHIFT;
 		m = PAGE_SIZE;
 		if (i == 0) {
-			from += iova & (PAGE_SIZE - 1);
-			m -= iova & (PAGE_SIZE - 1);
+			from += iova & ~PAGE_SIZE;
+			m -= iova & ~PAGE_MASK;
 		}
 
 		m = min(l, m);
-- 
2.25.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux