|
Line
Link Here
|
|
-- |
|
|
| 1 |
drivers/usb/core/devio.c | 26 +++++++++++++++----------- |
|
drivers/usb/core/devio.c | 26 +++++++++++++++----------- |
| 2 |
drivers/usb/core/notify.c | 3 +++ |
1 |
drivers/usb/core/notify.c | 3 +++ |
| 3 |
drivers/usb/core/usb.h | 1 + |
2 |
drivers/usb/core/usb.h | 1 + |
| 4 |
3 files changed, 19 insertions(+), 11 deletions(-) |
3 |
3 files changed, 19 insertions(+), 11 deletions(-) |
| 5 |
-- a/drivers/usb/core/devio.c |
4 |
++ b/drivers/usb/core/devio.c |
|
Lines 58-63
Link Here
|
| 58 |
#define USB_DEVICE_MAX USB_MAXBUS * 128 |
58 |
#define USB_DEVICE_MAX USB_MAXBUS * 128 |
| 59 |
static struct class *usb_device_class; |
59 |
static struct class *usb_device_class; |
| 60 |
|
60 |
|
|
|
61 |
/* Mutual exclusion for removal, open, and release */ |
| 62 |
DEFINE_MUTEX(usbfs_mutex); |
| 63 |
|
| 61 |
struct async { |
64 |
struct async { |
| 62 |
struct list_head asynclist; |
65 |
struct list_head asynclist; |
| 63 |
struct dev_state *ps; |
66 |
struct dev_state *ps; |
|
Lines 543-557
static int usbdev_open(struct inode *ino
Link Here
|
| 543 |
struct dev_state *ps; |
546 |
struct dev_state *ps; |
| 544 |
int ret; |
547 |
int ret; |
| 545 |
|
548 |
|
| 546 |
/* |
549 |
/* Protect against simultaneous removal or release */ |
| 547 |
* no locking necessary here, as chrdev_open has the kernel lock |
550 |
mutex_lock(&usbfs_mutex); |
| 548 |
* (still acquire the kernel lock for safety) |
551 |
|
| 549 |
*/ |
|
|
| 550 |
ret = -ENOMEM; |
552 |
ret = -ENOMEM; |
| 551 |
if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) |
553 |
if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) |
| 552 |
goto out_nolock; |
554 |
goto out; |
| 553 |
|
555 |
|
| 554 |
lock_kernel(); |
|
|
| 555 |
ret = -ENOENT; |
556 |
ret = -ENOENT; |
| 556 |
/* check if we are called from a real node or usbfs */ |
557 |
/* check if we are called from a real node or usbfs */ |
| 557 |
if (imajor(inode) == USB_DEVICE_MAJOR) |
558 |
if (imajor(inode) == USB_DEVICE_MAJOR) |
|
Lines 580-588
static int usbdev_open(struct inode *ino
Link Here
|
| 580 |
list_add_tail(&ps->list, &dev->filelist); |
581 |
list_add_tail(&ps->list, &dev->filelist); |
| 581 |
file->private_data = ps; |
582 |
file->private_data = ps; |
| 582 |
out: |
583 |
out: |
| 583 |
unlock_kernel(); |
584 |
mutex_unlock(&usbfs_mutex); |
| 584 |
out_nolock: |
585 |
return ret; |
| 585 |
return ret; |
|
|
| 586 |
} |
586 |
} |
| 587 |
|
587 |
|
| 588 |
static int usbdev_release(struct inode *inode, struct file *file) |
588 |
static int usbdev_release(struct inode *inode, struct file *file) |
|
Lines 592-598
static int usbdev_release(struct inode *
Link Here
|
| 592 |
unsigned int ifnum; |
592 |
unsigned int ifnum; |
| 593 |
|
593 |
|
| 594 |
usb_lock_device(dev); |
594 |
usb_lock_device(dev); |
|
|
595 |
|
| 596 |
/* Protect against simultaneous open */ |
| 597 |
mutex_lock(&usbfs_mutex); |
| 595 |
list_del_init(&ps->list); |
598 |
list_del_init(&ps->list); |
|
|
599 |
mutex_unlock(&usbfs_mutex); |
| 600 |
|
| 596 |
for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); |
601 |
for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); |
| 597 |
ifnum++) { |
602 |
ifnum++) { |
| 598 |
if (test_bit(ifnum, &ps->ifclaimed)) |
603 |
if (test_bit(ifnum, &ps->ifclaimed)) |
|
Lines 601-609
static int usbdev_release(struct inode *
Link Here
|
| 601 |
destroy_all_async(ps); |
606 |
destroy_all_async(ps); |
| 602 |
usb_unlock_device(dev); |
607 |
usb_unlock_device(dev); |
| 603 |
usb_put_dev(dev); |
608 |
usb_put_dev(dev); |
| 604 |
ps->dev = NULL; |
|
|
| 605 |
kfree(ps); |
609 |
kfree(ps); |
| 606 |
return 0; |
610 |
return 0; |
| 607 |
} |
611 |
} |
| 608 |
|
612 |
|
| 609 |
static int proc_control(struct dev_state *ps, void __user *arg) |
613 |
static int proc_control(struct dev_state *ps, void __user *arg) |
| 610 |
-- a/drivers/usb/core/notify.c |
614 |
++ b/drivers/usb/core/notify.c |
|
Lines 100-106
void usb_notify_add_device(struct usb_de
Link Here
|
| 100 |
|
100 |
|
| 101 |
void usb_notify_remove_device(struct usb_device *udev) |
101 |
void usb_notify_remove_device(struct usb_device *udev) |
| 102 |
{ |
102 |
{ |
|
|
103 |
/* Protect against simultaneous usbfs open */ |
| 104 |
mutex_lock(&usbfs_mutex); |
| 103 |
usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_REMOVE, udev); |
105 |
usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_REMOVE, udev); |
|
|
106 |
mutex_unlock(&usbfs_mutex); |
| 104 |
} |
107 |
} |
| 105 |
|
108 |
|
| 106 |
void usb_notify_add_bus(struct usb_bus *ubus) |
109 |
void usb_notify_add_bus(struct usb_bus *ubus) |
| 107 |
-- a/drivers/usb/core/usb.h |
110 |
++ b/drivers/usb/core/usb.h |
|
Lines 56-61
static inline int is_active(struct usb_i
Link Here
|
| 56 |
extern const char *usbcore_name; |
56 |
extern const char *usbcore_name; |
| 57 |
|
57 |
|
| 58 |
/* usbfs stuff */ |
58 |
/* usbfs stuff */ |
|
|
59 |
extern struct mutex usbfs_mutex; |
| 59 |
extern struct usb_driver usbfs_driver; |
60 |
extern struct usb_driver usbfs_driver; |
| 60 |
extern struct file_operations usbfs_devices_fops; |
61 |
extern struct file_operations usbfs_devices_fops; |
| 61 |
extern struct file_operations usbfs_device_file_operations; |
62 |
extern struct file_operations usbfs_device_file_operations; |