@@ -862,7 +862,7 @@ static int dev_open(struct inode *inode, struct file *file)
862
862
int ret ;
863
863
864
864
PDEBUG (D_STREAM , "%s open" , current -> comm );
865
- gspca_dev = ( struct gspca_dev * ) video_devdata (file );
865
+ gspca_dev = video_drvdata (file );
866
866
if (mutex_lock_interruptible (& gspca_dev -> queue_lock ))
867
867
return - ERESTARTSYS ;
868
868
if (!gspca_dev -> present ) {
@@ -890,10 +890,10 @@ static int dev_open(struct inode *inode, struct file *file)
890
890
#ifdef GSPCA_DEBUG
891
891
/* activate the v4l2 debug */
892
892
if (gspca_debug & D_V4L2 )
893
- gspca_dev -> vdev . debug |= V4L2_DEBUG_IOCTL
893
+ gspca_dev -> vdev -> debug |= V4L2_DEBUG_IOCTL
894
894
| V4L2_DEBUG_IOCTL_ARG ;
895
895
else
896
- gspca_dev -> vdev . debug &= ~(V4L2_DEBUG_IOCTL
896
+ gspca_dev -> vdev -> debug &= ~(V4L2_DEBUG_IOCTL
897
897
| V4L2_DEBUG_IOCTL_ARG );
898
898
#endif
899
899
ret = 0 ;
@@ -1755,11 +1755,6 @@ static ssize_t dev_read(struct file *file, char __user *data,
1755
1755
return ret ;
1756
1756
}
1757
1757
1758
- static void dev_release (struct video_device * vfd )
1759
- {
1760
- /* nothing */
1761
- }
1762
-
1763
1758
static struct file_operations dev_fops = {
1764
1759
.owner = THIS_MODULE ,
1765
1760
.open = dev_open ,
@@ -1807,7 +1802,7 @@ static struct video_device gspca_template = {
1807
1802
.name = "gspca main driver" ,
1808
1803
.fops = & dev_fops ,
1809
1804
.ioctl_ops = & dev_ioctl_ops ,
1810
- .release = dev_release , /* mandatory */
1805
+ .release = video_device_release ,
1811
1806
.minor = -1 ,
1812
1807
};
1813
1808
@@ -1876,24 +1871,27 @@ int gspca_dev_probe(struct usb_interface *intf,
1876
1871
init_waitqueue_head (& gspca_dev -> wq );
1877
1872
1878
1873
/* init video stuff */
1879
- memcpy ( & gspca_dev -> vdev , & gspca_template , sizeof gspca_template );
1880
- gspca_dev -> vdev . parent = & dev -> dev ;
1881
- gspca_dev -> vdev . fops = & dev_fops ;
1874
+ gspca_dev -> vdev = video_device_alloc ( );
1875
+ memcpy ( gspca_dev -> vdev , & gspca_template , sizeof gspca_template ) ;
1876
+ gspca_dev -> vdev -> parent = & dev -> dev ;
1882
1877
gspca_dev -> module = module ;
1883
1878
gspca_dev -> present = 1 ;
1884
- ret = video_register_device (& gspca_dev -> vdev ,
1879
+ video_set_drvdata (gspca_dev -> vdev , gspca_dev );
1880
+ ret = video_register_device (gspca_dev -> vdev ,
1885
1881
VFL_TYPE_GRABBER ,
1886
1882
video_nr );
1887
1883
if (ret < 0 ) {
1888
1884
err ("video_register_device err %d" , ret );
1885
+ video_device_release (gspca_dev -> vdev );
1889
1886
goto out ;
1890
1887
}
1891
1888
1892
1889
usb_set_intfdata (intf , gspca_dev );
1893
1890
PDEBUG (D_PROBE , "probe ok" );
1894
1891
return 0 ;
1895
1892
out :
1896
- kref_put (& gspca_dev -> kref , gspca_delete );
1893
+ kfree (gspca_dev -> usb_buf );
1894
+ kfree (gspca_dev );
1897
1895
return ret ;
1898
1896
}
1899
1897
EXPORT_SYMBOL (gspca_dev_probe );
@@ -1911,7 +1909,7 @@ void gspca_disconnect(struct usb_interface *intf)
1911
1909
usb_set_intfdata (intf , NULL );
1912
1910
1913
1911
/* We don't want people trying to open up the device */
1914
- video_unregister_device (& gspca_dev -> vdev );
1912
+ video_unregister_device (gspca_dev -> vdev );
1915
1913
1916
1914
gspca_dev -> present = 0 ;
1917
1915
gspca_dev -> streaming = 0 ;
0 commit comments