Commit 584b2373 authored by Piyush Thange's avatar Piyush Thange Committed by Mauro Carvalho Chehab

media: usb: cpia2: Fixed Coding Style issues

Fixed all the Coding style issues generated by checkpatch.pl.
The changes made considering the --strict option.
Signed-off-by: default avatarPiyush Thange <pthange19@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 5d11e6aa
......@@ -140,10 +140,10 @@ static ssize_t cpia2_v4l_read(struct file *file, char __user *buf, size_t count,
loff_t *off)
{
struct camera_data *cam = video_drvdata(file);
int noblock = file->f_flags&O_NONBLOCK;
int noblock = file->f_flags & O_NONBLOCK;
ssize_t ret;
if(!cam)
if (!cam)
return -EINVAL;
if (mutex_lock_interruptible(&cam->v4l2_lock))
......@@ -153,7 +153,6 @@ static ssize_t cpia2_v4l_read(struct file *file, char __user *buf, size_t count,
return ret;
}
/******************************************************************************
*
* cpia2_v4l_poll
......@@ -170,7 +169,6 @@ static __poll_t cpia2_v4l_poll(struct file *filp, struct poll_table_struct *wait
return res;
}
static int sync(struct camera_data *cam, int frame_nr)
{
struct framebuf *frame = &cam->buffers[frame_nr];
......@@ -247,8 +245,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,13 +375,14 @@ 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;
/* NOTE: This should be set to 1 for MJPEG, but some apps don't handle
* the missing Huffman table properly. */
* the missing Huffman table properly.
*/
cam->params.compression.inhibit_htables = 0;
/*f->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG;*/
......@@ -549,7 +548,6 @@ static const struct {
static int cpia2_enum_framesizes(struct file *file, void *fh,
struct v4l2_frmsizeenum *fsize)
{
if (fsize->pixel_format != V4L2_PIX_FMT_MJPEG &&
fsize->pixel_format != V4L2_PIX_FMT_JPEG)
return -EINVAL;
......@@ -665,19 +663,18 @@ 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;
}
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 +705,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 +721,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 +748,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 +771,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;
......@@ -783,7 +780,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 +821,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 +846,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,22 +874,23 @@ 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;
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) ||
(cb=cam->curbuff)->status == FRAME_READY);
(cb = cam->curbuff)->status == FRAME_READY);
mutex_lock(&cam->v4l2_lock);
if (signal_pending(current))
return -ERESTARTSYS;
......@@ -900,7 +899,6 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
frame = cb->num;
}
buf->index = frame;
buf->bytesused = cam->buffers[buf->index].length;
buf->flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE
......@@ -969,7 +967,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;
......@@ -1106,13 +1104,16 @@ int cpia2_register_camera(struct camera_data *cam)
if (cam->params.pnp_id.device_type == DEVICE_STV_672)
v4l2_ctrl_new_std_menu(hdl, &cpia2_ctrl_ops,
V4L2_CID_POWER_LINE_FREQUENCY,
V4L2_CID_POWER_LINE_FREQUENCY_60HZ, 0, 0);
V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
0, 0);
/* Light control only valid for the QX5 Microscope */
if (cam->params.pnp_id.product == 0x151) {
cam->top_light = v4l2_ctrl_new_std(hdl, &cpia2_ctrl_ops,
V4L2_CID_ILLUMINATORS_1, 0, 1, 1, 0);
V4L2_CID_ILLUMINATORS_1,
0, 1, 1, 0);
cam->bottom_light = v4l2_ctrl_new_std(hdl, &cpia2_ctrl_ops,
V4L2_CID_ILLUMINATORS_2, 0, 1, 1, 0);
V4L2_CID_ILLUMINATORS_2,
0, 1, 1, 0);
v4l2_ctrl_cluster(2, &cam->top_light);
}
......@@ -1159,28 +1160,28 @@ 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;
buffer_size = 1024 * 1024;
LOG("buffer_size ridiculously large, setting to %d\n",
buffer_size);
} else {
buffer_size += PAGE_SIZE-1;
buffer_size &= ~(PAGE_SIZE-1);
buffer_size += PAGE_SIZE - 1;
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);
}
......@@ -1197,7 +1198,6 @@ static void __init check_parameters(void)
/************ Module Stuff ***************/
/******************************************************************************
*
* cpia2_init/module_init
......@@ -1211,7 +1211,6 @@ static int __init cpia2_init(void)
return cpia2_usb_init();
}
/******************************************************************************
*
* cpia2_exit/module_exit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment