aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/gspca.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-06 08:28:18 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 08:26:46 -0400
commitf4c1605a74c46100d93f465238b9962ac9499e36 (patch)
treeb93af988889d32566bf105bc6cefb3a6724e500f /drivers/media/video/gspca/gspca.c
parent62bba5dd8181bed282967f1054ed5749b2c499f9 (diff)
[media] gspca: Use video_drvdata(file) instead of file->private_data
Prepare for control events: free up file->private_data by using video_drvdata(file) to get to the gspca_dev struct. [mchehab@redhat.com: fix a compile error: ‘file’ undeclared] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/gspca.c')
-rw-r--r--drivers/media/video/gspca/gspca.c64
1 files changed, 31 insertions, 33 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index d85c30dd37ad..dbebed90bbac 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -1061,7 +1061,7 @@ static int vidioc_g_register(struct file *file, void *priv,
1061 struct v4l2_dbg_register *reg) 1061 struct v4l2_dbg_register *reg)
1062{ 1062{
1063 int ret; 1063 int ret;
1064 struct gspca_dev *gspca_dev = priv; 1064 struct gspca_dev *gspca_dev = video_drvdata(file);
1065 1065
1066 if (!gspca_dev->sd_desc->get_chip_ident) 1066 if (!gspca_dev->sd_desc->get_chip_ident)
1067 return -EINVAL; 1067 return -EINVAL;
@@ -1085,7 +1085,7 @@ static int vidioc_s_register(struct file *file, void *priv,
1085 struct v4l2_dbg_register *reg) 1085 struct v4l2_dbg_register *reg)
1086{ 1086{
1087 int ret; 1087 int ret;
1088 struct gspca_dev *gspca_dev = priv; 1088 struct gspca_dev *gspca_dev = video_drvdata(file);
1089 1089
1090 if (!gspca_dev->sd_desc->get_chip_ident) 1090 if (!gspca_dev->sd_desc->get_chip_ident)
1091 return -EINVAL; 1091 return -EINVAL;
@@ -1110,7 +1110,7 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,
1110 struct v4l2_dbg_chip_ident *chip) 1110 struct v4l2_dbg_chip_ident *chip)
1111{ 1111{
1112 int ret; 1112 int ret;
1113 struct gspca_dev *gspca_dev = priv; 1113 struct gspca_dev *gspca_dev = video_drvdata(file);
1114 1114
1115 if (!gspca_dev->sd_desc->get_chip_ident) 1115 if (!gspca_dev->sd_desc->get_chip_ident)
1116 return -EINVAL; 1116 return -EINVAL;
@@ -1130,7 +1130,7 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,
1130static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, 1130static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
1131 struct v4l2_fmtdesc *fmtdesc) 1131 struct v4l2_fmtdesc *fmtdesc)
1132{ 1132{
1133 struct gspca_dev *gspca_dev = priv; 1133 struct gspca_dev *gspca_dev = video_drvdata(file);
1134 int i, j, index; 1134 int i, j, index;
1135 __u32 fmt_tb[8]; 1135 __u32 fmt_tb[8];
1136 1136
@@ -1172,7 +1172,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
1172static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, 1172static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
1173 struct v4l2_format *fmt) 1173 struct v4l2_format *fmt)
1174{ 1174{
1175 struct gspca_dev *gspca_dev = priv; 1175 struct gspca_dev *gspca_dev = video_drvdata(file);
1176 int mode; 1176 int mode;
1177 1177
1178 mode = gspca_dev->curr_mode; 1178 mode = gspca_dev->curr_mode;
@@ -1217,7 +1217,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file,
1217 void *priv, 1217 void *priv,
1218 struct v4l2_format *fmt) 1218 struct v4l2_format *fmt)
1219{ 1219{
1220 struct gspca_dev *gspca_dev = priv; 1220 struct gspca_dev *gspca_dev = video_drvdata(file);
1221 int ret; 1221 int ret;
1222 1222
1223 ret = try_fmt_vid_cap(gspca_dev, fmt); 1223 ret = try_fmt_vid_cap(gspca_dev, fmt);
@@ -1229,7 +1229,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file,
1229static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 1229static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1230 struct v4l2_format *fmt) 1230 struct v4l2_format *fmt)
1231{ 1231{
1232 struct gspca_dev *gspca_dev = priv; 1232 struct gspca_dev *gspca_dev = video_drvdata(file);
1233 int ret; 1233 int ret;
1234 1234
1235 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1235 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
@@ -1268,7 +1268,7 @@ out:
1268static int vidioc_enum_framesizes(struct file *file, void *priv, 1268static int vidioc_enum_framesizes(struct file *file, void *priv,
1269 struct v4l2_frmsizeenum *fsize) 1269 struct v4l2_frmsizeenum *fsize)
1270{ 1270{
1271 struct gspca_dev *gspca_dev = priv; 1271 struct gspca_dev *gspca_dev = video_drvdata(file);
1272 int i; 1272 int i;
1273 __u32 index = 0; 1273 __u32 index = 0;
1274 1274
@@ -1294,7 +1294,7 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
1294static int vidioc_enum_frameintervals(struct file *filp, void *priv, 1294static int vidioc_enum_frameintervals(struct file *filp, void *priv,
1295 struct v4l2_frmivalenum *fival) 1295 struct v4l2_frmivalenum *fival)
1296{ 1296{
1297 struct gspca_dev *gspca_dev = priv; 1297 struct gspca_dev *gspca_dev = video_drvdata(filp);
1298 int mode = wxh_to_mode(gspca_dev, fival->width, fival->height); 1298 int mode = wxh_to_mode(gspca_dev, fival->width, fival->height);
1299 __u32 i; 1299 __u32 i;
1300 1300
@@ -1333,10 +1333,9 @@ static void gspca_release(struct video_device *vfd)
1333 1333
1334static int dev_open(struct file *file) 1334static int dev_open(struct file *file)
1335{ 1335{
1336 struct gspca_dev *gspca_dev; 1336 struct gspca_dev *gspca_dev = video_drvdata(file);
1337 1337
1338 PDEBUG(D_STREAM, "[%s] open", current->comm); 1338 PDEBUG(D_STREAM, "[%s] open", current->comm);
1339 gspca_dev = (struct gspca_dev *) video_devdata(file);
1340 if (!gspca_dev->present) 1339 if (!gspca_dev->present)
1341 return -ENODEV; 1340 return -ENODEV;
1342 1341
@@ -1344,7 +1343,6 @@ static int dev_open(struct file *file)
1344 if (!try_module_get(gspca_dev->module)) 1343 if (!try_module_get(gspca_dev->module))
1345 return -ENODEV; 1344 return -ENODEV;
1346 1345
1347 file->private_data = gspca_dev;
1348#ifdef GSPCA_DEBUG 1346#ifdef GSPCA_DEBUG
1349 /* activate the v4l2 debug */ 1347 /* activate the v4l2 debug */
1350 if (gspca_debug & D_V4L2) 1348 if (gspca_debug & D_V4L2)
@@ -1359,7 +1357,7 @@ static int dev_open(struct file *file)
1359 1357
1360static int dev_close(struct file *file) 1358static int dev_close(struct file *file)
1361{ 1359{
1362 struct gspca_dev *gspca_dev = file->private_data; 1360 struct gspca_dev *gspca_dev = video_drvdata(file);
1363 1361
1364 PDEBUG(D_STREAM, "[%s] close", current->comm); 1362 PDEBUG(D_STREAM, "[%s] close", current->comm);
1365 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1363 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
@@ -1375,7 +1373,6 @@ static int dev_close(struct file *file)
1375 } 1373 }
1376 frame_free(gspca_dev); 1374 frame_free(gspca_dev);
1377 } 1375 }
1378 file->private_data = NULL;
1379 module_put(gspca_dev->module); 1376 module_put(gspca_dev->module);
1380 mutex_unlock(&gspca_dev->queue_lock); 1377 mutex_unlock(&gspca_dev->queue_lock);
1381 1378
@@ -1387,7 +1384,7 @@ static int dev_close(struct file *file)
1387static int vidioc_querycap(struct file *file, void *priv, 1384static int vidioc_querycap(struct file *file, void *priv,
1388 struct v4l2_capability *cap) 1385 struct v4l2_capability *cap)
1389{ 1386{
1390 struct gspca_dev *gspca_dev = priv; 1387 struct gspca_dev *gspca_dev = video_drvdata(file);
1391 int ret; 1388 int ret;
1392 1389
1393 /* protect the access to the usb device */ 1390 /* protect the access to the usb device */
@@ -1439,7 +1436,7 @@ static int get_ctrl(struct gspca_dev *gspca_dev,
1439static int vidioc_queryctrl(struct file *file, void *priv, 1436static int vidioc_queryctrl(struct file *file, void *priv,
1440 struct v4l2_queryctrl *q_ctrl) 1437 struct v4l2_queryctrl *q_ctrl)
1441{ 1438{
1442 struct gspca_dev *gspca_dev = priv; 1439 struct gspca_dev *gspca_dev = video_drvdata(file);
1443 const struct ctrl *ctrls; 1440 const struct ctrl *ctrls;
1444 struct gspca_ctrl *gspca_ctrl; 1441 struct gspca_ctrl *gspca_ctrl;
1445 int i, idx; 1442 int i, idx;
@@ -1482,7 +1479,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1482static int vidioc_s_ctrl(struct file *file, void *priv, 1479static int vidioc_s_ctrl(struct file *file, void *priv,
1483 struct v4l2_control *ctrl) 1480 struct v4l2_control *ctrl)
1484{ 1481{
1485 struct gspca_dev *gspca_dev = priv; 1482 struct gspca_dev *gspca_dev = video_drvdata(file);
1486 const struct ctrl *ctrls; 1483 const struct ctrl *ctrls;
1487 struct gspca_ctrl *gspca_ctrl; 1484 struct gspca_ctrl *gspca_ctrl;
1488 int idx, ret; 1485 int idx, ret;
@@ -1531,7 +1528,7 @@ out:
1531static int vidioc_g_ctrl(struct file *file, void *priv, 1528static int vidioc_g_ctrl(struct file *file, void *priv,
1532 struct v4l2_control *ctrl) 1529 struct v4l2_control *ctrl)
1533{ 1530{
1534 struct gspca_dev *gspca_dev = priv; 1531 struct gspca_dev *gspca_dev = video_drvdata(file);
1535 const struct ctrl *ctrls; 1532 const struct ctrl *ctrls;
1536 int idx, ret; 1533 int idx, ret;
1537 1534
@@ -1562,7 +1559,7 @@ out:
1562static int vidioc_querymenu(struct file *file, void *priv, 1559static int vidioc_querymenu(struct file *file, void *priv,
1563 struct v4l2_querymenu *qmenu) 1560 struct v4l2_querymenu *qmenu)
1564{ 1561{
1565 struct gspca_dev *gspca_dev = priv; 1562 struct gspca_dev *gspca_dev = video_drvdata(file);
1566 1563
1567 if (!gspca_dev->sd_desc->querymenu) 1564 if (!gspca_dev->sd_desc->querymenu)
1568 return -EINVAL; 1565 return -EINVAL;
@@ -1572,7 +1569,7 @@ static int vidioc_querymenu(struct file *file, void *priv,
1572static int vidioc_enum_input(struct file *file, void *priv, 1569static int vidioc_enum_input(struct file *file, void *priv,
1573 struct v4l2_input *input) 1570 struct v4l2_input *input)
1574{ 1571{
1575 struct gspca_dev *gspca_dev = priv; 1572 struct gspca_dev *gspca_dev = video_drvdata(file);
1576 1573
1577 if (input->index != 0) 1574 if (input->index != 0)
1578 return -EINVAL; 1575 return -EINVAL;
@@ -1599,7 +1596,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1599static int vidioc_reqbufs(struct file *file, void *priv, 1596static int vidioc_reqbufs(struct file *file, void *priv,
1600 struct v4l2_requestbuffers *rb) 1597 struct v4l2_requestbuffers *rb)
1601{ 1598{
1602 struct gspca_dev *gspca_dev = priv; 1599 struct gspca_dev *gspca_dev = video_drvdata(file);
1603 int i, ret = 0, streaming; 1600 int i, ret = 0, streaming;
1604 1601
1605 i = rb->memory; /* (avoid compilation warning) */ 1602 i = rb->memory; /* (avoid compilation warning) */
@@ -1670,7 +1667,7 @@ out:
1670static int vidioc_querybuf(struct file *file, void *priv, 1667static int vidioc_querybuf(struct file *file, void *priv,
1671 struct v4l2_buffer *v4l2_buf) 1668 struct v4l2_buffer *v4l2_buf)
1672{ 1669{
1673 struct gspca_dev *gspca_dev = priv; 1670 struct gspca_dev *gspca_dev = video_drvdata(file);
1674 struct gspca_frame *frame; 1671 struct gspca_frame *frame;
1675 1672
1676 if (v4l2_buf->index < 0 1673 if (v4l2_buf->index < 0
@@ -1685,7 +1682,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
1685static int vidioc_streamon(struct file *file, void *priv, 1682static int vidioc_streamon(struct file *file, void *priv,
1686 enum v4l2_buf_type buf_type) 1683 enum v4l2_buf_type buf_type)
1687{ 1684{
1688 struct gspca_dev *gspca_dev = priv; 1685 struct gspca_dev *gspca_dev = video_drvdata(file);
1689 int ret; 1686 int ret;
1690 1687
1691 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1688 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -1726,7 +1723,7 @@ out:
1726static int vidioc_streamoff(struct file *file, void *priv, 1723static int vidioc_streamoff(struct file *file, void *priv,
1727 enum v4l2_buf_type buf_type) 1724 enum v4l2_buf_type buf_type)
1728{ 1725{
1729 struct gspca_dev *gspca_dev = priv; 1726 struct gspca_dev *gspca_dev = video_drvdata(file);
1730 int ret; 1727 int ret;
1731 1728
1732 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1729 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -1770,7 +1767,7 @@ out:
1770static int vidioc_g_jpegcomp(struct file *file, void *priv, 1767static int vidioc_g_jpegcomp(struct file *file, void *priv,
1771 struct v4l2_jpegcompression *jpegcomp) 1768 struct v4l2_jpegcompression *jpegcomp)
1772{ 1769{
1773 struct gspca_dev *gspca_dev = priv; 1770 struct gspca_dev *gspca_dev = video_drvdata(file);
1774 int ret; 1771 int ret;
1775 1772
1776 if (!gspca_dev->sd_desc->get_jcomp) 1773 if (!gspca_dev->sd_desc->get_jcomp)
@@ -1789,7 +1786,7 @@ static int vidioc_g_jpegcomp(struct file *file, void *priv,
1789static int vidioc_s_jpegcomp(struct file *file, void *priv, 1786static int vidioc_s_jpegcomp(struct file *file, void *priv,
1790 struct v4l2_jpegcompression *jpegcomp) 1787 struct v4l2_jpegcompression *jpegcomp)
1791{ 1788{
1792 struct gspca_dev *gspca_dev = priv; 1789 struct gspca_dev *gspca_dev = video_drvdata(file);
1793 int ret; 1790 int ret;
1794 1791
1795 if (!gspca_dev->sd_desc->set_jcomp) 1792 if (!gspca_dev->sd_desc->set_jcomp)
@@ -1808,7 +1805,7 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv,
1808static int vidioc_g_parm(struct file *filp, void *priv, 1805static int vidioc_g_parm(struct file *filp, void *priv,
1809 struct v4l2_streamparm *parm) 1806 struct v4l2_streamparm *parm)
1810{ 1807{
1811 struct gspca_dev *gspca_dev = priv; 1808 struct gspca_dev *gspca_dev = video_drvdata(filp);
1812 1809
1813 parm->parm.capture.readbuffers = gspca_dev->nbufread; 1810 parm->parm.capture.readbuffers = gspca_dev->nbufread;
1814 1811
@@ -1834,7 +1831,7 @@ static int vidioc_g_parm(struct file *filp, void *priv,
1834static int vidioc_s_parm(struct file *filp, void *priv, 1831static int vidioc_s_parm(struct file *filp, void *priv,
1835 struct v4l2_streamparm *parm) 1832 struct v4l2_streamparm *parm)
1836{ 1833{
1837 struct gspca_dev *gspca_dev = priv; 1834 struct gspca_dev *gspca_dev = video_drvdata(filp);
1838 int n; 1835 int n;
1839 1836
1840 n = parm->parm.capture.readbuffers; 1837 n = parm->parm.capture.readbuffers;
@@ -1864,7 +1861,7 @@ static int vidioc_s_parm(struct file *filp, void *priv,
1864 1861
1865static int dev_mmap(struct file *file, struct vm_area_struct *vma) 1862static int dev_mmap(struct file *file, struct vm_area_struct *vma)
1866{ 1863{
1867 struct gspca_dev *gspca_dev = file->private_data; 1864 struct gspca_dev *gspca_dev = video_drvdata(file);
1868 struct gspca_frame *frame; 1865 struct gspca_frame *frame;
1869 struct page *page; 1866 struct page *page;
1870 unsigned long addr, start, size; 1867 unsigned long addr, start, size;
@@ -1967,7 +1964,7 @@ static int frame_ready(struct gspca_dev *gspca_dev, struct file *file,
1967static int vidioc_dqbuf(struct file *file, void *priv, 1964static int vidioc_dqbuf(struct file *file, void *priv,
1968 struct v4l2_buffer *v4l2_buf) 1965 struct v4l2_buffer *v4l2_buf)
1969{ 1966{
1970 struct gspca_dev *gspca_dev = priv; 1967 struct gspca_dev *gspca_dev = video_drvdata(file);
1971 struct gspca_frame *frame; 1968 struct gspca_frame *frame;
1972 int i, j, ret; 1969 int i, j, ret;
1973 1970
@@ -2043,7 +2040,7 @@ out:
2043static int vidioc_qbuf(struct file *file, void *priv, 2040static int vidioc_qbuf(struct file *file, void *priv,
2044 struct v4l2_buffer *v4l2_buf) 2041 struct v4l2_buffer *v4l2_buf)
2045{ 2042{
2046 struct gspca_dev *gspca_dev = priv; 2043 struct gspca_dev *gspca_dev = video_drvdata(file);
2047 struct gspca_frame *frame; 2044 struct gspca_frame *frame;
2048 int i, index, ret; 2045 int i, index, ret;
2049 2046
@@ -2137,7 +2134,7 @@ static int read_alloc(struct gspca_dev *gspca_dev,
2137 2134
2138static unsigned int dev_poll(struct file *file, poll_table *wait) 2135static unsigned int dev_poll(struct file *file, poll_table *wait)
2139{ 2136{
2140 struct gspca_dev *gspca_dev = file->private_data; 2137 struct gspca_dev *gspca_dev = video_drvdata(file);
2141 int ret; 2138 int ret;
2142 2139
2143 PDEBUG(D_FRAM, "poll"); 2140 PDEBUG(D_FRAM, "poll");
@@ -2168,7 +2165,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait)
2168static ssize_t dev_read(struct file *file, char __user *data, 2165static ssize_t dev_read(struct file *file, char __user *data,
2169 size_t count, loff_t *ppos) 2166 size_t count, loff_t *ppos)
2170{ 2167{
2171 struct gspca_dev *gspca_dev = file->private_data; 2168 struct gspca_dev *gspca_dev = video_drvdata(file);
2172 struct gspca_frame *frame; 2169 struct gspca_frame *frame;
2173 struct v4l2_buffer v4l2_buf; 2170 struct v4l2_buffer v4l2_buf;
2174 struct timeval timestamp; 2171 struct timeval timestamp;
@@ -2353,6 +2350,7 @@ int gspca_dev_probe2(struct usb_interface *intf,
2353 gspca_dev->empty_packet = -1; /* don't check the empty packets */ 2350 gspca_dev->empty_packet = -1; /* don't check the empty packets */
2354 gspca_dev->vdev = gspca_template; 2351 gspca_dev->vdev = gspca_template;
2355 gspca_dev->vdev.parent = &intf->dev; 2352 gspca_dev->vdev.parent = &intf->dev;
2353 video_set_drvdata(&gspca_dev->vdev, gspca_dev);
2356 gspca_dev->module = module; 2354 gspca_dev->module = module;
2357 gspca_dev->present = 1; 2355 gspca_dev->present = 1;
2358 2356