All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: media: Convert macro into an inline function
@ 2019-03-21 20:52 Madhumitha Prabakaran
  2019-03-21 21:02 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Madhumitha Prabakaran @ 2019-03-21 20:52 UTC (permalink / raw)
  To: mchehab, gregkh, outreachy-kernel; +Cc: Madhumitha Prabakaran

Convert macro into an inline function to maintain Linux kernel coding
style. In addition to that change the function names in respective call
sites.

Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
---
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 8 ++++----
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.h | 5 ++++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
index 4380e0a8e6dc..7d750e14253c 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
@@ -297,7 +297,7 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
 		case MEDIA_BUS_FMT_UYVY8_2X8:
 		case MEDIA_BUS_FMT_Y8_1X8:
 			RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
-			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
+			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
 			ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
 			break;
 
@@ -345,15 +345,15 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
 		case MEDIA_BUS_FMT_YUYV8_1X16:
 		case MEDIA_BUS_FMT_YUYV10_1X20:
 			RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
-			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
+			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
 			break;
 
 		case MEDIA_BUS_FMT_YUYV8_2X8:
 		case MEDIA_BUS_FMT_UYVY8_2X8:
 		case MEDIA_BUS_FMT_Y8_1X8:
 		case MEDIA_BUS_FMT_YUYV10_2X10:
-			SETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
-			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
+			setbit(val, IPIPEIF_CFG2_YUV8_SHIFT);
+			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
 			val |= IPIPEIF_CBCR_Y << IPIPEIF_CFG2_YUV8P_SHIFT;
 			break;
 
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
index 4685d64016de..0fe9d394962f 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
@@ -166,7 +166,10 @@ struct vpfe_ipipeif_device {
 #define IPIPEIF_RSZ_MIN			16
 #define IPIPEIF_RSZ_MAX			112
 #define IPIPEIF_RSZ_CONST		16
-#define SETBIT(reg, bit)   (reg = ((reg) | ((0x00000001)<<(bit))))
+static void setbit(u32 reg, int bit)
+{
+	reg = (reg | (0x00000001 << bit));
+}
 #define RESETBIT(reg, bit) (reg = ((reg) & (~(0x00000001<<(bit)))))
 
 #define IPIPEIF_ADOFS_LSB_MASK		0x1ff
-- 
2.17.1



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

* Re: [Outreachy kernel] [PATCH] Staging: media: Convert macro into an inline function
  2019-03-21 20:52 [PATCH] Staging: media: Convert macro into an inline function Madhumitha Prabakaran
@ 2019-03-21 21:02 ` Julia Lawall
  2019-03-21 22:10   ` Madhumthia Prabakaran
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2019-03-21 21:02 UTC (permalink / raw)
  To: Madhumitha Prabakaran; +Cc: mchehab, gregkh, outreachy-kernel



On Thu, 21 Mar 2019, Madhumitha Prabakaran wrote:

> Convert macro into an inline function to maintain Linux kernel coding
> style. In addition to that change the function names in respective call
> sites.
>
> Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> ---
>  drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 8 ++++----
>  drivers/staging/media/davinci_vpfe/dm365_ipipeif.h | 5 ++++-
>  2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> index 4380e0a8e6dc..7d750e14253c 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> @@ -297,7 +297,7 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
>  		case MEDIA_BUS_FMT_UYVY8_2X8:
>  		case MEDIA_BUS_FMT_Y8_1X8:
>  			RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> -			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> +			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
>  			ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
>  			break;
>
> @@ -345,15 +345,15 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
>  		case MEDIA_BUS_FMT_YUYV8_1X16:
>  		case MEDIA_BUS_FMT_YUYV10_1X20:
>  			RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> -			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> +			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
>  			break;
>
>  		case MEDIA_BUS_FMT_YUYV8_2X8:
>  		case MEDIA_BUS_FMT_UYVY8_2X8:
>  		case MEDIA_BUS_FMT_Y8_1X8:
>  		case MEDIA_BUS_FMT_YUYV10_2X10:
> -			SETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> -			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> +			setbit(val, IPIPEIF_CFG2_YUV8_SHIFT);
> +			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
>  			val |= IPIPEIF_CBCR_Y << IPIPEIF_CFG2_YUV8P_SHIFT;
>  			break;
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
> index 4685d64016de..0fe9d394962f 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
> +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
> @@ -166,7 +166,10 @@ struct vpfe_ipipeif_device {
>  #define IPIPEIF_RSZ_MIN			16
>  #define IPIPEIF_RSZ_MAX			112
>  #define IPIPEIF_RSZ_CONST		16
> -#define SETBIT(reg, bit)   (reg = ((reg) | ((0x00000001)<<(bit))))
> +static void setbit(u32 reg, int bit)
> +{
> +	reg = (reg | (0x00000001 << bit));
> +}

This is a really nice try, but it doesn't work.  Now you are just changing
the local variable of setbit rather than changing the variable at the call
site.  Maybe you could pass in a pointer and the compiler would be clever
enough to optimize it away.

But maybe the whole thing could be eg val |= BIT(IPIPEIF_CFG2_YUV8_SHIFT);
You could also take care of the uses of RESETBIT similarly.

julia

>  #define RESETBIT(reg, bit) (reg = ((reg) & (~(0x00000001<<(bit)))))
>
>  #define IPIPEIF_ADOFS_LSB_MASK		0x1ff
> --
> 2.17.1
>
> --
> 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 post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190321205206.21875-1-madhumithabiw%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


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

* Re: [Outreachy kernel] [PATCH] Staging: media: Convert macro into an inline function
  2019-03-21 21:02 ` [Outreachy kernel] " Julia Lawall
@ 2019-03-21 22:10   ` Madhumthia Prabakaran
  0 siblings, 0 replies; 3+ messages in thread
From: Madhumthia Prabakaran @ 2019-03-21 22:10 UTC (permalink / raw)
  To: Julia Lawall, outreachy-kernel

On Thu, Mar 21, 2019 at 10:02:12PM +0100, Julia Lawall wrote:
> 
> 
> On Thu, 21 Mar 2019, Madhumitha Prabakaran wrote:
> 
> > Convert macro into an inline function to maintain Linux kernel coding
> > style. In addition to that change the function names in respective call
> > sites.
> >
> > Signed-off-by: Madhumitha Prabakaran <madhumithabiw@gmail.com>
> > ---
> >  drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 8 ++++----
> >  drivers/staging/media/davinci_vpfe/dm365_ipipeif.h | 5 ++++-
> >  2 files changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> > index 4380e0a8e6dc..7d750e14253c 100644
> > --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> > +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> > @@ -297,7 +297,7 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
> >  		case MEDIA_BUS_FMT_UYVY8_2X8:
> >  		case MEDIA_BUS_FMT_Y8_1X8:
> >  			RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> > -			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> > +			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
> >  			ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
> >  			break;
> >
> > @@ -345,15 +345,15 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
> >  		case MEDIA_BUS_FMT_YUYV8_1X16:
> >  		case MEDIA_BUS_FMT_YUYV10_1X20:
> >  			RESETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> > -			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> > +			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
> >  			break;
> >
> >  		case MEDIA_BUS_FMT_YUYV8_2X8:
> >  		case MEDIA_BUS_FMT_UYVY8_2X8:
> >  		case MEDIA_BUS_FMT_Y8_1X8:
> >  		case MEDIA_BUS_FMT_YUYV10_2X10:
> > -			SETBIT(val, IPIPEIF_CFG2_YUV8_SHIFT);
> > -			SETBIT(val, IPIPEIF_CFG2_YUV16_SHIFT);
> > +			setbit(val, IPIPEIF_CFG2_YUV8_SHIFT);
> > +			setbit(val, IPIPEIF_CFG2_YUV16_SHIFT);
> >  			val |= IPIPEIF_CBCR_Y << IPIPEIF_CFG2_YUV8P_SHIFT;
> >  			break;
> >
> > diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
> > index 4685d64016de..0fe9d394962f 100644
> > --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
> > +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
> > @@ -166,7 +166,10 @@ struct vpfe_ipipeif_device {
> >  #define IPIPEIF_RSZ_MIN			16
> >  #define IPIPEIF_RSZ_MAX			112
> >  #define IPIPEIF_RSZ_CONST		16
> > -#define SETBIT(reg, bit)   (reg = ((reg) | ((0x00000001)<<(bit))))
> > +static void setbit(u32 reg, int bit)
> > +{
> > +	reg = (reg | (0x00000001 << bit));
> > +}
> 
> This is a really nice try, but it doesn't work.  Now you are just changing
> the local variable of setbit rather than changing the variable at the call
> site.  Maybe you could pass in a pointer and the compiler would be clever
> enough to optimize it away.

It slipped my mind that function is local. I will fix it. 

Thanks

> 
> But maybe the whole thing could be eg val |= BIT(IPIPEIF_CFG2_YUV8_SHIFT);
> You could also take care of the uses of RESETBIT similarly.
> 
> julia
> 
> >  #define RESETBIT(reg, bit) (reg = ((reg) & (~(0x00000001<<(bit)))))
> >
> >  #define IPIPEIF_ADOFS_LSB_MASK		0x1ff
> > --
> > 2.17.1
> >
> > --
> > 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 post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20190321205206.21875-1-madhumithabiw%40gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> >


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

end of thread, other threads:[~2019-03-21 22:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 20:52 [PATCH] Staging: media: Convert macro into an inline function Madhumitha Prabakaran
2019-03-21 21:02 ` [Outreachy kernel] " Julia Lawall
2019-03-21 22:10   ` Madhumthia Prabakaran

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.