Staging: media: Convert macro into an inline function
Subsystems (2)
PATCH 1/1 Staging: media: Convert macro into an inline function
Convert macro into an inline function to maintain Linux kernel coding style. In addition to that change the function names in respective call sites.
--- 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(-)
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +4 -4
@@ -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 ;
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +4 -1
@@ -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
Signature · 1 line
2.17.1
Quoted 47 lines · 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 <[email protected]>--- 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(-)drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +4
-4@@ -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 ;drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +0
-0
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h struct vpfe_ipipeif_device { · line 172
Quoted 8 lines
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +4
-1@@ -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
Quoted 13 lines
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +0
-1#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 [email protected]. To post to this group, send email to [email protected].
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.
Quoted 56 lines · Julia Lawall
Quoted 52 lines · 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 <[email protected]>--- 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(-)drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +4
-4@@ -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 ;drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +1
-1@@ -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)
Quoted 8 lines
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h struct vpfe_ipipeif_device { · line 172
Quoted 3 lines
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +3
-0+{ + 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
Quoted 19 lines
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
Quoted 13 lines
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +0
-1#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 [email protected]. To post to this group, send email to [email protected].
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.