V4L/DVB (9706): gspca: Use the ref counting of v4l2 for disconnection.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
579ef87999
commit
d01823069f
@@ -30,7 +30,6 @@
|
|||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#include <linux/pagemap.h>
|
#include <linux/pagemap.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/kref.h>
|
|
||||||
#include <asm/page.h>
|
#include <asm/page.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
@@ -871,11 +870,11 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gspca_delete(struct kref *kref)
|
static void gspca_release(struct video_device *vfd)
|
||||||
{
|
{
|
||||||
struct gspca_dev *gspca_dev = container_of(kref, struct gspca_dev, kref);
|
struct gspca_dev *gspca_dev = container_of(vfd, struct gspca_dev, vdev);
|
||||||
|
|
||||||
PDEBUG(D_STREAM, "device deleted");
|
PDEBUG(D_STREAM, "device released");
|
||||||
|
|
||||||
kfree(gspca_dev->usb_buf);
|
kfree(gspca_dev->usb_buf);
|
||||||
kfree(gspca_dev);
|
kfree(gspca_dev);
|
||||||
@@ -908,9 +907,6 @@ static int dev_open(struct inode *inode, struct file *file)
|
|||||||
|
|
||||||
gspca_dev->users++;
|
gspca_dev->users++;
|
||||||
|
|
||||||
/* one more user */
|
|
||||||
kref_get(&gspca_dev->kref);
|
|
||||||
|
|
||||||
file->private_data = gspca_dev;
|
file->private_data = gspca_dev;
|
||||||
#ifdef GSPCA_DEBUG
|
#ifdef GSPCA_DEBUG
|
||||||
/* activate the v4l2 debug */
|
/* activate the v4l2 debug */
|
||||||
@@ -957,8 +953,6 @@ static int dev_close(struct inode *inode, struct file *file)
|
|||||||
|
|
||||||
PDEBUG(D_STREAM, "close done");
|
PDEBUG(D_STREAM, "close done");
|
||||||
|
|
||||||
kref_put(&gspca_dev->kref, gspca_delete);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1827,7 +1821,7 @@ static struct video_device gspca_template = {
|
|||||||
.name = "gspca main driver",
|
.name = "gspca main driver",
|
||||||
.fops = &dev_fops,
|
.fops = &dev_fops,
|
||||||
.ioctl_ops = &dev_ioctl_ops,
|
.ioctl_ops = &dev_ioctl_ops,
|
||||||
.release = video_device_release,
|
.release = gspca_release,
|
||||||
.minor = -1,
|
.minor = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1865,7 +1859,6 @@ int gspca_dev_probe(struct usb_interface *intf,
|
|||||||
err("couldn't kzalloc gspca struct");
|
err("couldn't kzalloc gspca struct");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
kref_init(&gspca_dev->kref);
|
|
||||||
gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL);
|
gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL);
|
||||||
if (!gspca_dev->usb_buf) {
|
if (!gspca_dev->usb_buf) {
|
||||||
err("out of memory");
|
err("out of memory");
|
||||||
@@ -1936,8 +1929,6 @@ void gspca_disconnect(struct usb_interface *intf)
|
|||||||
/* (this will call gspca_release() immediatly or on last close) */
|
/* (this will call gspca_release() immediatly or on last close) */
|
||||||
video_unregister_device(&gspca_dev->vdev);
|
video_unregister_device(&gspca_dev->vdev);
|
||||||
|
|
||||||
kref_put(&gspca_dev->kref, gspca_delete);
|
|
||||||
|
|
||||||
PDEBUG(D_PROBE, "disconnect complete");
|
PDEBUG(D_PROBE, "disconnect complete");
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(gspca_disconnect);
|
EXPORT_SYMBOL(gspca_disconnect);
|
||||||
|
@@ -127,7 +127,6 @@ struct gspca_dev {
|
|||||||
struct video_device vdev; /* !! must be the first item */
|
struct video_device vdev; /* !! must be the first item */
|
||||||
struct module *module; /* subdriver handling the device */
|
struct module *module; /* subdriver handling the device */
|
||||||
struct usb_device *dev;
|
struct usb_device *dev;
|
||||||
struct kref kref;
|
|
||||||
struct file *capt_file; /* file doing video capture */
|
struct file *capt_file; /* file doing video capture */
|
||||||
|
|
||||||
struct cam cam; /* device information */
|
struct cam cam; /* device information */
|
||||||
|
Reference in New Issue
Block a user