|
@@ -27,6 +27,7 @@
|
|
#include <linux/slab.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/mutex.h>
|
|
|
|
+#include <linux/smp_lock.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/usb.h>
|
|
#include <linux/usb.h>
|
|
|
|
|
|
@@ -103,19 +104,23 @@ static int vstusb_open(struct inode *inode, struct file *file)
|
|
struct vstusb_device *vstdev;
|
|
struct vstusb_device *vstdev;
|
|
struct usb_interface *interface;
|
|
struct usb_interface *interface;
|
|
|
|
|
|
|
|
+ lock_kernel();
|
|
interface = usb_find_interface(&vstusb_driver, iminor(inode));
|
|
interface = usb_find_interface(&vstusb_driver, iminor(inode));
|
|
|
|
|
|
if (!interface) {
|
|
if (!interface) {
|
|
printk(KERN_ERR KBUILD_MODNAME
|
|
printk(KERN_ERR KBUILD_MODNAME
|
|
": %s - error, can't find device for minor %d\n",
|
|
": %s - error, can't find device for minor %d\n",
|
|
__func__, iminor(inode));
|
|
__func__, iminor(inode));
|
|
|
|
+ unlock_kernel();
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
|
|
vstdev = usb_get_intfdata(interface);
|
|
vstdev = usb_get_intfdata(interface);
|
|
|
|
|
|
- if (!vstdev)
|
|
|
|
|
|
+ if (!vstdev) {
|
|
|
|
+ unlock_kernel();
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
|
|
+ }
|
|
|
|
|
|
/* lock this device */
|
|
/* lock this device */
|
|
mutex_lock(&vstdev->lock);
|
|
mutex_lock(&vstdev->lock);
|
|
@@ -123,6 +128,7 @@ static int vstusb_open(struct inode *inode, struct file *file)
|
|
/* can only open one time */
|
|
/* can only open one time */
|
|
if ((!vstdev->present) || (vstdev->isopen)) {
|
|
if ((!vstdev->present) || (vstdev->isopen)) {
|
|
mutex_unlock(&vstdev->lock);
|
|
mutex_unlock(&vstdev->lock);
|
|
|
|
+ unlock_kernel();
|
|
return -EBUSY;
|
|
return -EBUSY;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,6 +143,7 @@ static int vstusb_open(struct inode *inode, struct file *file)
|
|
dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__);
|
|
dev_dbg(&vstdev->usb_dev->dev, "%s: opened\n", __func__);
|
|
|
|
|
|
mutex_unlock(&vstdev->lock);
|
|
mutex_unlock(&vstdev->lock);
|
|
|
|
+ unlock_kernel();
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|