aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-04 07:00:48 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:40:10 -0500
commit10351adc6ac9251863ec6d90436e3ad277d178e0 (patch)
tree0a271b52167b68f786ef4b50ce264b41ecb1c9a0
parentdc0fb28675e7ef7ac12a5532500b2f89e41f2174 (diff)
[media] stk-webcam: don't use private_data, use video_drvdata
file->private_data is needed to store the pointer to struct v4l2_fh. So use video_drvdata to get hold of the stk_camera struct. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Arvydas Sidorenko <asido4@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index f1cf9060ce71..49a4dfd22bf2 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -604,11 +604,7 @@ static void stk_free_buffers(struct stk_camera *dev)
604static int v4l_stk_open(struct file *fp) 604static int v4l_stk_open(struct file *fp)
605{ 605{
606 static int first_init = 1; /* webcam LED management */ 606 static int first_init = 1; /* webcam LED management */
607 struct stk_camera *dev; 607 struct stk_camera *dev = video_drvdata(fp);
608 struct video_device *vdev;
609
610 vdev = video_devdata(fp);
611 dev = vdev_to_camera(vdev);
612 608
613 if (dev == NULL || !is_present(dev)) 609 if (dev == NULL || !is_present(dev))
614 return -ENXIO; 610 return -ENXIO;
@@ -618,7 +614,6 @@ static int v4l_stk_open(struct file *fp)
618 else 614 else
619 first_init = 0; 615 first_init = 0;
620 616
621 fp->private_data = dev;
622 usb_autopm_get_interface(dev->interface); 617 usb_autopm_get_interface(dev->interface);
623 618
624 return 0; 619 return 0;
@@ -626,7 +621,7 @@ static int v4l_stk_open(struct file *fp)
626 621
627static int v4l_stk_release(struct file *fp) 622static int v4l_stk_release(struct file *fp)
628{ 623{
629 struct stk_camera *dev = fp->private_data; 624 struct stk_camera *dev = video_drvdata(fp);
630 625
631 if (dev->owner == fp) { 626 if (dev->owner == fp) {
632 stk_stop_stream(dev); 627 stk_stop_stream(dev);
@@ -649,7 +644,7 @@ static ssize_t v4l_stk_read(struct file *fp, char __user *buf,
649 int ret; 644 int ret;
650 unsigned long flags; 645 unsigned long flags;
651 struct stk_sio_buffer *sbuf; 646 struct stk_sio_buffer *sbuf;
652 struct stk_camera *dev = fp->private_data; 647 struct stk_camera *dev = video_drvdata(fp);
653 648
654 if (!is_present(dev)) 649 if (!is_present(dev))
655 return -EIO; 650 return -EIO;
@@ -705,7 +700,7 @@ static ssize_t v4l_stk_read(struct file *fp, char __user *buf,
705 700
706static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) 701static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
707{ 702{
708 struct stk_camera *dev = fp->private_data; 703 struct stk_camera *dev = video_drvdata(fp);
709 704
710 poll_wait(fp, &dev->wait_frame, wait); 705 poll_wait(fp, &dev->wait_frame, wait);
711 706
@@ -741,7 +736,7 @@ static int v4l_stk_mmap(struct file *fp, struct vm_area_struct *vma)
741 unsigned int i; 736 unsigned int i;
742 int ret; 737 int ret;
743 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; 738 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
744 struct stk_camera *dev = fp->private_data; 739 struct stk_camera *dev = video_drvdata(fp);
745 struct stk_sio_buffer *sbuf = NULL; 740 struct stk_sio_buffer *sbuf = NULL;
746 741
747 if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED)) 742 if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED))
@@ -879,7 +874,7 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp,
879 void *priv, struct v4l2_format *f) 874 void *priv, struct v4l2_format *f)
880{ 875{
881 struct v4l2_pix_format *pix_format = &f->fmt.pix; 876 struct v4l2_pix_format *pix_format = &f->fmt.pix;
882 struct stk_camera *dev = priv; 877 struct stk_camera *dev = video_drvdata(filp);
883 int i; 878 int i;
884 879
885 for (i = 0; i < ARRAY_SIZE(stk_sizes) && 880 for (i = 0; i < ARRAY_SIZE(stk_sizes) &&
@@ -984,7 +979,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp,
984 void *priv, struct v4l2_format *fmtd) 979 void *priv, struct v4l2_format *fmtd)
985{ 980{
986 int ret; 981 int ret;
987 struct stk_camera *dev = priv; 982 struct stk_camera *dev = video_drvdata(filp);
988 983
989 if (dev == NULL) 984 if (dev == NULL)
990 return -ENODEV; 985 return -ENODEV;
@@ -1011,7 +1006,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp,
1011static int stk_vidioc_reqbufs(struct file *filp, 1006static int stk_vidioc_reqbufs(struct file *filp,
1012 void *priv, struct v4l2_requestbuffers *rb) 1007 void *priv, struct v4l2_requestbuffers *rb)
1013{ 1008{
1014 struct stk_camera *dev = priv; 1009 struct stk_camera *dev = video_drvdata(filp);
1015 1010
1016 if (dev == NULL) 1011 if (dev == NULL)
1017 return -ENODEV; 1012 return -ENODEV;
@@ -1037,7 +1032,7 @@ static int stk_vidioc_reqbufs(struct file *filp,
1037static int stk_vidioc_querybuf(struct file *filp, 1032static int stk_vidioc_querybuf(struct file *filp,
1038 void *priv, struct v4l2_buffer *buf) 1033 void *priv, struct v4l2_buffer *buf)
1039{ 1034{
1040 struct stk_camera *dev = priv; 1035 struct stk_camera *dev = video_drvdata(filp);
1041 struct stk_sio_buffer *sbuf; 1036 struct stk_sio_buffer *sbuf;
1042 1037
1043 if (buf->index >= dev->n_sbufs) 1038 if (buf->index >= dev->n_sbufs)
@@ -1050,7 +1045,7 @@ static int stk_vidioc_querybuf(struct file *filp,
1050static int stk_vidioc_qbuf(struct file *filp, 1045static int stk_vidioc_qbuf(struct file *filp,
1051 void *priv, struct v4l2_buffer *buf) 1046 void *priv, struct v4l2_buffer *buf)
1052{ 1047{
1053 struct stk_camera *dev = priv; 1048 struct stk_camera *dev = video_drvdata(filp);
1054 struct stk_sio_buffer *sbuf; 1049 struct stk_sio_buffer *sbuf;
1055 unsigned long flags; 1050 unsigned long flags;
1056 1051
@@ -1074,7 +1069,7 @@ static int stk_vidioc_qbuf(struct file *filp,
1074static int stk_vidioc_dqbuf(struct file *filp, 1069static int stk_vidioc_dqbuf(struct file *filp,
1075 void *priv, struct v4l2_buffer *buf) 1070 void *priv, struct v4l2_buffer *buf)
1076{ 1071{
1077 struct stk_camera *dev = priv; 1072 struct stk_camera *dev = video_drvdata(filp);
1078 struct stk_sio_buffer *sbuf; 1073 struct stk_sio_buffer *sbuf;
1079 unsigned long flags; 1074 unsigned long flags;
1080 int ret; 1075 int ret;
@@ -1107,7 +1102,7 @@ static int stk_vidioc_dqbuf(struct file *filp,
1107static int stk_vidioc_streamon(struct file *filp, 1102static int stk_vidioc_streamon(struct file *filp,
1108 void *priv, enum v4l2_buf_type type) 1103 void *priv, enum v4l2_buf_type type)
1109{ 1104{
1110 struct stk_camera *dev = priv; 1105 struct stk_camera *dev = video_drvdata(filp);
1111 if (is_streaming(dev)) 1106 if (is_streaming(dev))
1112 return 0; 1107 return 0;
1113 if (dev->sio_bufs == NULL) 1108 if (dev->sio_bufs == NULL)
@@ -1119,7 +1114,7 @@ static int stk_vidioc_streamon(struct file *filp,
1119static int stk_vidioc_streamoff(struct file *filp, 1114static int stk_vidioc_streamoff(struct file *filp,
1120 void *priv, enum v4l2_buf_type type) 1115 void *priv, enum v4l2_buf_type type)
1121{ 1116{
1122 struct stk_camera *dev = priv; 1117 struct stk_camera *dev = video_drvdata(filp);
1123 unsigned long flags; 1118 unsigned long flags;
1124 int i; 1119 int i;
1125 stk_stop_stream(dev); 1120 stk_stop_stream(dev);
@@ -1222,6 +1217,7 @@ static int stk_register_video_device(struct stk_camera *dev)
1222 dev->vdev = stk_v4l_data; 1217 dev->vdev = stk_v4l_data;
1223 dev->vdev.debug = debug; 1218 dev->vdev.debug = debug;
1224 dev->vdev.v4l2_dev = &dev->v4l2_dev; 1219 dev->vdev.v4l2_dev = &dev->v4l2_dev;
1220 video_set_drvdata(&dev->vdev, dev);
1225 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); 1221 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
1226 if (err) 1222 if (err)
1227 STK_ERROR("v4l registration failed\n"); 1223 STK_ERROR("v4l registration failed\n");