All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] media: ipu3-cio2: Use macros from mm.h
@ 2020-10-28 15:55 Andy Shevchenko
  2020-11-16 16:53 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-10-28 15:55 UTC (permalink / raw)
  To: Yong Zhi, Sakari Ailus, linux-media, Tianshu Qiu, Mauro Carvalho Chehab
  Cc: Andy Shevchenko, Bingbu Cao

There are few nice macros in mm.h, some of which we may use here.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
---
v2: rewrote to make it short and neat (Bingbu), added Rb tag (Bingbu)
 drivers/media/pci/intel/ipu3/ipu3-cio2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index d4b575813300..3d0c867e9762 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/iopoll.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/pfn.h>
@@ -190,9 +191,8 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2,
 	 * 4095 (PAGE_SIZE - 1) means every single byte in the last page
 	 * is available for DMA transfer.
 	 */
-	entry[1].second_entry.last_page_available_bytes =
-			(remaining & ~PAGE_MASK) ?
-				(remaining & ~PAGE_MASK) - 1 : PAGE_SIZE - 1;
+	remaining = offset_in_page(remaining) ?: PAGE_SIZE;
+	entry[1].second_entry.last_page_available_bytes = remaining - 1;
 	/* Fill FBPT */
 	remaining = length;
 	i = 0;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] media: ipu3-cio2: Use macros from mm.h
  2020-10-28 15:55 [PATCH v2] media: ipu3-cio2: Use macros from mm.h Andy Shevchenko
@ 2020-11-16 16:53 ` Andy Shevchenko
  2020-11-18 22:24   ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-11-16 16:53 UTC (permalink / raw)
  To: Yong Zhi, Sakari Ailus, linux-media, Tianshu Qiu, Mauro Carvalho Chehab
  Cc: Bingbu Cao

On Wed, Oct 28, 2020 at 05:55:20PM +0200, Andy Shevchenko wrote:
> There are few nice macros in mm.h, some of which we may use here.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>

If there is no further comments, can it be applied?

> ---
> v2: rewrote to make it short and neat (Bingbu), added Rb tag (Bingbu)
>  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index d4b575813300..3d0c867e9762 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -15,6 +15,7 @@
>  #include <linux/delay.h>
>  #include <linux/interrupt.h>
>  #include <linux/iopoll.h>
> +#include <linux/mm.h>
>  #include <linux/module.h>
>  #include <linux/pci.h>
>  #include <linux/pfn.h>
> @@ -190,9 +191,8 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2,
>  	 * 4095 (PAGE_SIZE - 1) means every single byte in the last page
>  	 * is available for DMA transfer.
>  	 */
> -	entry[1].second_entry.last_page_available_bytes =
> -			(remaining & ~PAGE_MASK) ?
> -				(remaining & ~PAGE_MASK) - 1 : PAGE_SIZE - 1;
> +	remaining = offset_in_page(remaining) ?: PAGE_SIZE;
> +	entry[1].second_entry.last_page_available_bytes = remaining - 1;
>  	/* Fill FBPT */
>  	remaining = length;
>  	i = 0;
> -- 
> 2.28.0
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] media: ipu3-cio2: Use macros from mm.h
  2020-11-16 16:53 ` Andy Shevchenko
@ 2020-11-18 22:24   ` Sakari Ailus
  0 siblings, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2020-11-18 22:24 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Yong Zhi, linux-media, Tianshu Qiu, Mauro Carvalho Chehab, Bingbu Cao

On Mon, Nov 16, 2020 at 06:53:19PM +0200, Andy Shevchenko wrote:
> On Wed, Oct 28, 2020 at 05:55:20PM +0200, Andy Shevchenko wrote:
> > There are few nice macros in mm.h, some of which we may use here.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
> 
> If there is no further comments, can it be applied?

It's in my latest pull request, but not in media tree master yet.

-- 
Sakari Ailus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-18 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 15:55 [PATCH v2] media: ipu3-cio2: Use macros from mm.h Andy Shevchenko
2020-11-16 16:53 ` Andy Shevchenko
2020-11-18 22:24   ` Sakari Ailus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.