media: usb: cpia2: Fixed coding style issues
PATCH 1/4 media: usb: cpia2: Fixed coding style issues
Fixed coding style issues with spaces for if condition & others statements.
--- drivers/media/usb/cpia2/cpia2_v4l.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/usb/cpia2/cpia2_v4l.c +7 -7
@@ -143,7 +143,7 @@ static ssize_t cpia2_v4l_read(struct file *file, char __user *buf, size_t count,int noblock = file->f_flags&O_NONBLOCK ;ssize_t ret; -if (!cam) +if (!cam)return -EINVAL ;if (mutex_lock_interruptible (&cam->v4l2_lock))
@@ -247,8 +247,8 @@ static int cpia2_querycap(struct file *file, void *fh, struct v4l2_capability *vbreak ; } -if (usb_make_path (cam->dev, vc->bus_info,sizeof (vc->bus_info)) <0 ) -memset (vc->bus_info,0 ,sizeof (vc->bus_info)); +if (usb_make_path (cam->dev, vc->bus_info,sizeof (vc->bus_info)) <0 ) +memset (vc->bus_info,0 ,sizeof (vc->bus_info));return 0 ; }
@@ -377,7 +377,7 @@ static int cpia2_s_fmt_vid_cap(struct file *file, void *_fh,int err, frame; err =cpia2_try_fmt_vid_cap (file, _fh, f); -if (err !=0 ) +if (err !=0 )return err; cam->pixelformat = f->fmt.pix.pixelformat;
@@ -665,13 +665,13 @@ static int cpia2_g_jpegcomp(struct file *file, void *fh, struct v4l2_jpegcompres parms->quality =80 ;// TODO: Can this be made meaningful? parms->jpeg_markers =V4L2_JPEG_MARKER_DQT |V4L2_JPEG_MARKER_DRI ; -if (!cam->params.compression.inhibit_htables) { +if (!cam->params.compression.inhibit_htables) parms->jpeg_markers |=V4L2_JPEG_MARKER_DHT ; - } + parms->APPn = cam->APPn; parms->APP_len = cam->APP_len; -if (cam->APP_len >0 ) { +if (cam->APP_len >0 ) {memcpy (parms->APP_data, cam->APP_data, cam->APP_len); parms->jpeg_markers |=V4L2_JPEG_MARKER_APP ; }
Signature · 1 line
2.25.1
PATCH 2/4 media: usb: cpia2: Fixed coding style issues
Adding more fixes on coding style issues.
--- drivers/media/usb/cpia2/cpia2_v4l.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/usb/cpia2/cpia2_v4l.c +7 -7
@@ -677,7 +677,7 @@ static int cpia2_g_jpegcomp(struct file *file, void *fh, struct v4l2_jpegcompres } parms->COM_len = cam->COM_len; -if (cam->COM_len >0 ) { +if (cam->COM_len >0 ) {memcpy (parms->COM_data, cam->COM_data, cam->COM_len); parms->jpeg_markers |=JPEG_MARKER_COM ; }
@@ -708,8 +708,8 @@ static int cpia2_s_jpegcomp(struct file *file, void *fh, cam->params.compression.inhibit_htables = !(parms->jpeg_markers &V4L2_JPEG_MARKER_DHT ); -if (parms->APP_len !=0 ) { -if (parms->APP_len >0 && +if (parms->APP_len !=0 ) { +if (parms->APP_len >0 && parms->APP_len <=sizeof (cam->APP_data) && parms->APPn >=0 && parms->APPn <=15 ) { cam->APPn = parms->APPn;
@@ -724,8 +724,8 @@ static int cpia2_s_jpegcomp(struct file *file, void *fh, cam->APP_len =0 ; } -if (parms->COM_len !=0 ) { -if (parms->COM_len >0 && +if (parms->COM_len !=0 ) { +if (parms->COM_len >0 && parms->COM_len <=sizeof (cam->COM_data)) { cam->COM_len = parms->COM_len;memcpy (cam->COM_data, parms->COM_data, parms->COM_len);
@@ -751,7 +751,7 @@ static int cpia2_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers {struct camera_data *cam =video_drvdata (file); -if (req->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || +if (req->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || req->memory !=V4L2_MEMORY_MMAP )return -EINVAL ;
@@ -774,7 +774,7 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) {struct camera_data *cam =video_drvdata (file); -if (buf->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || +if (buf->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || buf->index >= cam->num_frames)return -EINVAL ;
Signature · 1 line
2.25.1
PATCH 3/4 media: usb: cpia2: Fixed coding style issues
In reply to Piyush ThangeAdditional fixes about coding style.
--- drivers/media/usb/cpia2/cpia2_v4l.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/media/usb/cpia2/cpia2_v4l.c +8 -7
@@ -783,7 +783,7 @@ static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) buf->memory =V4L2_MEMORY_MMAP ; -if (cam->mmapped) +if (cam->mmapped) buf->flags =V4L2_BUF_FLAG_MAPPED ;else buf->flags =0 ;
@@ -824,14 +824,14 @@ static int cpia2_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) {struct camera_data *cam =video_drvdata (file); -if (buf->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || +if (buf->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || buf->memory !=V4L2_MEMORY_MMAP || buf->index >= cam->num_frames)return -EINVAL ;DBG ("QBUF #%d\n" , buf->index); -if (cam->buffers[buf->index].status ==FRAME_READY ) +if (cam->buffers[buf->index].status ==FRAME_READY ) cam->buffers[buf->index].status =FRAME_EMPTY ;return 0 ;
@@ -849,9 +849,10 @@ static int find_earliest_filled_buffer(struct camera_data *cam) {int i;int found =-1 ; -for (i=0 ; i<cam->num_frames; i++) { -if (cam->buffers[i].status ==FRAME_READY ) { -if (found <0 ) { + +for (i =0 ; i < cam->num_frames; i++) { +if (cam->buffers[i].status ==FRAME_READY ) { +if (found <0 ) { found = i; }else {/* find which buffer is earlier */
@@ -876,7 +877,7 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)struct camera_data *cam =video_drvdata (file);int frame; -if (buf->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || +if (buf->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE || buf->memory !=V4L2_MEMORY_MMAP )return -EINVAL ;
Signature · 1 line
2.25.1
PATCH 4/4 media: usb: cpia2: Fixed coding style issues
In reply to Piyush ThangeAddition of more fixes on coding style.
--- drivers/media/usb/cpia2/cpia2_v4l.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/media/usb/cpia2/cpia2_v4l.c +9 -9
@@ -883,12 +883,12 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) frame =find_earliest_filled_buffer (cam); -if (frame <0 && file->f_flags&O_NONBLOCK ) +if (frame <0 && file->f_flags&O_NONBLOCK )return -EAGAIN ; -if (frame <0 ) { +if (frame <0 ) {/* Wait for a frame to become available */ -struct framebuf *cb=cam->curbuff; +struct framebuf *cb = cam->curbuff;mutex_unlock (&cam->v4l2_lock); wait_event_interruptible(cam->wq_stream, !video_is_registered(&cam->vdev) ||
@@ -970,7 +970,7 @@ static int cpia2_mmap(struct file *file, struct vm_area_struct *area)return -ERESTARTSYS ; retval =cpia2_remap_buffer (cam, area); -if (!retval) +if (!retval) cam->stream_fh = file->private_data;mutex_unlock (&cam->v4l2_lock);return retval;
@@ -1160,10 +1160,10 @@ void cpia2_unregister_camera(struct camera_data *cam)*****************************************************************************/ static void __init check_parameters (void ) { -if (buffer_size <PAGE_SIZE ) { +if (buffer_size <PAGE_SIZE ) { buffer_size =PAGE_SIZE ;LOG ("buffer_size too small, setting to %d\n" , buffer_size); - }else if (buffer_size >1024 *1024 ) { + }else if (buffer_size >1024 *1024 ) {/* arbitrary upper limiit */ buffer_size =1024 *1024 ; LOG("buffer_size ridiculously large, setting to %d\n",
@@ -1173,15 +1173,15 @@ static void __init check_parameters(void) buffer_size &= ~(PAGE_SIZE -1 ); } -if (num_buffers <1 ) { +if (num_buffers <1 ) { num_buffers =1 ;LOG ("num_buffers too small, setting to %d\n" , num_buffers); - }else if (num_buffers >VIDEO_MAX_FRAME ) { + }else if (num_buffers >VIDEO_MAX_FRAME ) { num_buffers =VIDEO_MAX_FRAME ;LOG ("num_buffers too large, setting to %d\n" , num_buffers); } -if (alternate <USBIF_ISO_1 || alternate >USBIF_ISO_6 ) { +if (alternate <USBIF_ISO_1 || alternate >USBIF_ISO_6 ) { alternate =DEFAULT_ALT ;LOG ("alternate specified is invalid, using %d\n" , alternate); }
Signature · 1 line
2.25.1
Quoted 12 lines · Piyush Thange
Addition of more fixes on coding style.
Signed-off-by Piyush Thange <[email protected]>--- drivers/media/usb/cpia2/cpia2_v4l.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)drivers/media/usb/cpia2/cpia2_v4l.c +0
-0
drivers/media/usb/cpia2/cpia2_v4l.c static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) · line 886
Quoted 5 lines
drivers/media/usb/cpia2/cpia2_v4l.c +1
-1@@ -883,12 +883,12 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) frame =find_earliest_filled_buffer (cam); -if (frame <0 && file->f_flags&O_NONBLOCK ) +if (frame <0 && file->f_flags&O_NONBLOCK )
Add spaces around & as well.
There is no need to split this up into four patches. Just post a single patch for all these changes.
Quoted 20 lines
drivers/media/usb/cpia2/cpia2_v4l.c +3
-3return -EAGAIN ; -if (frame <0 ) { +if (frame <0 ) {/* Wait for a frame to become available */ -struct framebuf *cb=cam->curbuff; +struct framebuf *cb = cam->curbuff;mutex_unlock (&cam->v4l2_lock); wait_event_interruptible(cam->wq_stream, !video_is_registered(&cam->vdev) ||@@ -970,7 +970,7 @@ static int cpia2_mmap(struct file *file, struct vm_area_struct *area)return -ERESTARTSYS ; retval =cpia2_remap_buffer (cam, area); -if (!retval) +if (!retval) cam->stream_fh = file->private_data;mutex_unlock (&cam->v4l2_lock);return retval;
drivers/media/usb/cpia2/cpia2_v4l.c void cpia2_unregister_camera(struct camera_data *cam) · line 1166
Quoted 9 lines
drivers/media/usb/cpia2/cpia2_v4l.c +2
-2@@ -1160,10 +1160,10 @@ void cpia2_unregister_camera(struct camera_data *cam)*****************************************************************************/ static void __init check_parameters (void ) { -if (buffer_size <PAGE_SIZE ) { +if (buffer_size <PAGE_SIZE ) { buffer_size =PAGE_SIZE ;LOG ("buffer_size too small, setting to %d\n" , buffer_size); - }else if (buffer_size >1024 *1024 ) { + }else if (buffer_size >1024 *1024 ) {
Add spaces around * as well. checkpatch.pl --strict warns about that!
Regards,
Hans
Quoted 23 lines
drivers/media/usb/cpia2/cpia2_v4l.c +3
-3/* arbitrary upper limiit */ buffer_size =1024 *1024 ; LOG("buffer_size ridiculously large, setting to %d\n",@@ -1173,15 +1173,15 @@ static void __init check_parameters(void) buffer_size &= ~(PAGE_SIZE -1 ); } -if (num_buffers <1 ) { +if (num_buffers <1 ) { num_buffers =1 ;LOG ("num_buffers too small, setting to %d\n" , num_buffers); - }else if (num_buffers >VIDEO_MAX_FRAME ) { + }else if (num_buffers >VIDEO_MAX_FRAME ) { num_buffers =VIDEO_MAX_FRAME ;LOG ("num_buffers too large, setting to %d\n" , num_buffers); } -if (alternate <USBIF_ISO_1 || alternate >USBIF_ISO_6 ) { +if (alternate <USBIF_ISO_1 || alternate >USBIF_ISO_6 ) { alternate =DEFAULT_ALT ;LOG ("alternate specified is invalid, using %d\n" , alternate); }