Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH v1] media: ipu3-cio2: Use macros from mm.h
@ 2020-10-27 18:14 Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2020-10-27 18:14 UTC (permalink / raw)
  To: Yong Zhi, Sakari Ailus, Bingbu Cao, linux-media, Tianshu Qiu,
	Mauro Carvalho Chehab
  Cc: Andy Shevchenko

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>
---
 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..3ef5cf46647c 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);
+	entry[1].second_entry.last_page_available_bytes = (remaining ?: PAGE_SIZE) - 1;
 	/* Fill FBPT */
 	remaining = length;
 	i = 0;
-- 
2.28.0


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

* Re: [PATCH v1] media: ipu3-cio2: Use macros from mm.h
@ 2020-10-29 20:16 Andy Shevchenko
  2020-10-29 22:08 ` Sakari Ailus
  2020-10-30  2:01 ` Cao, Bingbu
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2020-10-29 20:16 UTC (permalink / raw)
  To: Bingbu Cao
  Cc: Yong Zhi, Sakari Ailus, Bingbu Cao, linux-media, Tianshu Qiu,
	Mauro Carvalho Chehab

On Wed, Oct 28, 2020 at 04:11:05PM +0800, Bingbu Cao wrote:
> Andy, thanks for your patch.

> Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>

Thanks!

> On 10/28/20 2:14 AM, Andy Shevchenko wrote:

> > -	entry[1].second_entry.last_page_available_bytes =
> > -			(remaining & ~PAGE_MASK) ?
> > -				(remaining & ~PAGE_MASK) - 1 : PAGE_SIZE - 1;
> > +	remaining = offset_in_page(remaining);
> > +	entry[1].second_entry.last_page_available_bytes = (remaining ?: PAGE_SIZE) - 1;
> 
> Not really about this change, is there some coding style update? This line obviously over 80
> chars, but the latest script did not report warning.

There is a relaxation in the script, but now it's ambiguous with the documentation.
I just realized I can rewrite this as:

	remaining = offset_in_page(remaining) ?: PAGE_SIZE;
	entry[1].second_entry.last_page_available_bytes = remaining - 1;

Would it work for you?

> >  	/* Fill FBPT */
> >  	remaining = length;
> >  	i = 0;

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1] media: ipu3-cio2: Use macros from mm.h
  2020-10-29 20:16 [PATCH v1] media: ipu3-cio2: Use macros from mm.h Andy Shevchenko
@ 2020-10-29 22:08 ` Sakari Ailus
  2020-10-29 23:06   ` Andy Shevchenko
  2020-10-30  2:01 ` Cao, Bingbu
  1 sibling, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2020-10-29 22:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Bingbu Cao, Yong Zhi, Bingbu Cao, linux-media, Tianshu Qiu,
	Mauro Carvalho Chehab

Hi Andy,

On Thu, Oct 29, 2020 at 10:16:57PM +0200, Andy Shevchenko wrote:
> On Wed, Oct 28, 2020 at 04:11:05PM +0800, Bingbu Cao wrote:
> > Andy, thanks for your patch.
> 
> > Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
> 
> Thanks!
> 
> > On 10/28/20 2:14 AM, Andy Shevchenko wrote:
> 
> > > -	entry[1].second_entry.last_page_available_bytes =
> > > -			(remaining & ~PAGE_MASK) ?
> > > -				(remaining & ~PAGE_MASK) - 1 : PAGE_SIZE - 1;
> > > +	remaining = offset_in_page(remaining);
> > > +	entry[1].second_entry.last_page_available_bytes = (remaining ?: PAGE_SIZE) - 1;
> > 
> > Not really about this change, is there some coding style update? This line obviously over 80
> > chars, but the latest script did not report warning.
> 
> There is a relaxation in the script, but now it's ambiguous with the documentation.

This line is over 80 characters. :-o

It's not ambibuous btw.; the documentation says:

	The preferred limit on the length of a single line is 80 columns.

I understand that as a preference to stay below that limit. It's not a
strict rule. Or... did you mean it didn't say whether this was upper or
lower limit? :-)

> I just realized I can rewrite this as:
> 
> 	remaining = offset_in_page(remaining) ?: PAGE_SIZE;
> 	entry[1].second_entry.last_page_available_bytes = remaining - 1;
> 
> Would it work for you?

Looks good to me.

-- 
Regards,

Sakari Ailus

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

* Re: [PATCH v1] media: ipu3-cio2: Use macros from mm.h
  2020-10-29 22:08 ` Sakari Ailus
@ 2020-10-29 23:06   ` Andy Shevchenko
  2020-10-29 23:10     ` Sakari Ailus
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2020-10-29 23:06 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Andy Shevchenko, Bingbu Cao, Yong Zhi, Bingbu Cao,
	Linux Media Mailing List, Tianshu Qiu, Mauro Carvalho Chehab

On Fri, Oct 30, 2020 at 12:12 AM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
> On Thu, Oct 29, 2020 at 10:16:57PM +0200, Andy Shevchenko wrote:
> > On Wed, Oct 28, 2020 at 04:11:05PM +0800, Bingbu Cao wrote:

...

> > I just realized I can rewrite this as:
> >
> >       remaining = offset_in_page(remaining) ?: PAGE_SIZE;
> >       entry[1].second_entry.last_page_available_bytes = remaining - 1;
> >
> > Would it work for you?
>
> Looks good to me.

Have you got v2?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v1] media: ipu3-cio2: Use macros from mm.h
  2020-10-29 23:06   ` Andy Shevchenko
@ 2020-10-29 23:10     ` Sakari Ailus
  0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2020-10-29 23:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andy Shevchenko, Bingbu Cao, Yong Zhi, Bingbu Cao,
	Linux Media Mailing List, Tianshu Qiu, Mauro Carvalho Chehab

On Fri, Oct 30, 2020 at 01:06:30AM +0200, Andy Shevchenko wrote:
> On Fri, Oct 30, 2020 at 12:12 AM Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> > On Thu, Oct 29, 2020 at 10:16:57PM +0200, Andy Shevchenko wrote:
> > > On Wed, Oct 28, 2020 at 04:11:05PM +0800, Bingbu Cao wrote:
> 
> ...
> 
> > > I just realized I can rewrite this as:
> > >
> > >       remaining = offset_in_page(remaining) ?: PAGE_SIZE;
> > >       entry[1].second_entry.last_page_available_bytes = remaining - 1;
> > >
> > > Would it work for you?
> >
> > Looks good to me.
> 
> Have you got v2?

Yes, in fact. I'll check it tomorrow / some time next week.

-- 
Sakari Ailus

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

* Re: [PATCH v1] media: ipu3-cio2: Use macros from mm.h
  2020-10-29 20:16 [PATCH v1] media: ipu3-cio2: Use macros from mm.h Andy Shevchenko
  2020-10-29 22:08 ` Sakari Ailus
@ 2020-10-30  2:01 ` Cao, Bingbu
  1 sibling, 0 replies; 6+ messages in thread
From: Cao, Bingbu @ 2020-10-30  2:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Yong Zhi, Sakari Ailus, Bingbu Cao, linux-media, Tianshu Qiu,
	Mauro Carvalho Chehab


On 10/30/20 4:16 AM, Andy Shevchenko wrote:
> On Wed, Oct 28, 2020 at 04:11:05PM +0800, Bingbu Cao wrote:
>> Andy, thanks for your patch.
> 
>> Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
> 
> Thanks!
> 
>> On 10/28/20 2:14 AM, Andy Shevchenko wrote:
> 
>>> -	entry[1].second_entry.last_page_available_bytes =
>>> -			(remaining & ~PAGE_MASK) ?
>>> -				(remaining & ~PAGE_MASK) - 1 : PAGE_SIZE - 1;
>>> +	remaining = offset_in_page(remaining);
>>> +	entry[1].second_entry.last_page_available_bytes = (remaining ?: PAGE_SIZE) - 1;
>>
>> Not really about this change, is there some coding style update? This line obviously over 80
>> chars, but the latest script did not report warning.
> 
> There is a relaxation in the script, but now it's ambiguous with the documentation.
> I just realized I can rewrite this as:
> 
> 	remaining = offset_in_page(remaining) ?: PAGE_SIZE;
> 	entry[1].second_entry.last_page_available_bytes = remaining - 1;
> 
> Would it work for you?

Yes, looks good for me, thanks.

> 
>>>  	/* Fill FBPT */
>>>  	remaining = length;
>>>  	i = 0;
> 

-- 
Best regards,
Bingbu Cao

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

end of thread, other threads:[~2020-10-30  2:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 20:16 [PATCH v1] media: ipu3-cio2: Use macros from mm.h Andy Shevchenko
2020-10-29 22:08 ` Sakari Ailus
2020-10-29 23:06   ` Andy Shevchenko
2020-10-29 23:10     ` Sakari Ailus
2020-10-30  2:01 ` Cao, Bingbu
  -- strict thread matches above, loose matches on Subject: below --
2020-10-27 18:14 Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox