2021-04-30 15:50:43

by Piyush Thange

[permalink] [raw]
Subject: [PATCH 1/4] media: usb: cpia2: Fixed coding style issues

Fixed coding style issues with spaces for if condition &
others statements.

Signed-off-by: Piyush Thange <[email protected]>
---
drivers/media/usb/cpia2/cpia2_v4l.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
index 69d5c628a797..4b58b1e7847e 100644
--- a/drivers/media/usb/cpia2/cpia2_v4l.c
+++ b/drivers/media/usb/cpia2/cpia2_v4l.c
@@ -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 *v
break;
}

- 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;
}
--
2.25.1


2021-04-30 15:50:59

by Piyush Thange

[permalink] [raw]
Subject: [PATCH 4/4] media: usb: cpia2: Fixed coding style issues

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(-)

diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
index 261ced144793..d950f9171208 100644
--- a/drivers/media/usb/cpia2/cpia2_v4l.c
+++ b/drivers/media/usb/cpia2/cpia2_v4l.c
@@ -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);
}
--
2.25.1

2021-05-26 13:37:48

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 4/4] media: usb: cpia2: Fixed coding style issues

On 30/04/2021 17:43, Piyush Thange wrote:
> 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(-)
>
> diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
> index 261ced144793..d950f9171208 100644
> --- a/drivers/media/usb/cpia2/cpia2_v4l.c
> +++ b/drivers/media/usb/cpia2/cpia2_v4l.c
> @@ -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.

> 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) {

Add spaces around * as well. checkpatch.pl --strict warns about that!

Regards,

Hans

> /* 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);
> }
>