diff mbox series

[1/6] staging: media: intel-ipu3: replace bit shifts with BIT() macro

Message ID cc7b827a3264f08cedb76adddd16a34df48f935f.1618180659.git.mitaliborkar810@gmail.com (mailing list archive)
State New, archived
Headers show
Series staging: media: intel-ipu3: cleanup patchset for style issues | expand

Commit Message

Mitali Borkar April 11, 2021, 11:08 p.m. UTC
Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
Use of macro is better and neater. It maintains consistency.
Reported by checkpatch.

Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
---
 drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Sakari Ailus April 12, 2021, 9:42 a.m. UTC | #1
Hi Mitali,

On Mon, Apr 12, 2021 at 04:38:39AM +0530, Mitali Borkar wrote:
> Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
> This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
> and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
> Use of macro is better and neater. It maintains consistency.
> Reported by checkpatch.
> 
> Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
> ---
>  drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
> index edd8edda0647..589d5ccee3a7 100644
> --- a/drivers/staging/media/ipu3/include/intel-ipu3.h
> +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
> @@ -5,6 +5,7 @@
>  #define __IPU3_UAPI_H
>  
>  #include <linux/types.h>
> +#include <linux/bitops.h>
>  
>  /* from /drivers/staging/media/ipu3/include/videodev2.h */
>  
> @@ -22,11 +23,11 @@
>  #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
>  
>  #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
> -#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
> +#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)

This header is used in user space where you don't have the BIT() macro.

>  
>  /* controls generation of meta_data (like FF enable/disable) */
> -#define IPU3_UAPI_AWB_RGBS_THR_B_EN			(1 << 14)
> -#define IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT		(1 << 15)
> +#define IPU3_UAPI_AWB_RGBS_THR_B_EN			BIT(14)
> +#define IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT		BIT(15)
>  
>  /**
>   * struct ipu3_uapi_grid_config - Grid plane config
Greg KH April 12, 2021, 9:49 a.m. UTC | #2
On Mon, Apr 12, 2021 at 12:42:30PM +0300, Sakari Ailus wrote:
> Hi Mitali,
> 
> On Mon, Apr 12, 2021 at 04:38:39AM +0530, Mitali Borkar wrote:
> > Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
> > This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
> > and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
> > Use of macro is better and neater. It maintains consistency.
> > Reported by checkpatch.
> > 
> > Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
> > ---
> >  drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > index edd8edda0647..589d5ccee3a7 100644
> > --- a/drivers/staging/media/ipu3/include/intel-ipu3.h
> > +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > @@ -5,6 +5,7 @@
> >  #define __IPU3_UAPI_H
> >  
> >  #include <linux/types.h>
> > +#include <linux/bitops.h>
> >  
> >  /* from /drivers/staging/media/ipu3/include/videodev2.h */
> >  
> > @@ -22,11 +23,11 @@
> >  #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
> >  
> >  #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
> > -#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
> > +#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)
> 
> This header is used in user space where you don't have the BIT() macro.

If that is true, why is it not in a "uapi" subdir within this driver?

Otherwise it is not obvious at all that this is the case :(

thanks,

greg k-h
Julia Lawall April 12, 2021, 10:17 a.m. UTC | #3
On Mon, 12 Apr 2021, Greg KH wrote:

> On Mon, Apr 12, 2021 at 12:42:30PM +0300, Sakari Ailus wrote:
> > Hi Mitali,
> >
> > On Mon, Apr 12, 2021 at 04:38:39AM +0530, Mitali Borkar wrote:
> > > Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
> > > This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
> > > and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
> > > Use of macro is better and neater. It maintains consistency.
> > > Reported by checkpatch.
> > >
> > > Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
> > > ---
> > >  drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > index edd8edda0647..589d5ccee3a7 100644
> > > --- a/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > @@ -5,6 +5,7 @@
> > >  #define __IPU3_UAPI_H
> > >
> > >  #include <linux/types.h>
> > > +#include <linux/bitops.h>
> > >
> > >  /* from /drivers/staging/media/ipu3/include/videodev2.h */
> > >
> > > @@ -22,11 +23,11 @@
> > >  #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
> > >
> > >  #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)

Mitali,

It's not very relevant given the use of this header, but if the 1 << 15
translation was correct, you could have changed the 1 << 12 computation as
well.

julia

> > > -#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
> > > +#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)
> >
> > This header is used in user space where you don't have the BIT() macro.
>
> If that is true, why is it not in a "uapi" subdir within this driver?
>
> Otherwise it is not obvious at all that this is the case :(
>
> thanks,
>
> greg k-h
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/YHQXty07oAP1L0W9%40kroah.com.
>
Sakari Ailus April 12, 2021, 10:44 a.m. UTC | #4
Hi Greg,

On Mon, Apr 12, 2021 at 11:49:43AM +0200, Greg KH wrote:
> On Mon, Apr 12, 2021 at 12:42:30PM +0300, Sakari Ailus wrote:
> > Hi Mitali,
> > 
> > On Mon, Apr 12, 2021 at 04:38:39AM +0530, Mitali Borkar wrote:
> > > Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
> > > This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
> > > and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
> > > Use of macro is better and neater. It maintains consistency.
> > > Reported by checkpatch.
> > > 
> > > Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
> > > ---
> > >  drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
> > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > index edd8edda0647..589d5ccee3a7 100644
> > > --- a/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > @@ -5,6 +5,7 @@
> > >  #define __IPU3_UAPI_H
> > >  
> > >  #include <linux/types.h>
> > > +#include <linux/bitops.h>
> > >  
> > >  /* from /drivers/staging/media/ipu3/include/videodev2.h */
> > >  
> > > @@ -22,11 +23,11 @@
> > >  #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
> > >  
> > >  #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
> > > -#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
> > > +#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)
> > 
> > This header is used in user space where you don't have the BIT() macro.
> 
> If that is true, why is it not in a "uapi" subdir within this driver?
> 
> Otherwise it is not obvious at all that this is the case :(

It defines an interface towards the user space and the argument has been a
staging driver shouldn't be doing that (for the lack of ABI stability),
hence leaving it where it is currently.

Also CC Laurent.
Greg KH April 12, 2021, 10:55 a.m. UTC | #5
On Mon, Apr 12, 2021 at 01:44:35PM +0300, Sakari Ailus wrote:
> Hi Greg,
> 
> On Mon, Apr 12, 2021 at 11:49:43AM +0200, Greg KH wrote:
> > On Mon, Apr 12, 2021 at 12:42:30PM +0300, Sakari Ailus wrote:
> > > Hi Mitali,
> > > 
> > > On Mon, Apr 12, 2021 at 04:38:39AM +0530, Mitali Borkar wrote:
> > > > Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
> > > > This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
> > > > and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
> > > > Use of macro is better and neater. It maintains consistency.
> > > > Reported by checkpatch.
> > > > 
> > > > Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
> > > > ---
> > > >  drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
> > > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > > index edd8edda0647..589d5ccee3a7 100644
> > > > --- a/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > > +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > > @@ -5,6 +5,7 @@
> > > >  #define __IPU3_UAPI_H
> > > >  
> > > >  #include <linux/types.h>
> > > > +#include <linux/bitops.h>
> > > >  
> > > >  /* from /drivers/staging/media/ipu3/include/videodev2.h */
> > > >  
> > > > @@ -22,11 +23,11 @@
> > > >  #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
> > > >  
> > > >  #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
> > > > -#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
> > > > +#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)
> > > 
> > > This header is used in user space where you don't have the BIT() macro.
> > 
> > If that is true, why is it not in a "uapi" subdir within this driver?
> > 
> > Otherwise it is not obvious at all that this is the case :(
> 
> It defines an interface towards the user space and the argument has been a
> staging driver shouldn't be doing that (for the lack of ABI stability),
> hence leaving it where it is currently.

I think we are talking past each other here...

If you have a userspace api, then put that in a .h file that has a
"uapi" in the path.  Just because you have this in a staging driver does
not mean you should not have such a thing, otherwise you are going to
constantly fight against people sending you patches like this as there
is no obvious way to determine this.

So how about moving this file to:
	drivers/staging/media/ipu3/include/uapi/intel-ipu3.h

thanks,

greg k-h
Sakari Ailus April 12, 2021, 11 a.m. UTC | #6
On Mon, Apr 12, 2021 at 12:55:52PM +0200, Greg KH wrote:
> On Mon, Apr 12, 2021 at 01:44:35PM +0300, Sakari Ailus wrote:
> > Hi Greg,
> > 
> > On Mon, Apr 12, 2021 at 11:49:43AM +0200, Greg KH wrote:
> > > On Mon, Apr 12, 2021 at 12:42:30PM +0300, Sakari Ailus wrote:
> > > > Hi Mitali,
> > > > 
> > > > On Mon, Apr 12, 2021 at 04:38:39AM +0530, Mitali Borkar wrote:
> > > > > Added #include <linux/bitops.h> and replaced bit shifts by BIT() macro.
> > > > > This BIT() macro from linux/bitops.h is used to define IPU3_UAPI_GRID_Y_START_EN
> > > > > and IPU3_UAPI_AWB_RGBS_THR_B_* bitmask.
> > > > > Use of macro is better and neater. It maintains consistency.
> > > > > Reported by checkpatch.
> > > > > 
> > > > > Signed-off-by: Mitali Borkar <mitaliborkar810@gmail.com>
> > > > > ---
> > > > >  drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++---
> > > > >  1 file changed, 4 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > > > index edd8edda0647..589d5ccee3a7 100644
> > > > > --- a/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > > > +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
> > > > > @@ -5,6 +5,7 @@
> > > > >  #define __IPU3_UAPI_H
> > > > >  
> > > > >  #include <linux/types.h>
> > > > > +#include <linux/bitops.h>
> > > > >  
> > > > >  /* from /drivers/staging/media/ipu3/include/videodev2.h */
> > > > >  
> > > > > @@ -22,11 +23,11 @@
> > > > >  #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
> > > > >  
> > > > >  #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
> > > > > -#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
> > > > > +#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)
> > > > 
> > > > This header is used in user space where you don't have the BIT() macro.
> > > 
> > > If that is true, why is it not in a "uapi" subdir within this driver?
> > > 
> > > Otherwise it is not obvious at all that this is the case :(
> > 
> > It defines an interface towards the user space and the argument has been a
> > staging driver shouldn't be doing that (for the lack of ABI stability),
> > hence leaving it where it is currently.
> 
> I think we are talking past each other here...
> 
> If you have a userspace api, then put that in a .h file that has a
> "uapi" in the path.  Just because you have this in a staging driver does
> not mean you should not have such a thing, otherwise you are going to
> constantly fight against people sending you patches like this as there
> is no obvious way to determine this.
> 
> So how about moving this file to:
> 	drivers/staging/media/ipu3/include/uapi/intel-ipu3.h

Ah, sure! I'll send a patch.
diff mbox series

Patch

diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h
index edd8edda0647..589d5ccee3a7 100644
--- a/drivers/staging/media/ipu3/include/intel-ipu3.h
+++ b/drivers/staging/media/ipu3/include/intel-ipu3.h
@@ -5,6 +5,7 @@ 
 #define __IPU3_UAPI_H
 
 #include <linux/types.h>
+#include <linux/bitops.h>
 
 /* from /drivers/staging/media/ipu3/include/videodev2.h */
 
@@ -22,11 +23,11 @@ 
 #define IPU3_UAPI_MAX_BUBBLE_SIZE			10
 
 #define IPU3_UAPI_GRID_START_MASK			((1 << 12) - 1)
-#define IPU3_UAPI_GRID_Y_START_EN			(1 << 15)
+#define IPU3_UAPI_GRID_Y_START_EN			BIT(15)
 
 /* controls generation of meta_data (like FF enable/disable) */
-#define IPU3_UAPI_AWB_RGBS_THR_B_EN			(1 << 14)
-#define IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT		(1 << 15)
+#define IPU3_UAPI_AWB_RGBS_THR_B_EN			BIT(14)
+#define IPU3_UAPI_AWB_RGBS_THR_B_INCL_SAT		BIT(15)
 
 /**
  * struct ipu3_uapi_grid_config - Grid plane config