diff options
Diffstat (limited to 'drivers/usb/misc/idmouse.c')
-rw-r--r-- | drivers/usb/misc/idmouse.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index b3aca5124339..d0b167256699 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
27 | #include <linux/completion.h> | 27 | #include <linux/completion.h> |
28 | #include <linux/mutex.h> | ||
28 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
29 | #include <linux/usb.h> | 30 | #include <linux/usb.h> |
30 | 31 | ||
@@ -121,7 +122,7 @@ static struct usb_driver idmouse_driver = { | |||
121 | }; | 122 | }; |
122 | 123 | ||
123 | /* prevent races between open() and disconnect() */ | 124 | /* prevent races between open() and disconnect() */ |
124 | static DECLARE_MUTEX(disconnect_sem); | 125 | static DEFINE_MUTEX(disconnect_mutex); |
125 | 126 | ||
126 | static int idmouse_create_image(struct usb_idmouse *dev) | 127 | static int idmouse_create_image(struct usb_idmouse *dev) |
127 | { | 128 | { |
@@ -213,18 +214,18 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
213 | int result = 0; | 214 | int result = 0; |
214 | 215 | ||
215 | /* prevent disconnects */ | 216 | /* prevent disconnects */ |
216 | down(&disconnect_sem); | 217 | mutex_lock(&disconnect_mutex); |
217 | 218 | ||
218 | /* get the interface from minor number and driver information */ | 219 | /* get the interface from minor number and driver information */ |
219 | interface = usb_find_interface (&idmouse_driver, iminor (inode)); | 220 | interface = usb_find_interface (&idmouse_driver, iminor (inode)); |
220 | if (!interface) { | 221 | if (!interface) { |
221 | up(&disconnect_sem); | 222 | mutex_unlock(&disconnect_mutex); |
222 | return -ENODEV; | 223 | return -ENODEV; |
223 | } | 224 | } |
224 | /* get the device information block from the interface */ | 225 | /* get the device information block from the interface */ |
225 | dev = usb_get_intfdata(interface); | 226 | dev = usb_get_intfdata(interface); |
226 | if (!dev) { | 227 | if (!dev) { |
227 | up(&disconnect_sem); | 228 | mutex_unlock(&disconnect_mutex); |
228 | return -ENODEV; | 229 | return -ENODEV; |
229 | } | 230 | } |
230 | 231 | ||
@@ -258,7 +259,7 @@ error: | |||
258 | up(&dev->sem); | 259 | up(&dev->sem); |
259 | 260 | ||
260 | /* unlock the disconnect semaphore */ | 261 | /* unlock the disconnect semaphore */ |
261 | up(&disconnect_sem); | 262 | mutex_unlock(&disconnect_mutex); |
262 | return result; | 263 | return result; |
263 | } | 264 | } |
264 | 265 | ||
@@ -267,12 +268,12 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
267 | struct usb_idmouse *dev; | 268 | struct usb_idmouse *dev; |
268 | 269 | ||
269 | /* prevent a race condition with open() */ | 270 | /* prevent a race condition with open() */ |
270 | down(&disconnect_sem); | 271 | mutex_lock(&disconnect_mutex); |
271 | 272 | ||
272 | dev = (struct usb_idmouse *) file->private_data; | 273 | dev = (struct usb_idmouse *) file->private_data; |
273 | 274 | ||
274 | if (dev == NULL) { | 275 | if (dev == NULL) { |
275 | up(&disconnect_sem); | 276 | mutex_unlock(&disconnect_mutex); |
276 | return -ENODEV; | 277 | return -ENODEV; |
277 | } | 278 | } |
278 | 279 | ||
@@ -282,7 +283,7 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
282 | /* are we really open? */ | 283 | /* are we really open? */ |
283 | if (dev->open <= 0) { | 284 | if (dev->open <= 0) { |
284 | up(&dev->sem); | 285 | up(&dev->sem); |
285 | up(&disconnect_sem); | 286 | mutex_unlock(&disconnect_mutex); |
286 | return -ENODEV; | 287 | return -ENODEV; |
287 | } | 288 | } |
288 | 289 | ||
@@ -292,12 +293,12 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
292 | /* the device was unplugged before the file was released */ | 293 | /* the device was unplugged before the file was released */ |
293 | up(&dev->sem); | 294 | up(&dev->sem); |
294 | idmouse_delete(dev); | 295 | idmouse_delete(dev); |
295 | up(&disconnect_sem); | 296 | mutex_unlock(&disconnect_mutex); |
296 | return 0; | 297 | return 0; |
297 | } | 298 | } |
298 | 299 | ||
299 | up(&dev->sem); | 300 | up(&dev->sem); |
300 | up(&disconnect_sem); | 301 | mutex_unlock(&disconnect_mutex); |
301 | return 0; | 302 | return 0; |
302 | } | 303 | } |
303 | 304 | ||
@@ -399,7 +400,7 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
399 | struct usb_idmouse *dev; | 400 | struct usb_idmouse *dev; |
400 | 401 | ||
401 | /* prevent races with open() */ | 402 | /* prevent races with open() */ |
402 | down(&disconnect_sem); | 403 | mutex_lock(&disconnect_mutex); |
403 | 404 | ||
404 | /* get device structure */ | 405 | /* get device structure */ |
405 | dev = usb_get_intfdata(interface); | 406 | dev = usb_get_intfdata(interface); |
@@ -421,7 +422,7 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
421 | if (!dev->open) | 422 | if (!dev->open) |
422 | idmouse_delete(dev); | 423 | idmouse_delete(dev); |
423 | 424 | ||
424 | up(&disconnect_sem); | 425 | mutex_unlock(&disconnect_mutex); |
425 | 426 | ||
426 | info("%s disconnected", DRIVER_DESC); | 427 | info("%s disconnected", DRIVER_DESC); |
427 | } | 428 | } |