staging: bcm2835-camera: call function instead of macro
Subsystems (3)
PATCH 1/1 staging: bcm2835-camera: call function instead of macro
Fix checkpatch.pl warning of 'macro argument reuse' in bcm2835-camera.h by removing the macro and calling the function, written in macro in bcm2835-camera.h, directly in bcm2835-camera.c
--- .../bcm2835-camera/bcm2835-camera.c | 28 +++++++++++++++---- .../bcm2835-camera/bcm2835-camera.h | 10 ------- 2 files changed, 22 insertions(+), 16 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +22 -6
@@ -919,9 +919,17 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,else f->fmt.pix.colorspace =V4L2_COLORSPACE_SMPTE170M ; f->fmt.pix.priv =0 ; - -v4l2_dump_pix_format (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, &f->fmt.pix, - __func__); +v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, +"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n" , + __func__, + (&f->fmt.pix)->width, + (&f->fmt.pix)->height, + (&f->fmt.pix)->field, + (&f->fmt.pix)->pixelformat, + (&f->fmt.pix)->bytesperline, + (&f->fmt.pix)->sizeimage, + (&f->fmt.pix)->colorspace, + (&f->fmt.pix)->priv);return 0 ; }
@@ -995,9 +1003,17 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"Now %dx%d format %08X\n" , f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.pixelformat); - -v4l2_dump_pix_format (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, &f->fmt.pix, - __func__); +v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, +"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n" , + __func__, + (&f->fmt.pix)->width, + (&f->fmt.pix)->height, + (&f->fmt.pix)->field, + (&f->fmt.pix)->pixelformat, + (&f->fmt.pix)->bytesperline, + (&f->fmt.pix)->sizeimage, + (&f->fmt.pix)->colorspace, + (&f->fmt.pix)->priv);return 0 ; }
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +0 -10
@@ -121,16 +121,6 @@ int set_framerate_params(struct bm2835_mmal_dev *dev);/* Debug helpers */ -#define v4l2_dump_pix_format (level, debug, dev, pix_fmt, desc) \ -{ \ - v4l2_dbg(level, debug, dev, \ -"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n", \ - desc, \ - (pix_fmt)->width, (pix_fmt)->height, (pix_fmt)->field, \ - (pix_fmt)->pixelformat, (pix_fmt)->bytesperline, \ - (pix_fmt)->sizeimage, (pix_fmt)->colorspace, (pix_fmt)->priv); \ -} -#define v4l2_dump_win_format (level, debug, dev, win_fmt, desc) \ { \ v4l2_dbg(level, debug, dev, \
Signature · 1 line
2.17.1
Quoted 22 lines · Kaaira Gupta
Fix checkpatch.pl warning of 'macro argument reuse' in
bcm2835-camera.hby removing the macro and calling the function, written in macro inbcm2835-camera.h, directly inbcm2835-camera.cSigned-off-by Kaaira Gupta <[email protected]>--- .../bcm2835-camera/bcm2835-camera.c | 28 +++++++++++++++---- .../bcm2835-camera/bcm2835-camera.h | 10 ------- 2 files changed, 22 insertions(+), 16 deletions(-)drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +1
-3@@ -919,9 +919,17 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,else f->fmt.pix.colorspace =V4L2_COLORSPACE_SMPTE170M ; f->fmt.pix.priv =0 ; - -v4l2_dump_pix_format (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, &f->fmt.pix, - __func__); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, · line 932
Quoted 10 lines
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +10
-0+"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n" , + __func__, + (&f->fmt.pix)->width, + (&f->fmt.pix)->height, + (&f->fmt.pix)->field, + (&f->fmt.pix)->pixelformat, + (&f->fmt.pix)->bytesperline, + (&f->fmt.pix)->sizeimage, + (&f->fmt.pix)->colorspace, + (&f->fmt.pix)->priv);
This is not as nice to look at as the original. Just ignore the warning.
regards,
dan carpenter
PATCH 1/1 staging: bcm2835-camera: call function instead of macro
Quoted 37 lines · Dan Carpenter
Quoted 22 lines · Kaaira Gupta
Fix checkpatch.pl warning of 'macro argument reuse' in
bcm2835-camera.hby removing the macro and calling the function, written in macro inbcm2835-camera.h, directly inbcm2835-camera.cSigned-off-by Kaaira Gupta <[email protected]>--- .../bcm2835-camera/bcm2835-camera.c | 28 +++++++++++++++---- .../bcm2835-camera/bcm2835-camera.h | 10 ------- 2 files changed, 22 insertions(+), 16 deletions(-)drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +1
-3@@ -919,9 +919,17 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,else f->fmt.pix.colorspace =V4L2_COLORSPACE_SMPTE170M ; f->fmt.pix.priv =0 ; - -v4l2_dump_pix_format (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, &f->fmt.pix, - __func__); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, · line 932
Quoted 10 lines
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +10
-0+"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n" , + __func__, + (&f->fmt.pix)->width, + (&f->fmt.pix)->height, + (&f->fmt.pix)->field, + (&f->fmt.pix)->pixelformat, + (&f->fmt.pix)->bytesperline, + (&f->fmt.pix)->sizeimage, + (&f->fmt.pix)->colorspace, + (&f->fmt.pix)->priv);This is not as nice to look at as the original. Just ignore the warning.
Quoted 3 lines
regards,
dan carpenter
So, is this warning to be ignored from everywhere in every driver, as it doesn't look good? And if yes, then why is it there in the first place?
Thanks!
Quoted 38 lines · Kaaira Gupta
Quoted 37 lines · Dan Carpenter
Quoted 22 lines · Kaaira Gupta
Fix checkpatch.pl warning of 'macro argument reuse' in
bcm2835-camera.hby removing the macro and calling the function, written in macro inbcm2835-camera.h, directly inbcm2835-camera.cSigned-off-by Kaaira Gupta <[email protected]>--- .../bcm2835-camera/bcm2835-camera.c | 28 +++++++++++++++---- .../bcm2835-camera/bcm2835-camera.h | 10 ------- 2 files changed, 22 insertions(+), 16 deletions(-)drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +1
-3@@ -919,9 +919,17 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,else f->fmt.pix.colorspace =V4L2_COLORSPACE_SMPTE170M ; f->fmt.pix.priv =0 ; - -v4l2_dump_pix_format (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, &f->fmt.pix, - __func__); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, · line 932
Quoted 10 lines
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +10
-0+"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n" , + __func__, + (&f->fmt.pix)->width, + (&f->fmt.pix)->height, + (&f->fmt.pix)->field, + (&f->fmt.pix)->pixelformat, + (&f->fmt.pix)->bytesperline, + (&f->fmt.pix)->sizeimage, + (&f->fmt.pix)->colorspace, + (&f->fmt.pix)->priv);This is not as nice to look at as the original. Just ignore the warning.
Quoted 5 lines
Quoted 3 lines
regards,
dan carpenterSo, is this warning to be ignored from everywhere in every driver, as it doesn't look good? And if yes, then why is it there in the first place?
Obviously the reason for the warning is a good idea. Do a google search for the dangers of c macros if you don't understand.
But at the same time uniformity and clean code is nice so it's a matter of setting priorities. Checkpatch is just a Perl script and not the King of The World. We can ignore it if we want to.
regards,
dan carpenter