Loading drivers/usb/class/cdc-acm.c +12 −11 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ #include <linux/tty_flip.h> #include <linux/module.h> #include <linux/smp_lock.h> #include <linux/mutex.h> #include <asm/uaccess.h> #include <linux/usb.h> #include <linux/usb_cdc.h> Loading @@ -80,7 +81,7 @@ static struct usb_driver acm_driver; static struct tty_driver *acm_tty_driver; static struct acm *acm_table[ACM_TTY_MINORS]; static DECLARE_MUTEX(open_sem); static DEFINE_MUTEX(open_mutex); #define ACM_READY(acm) (acm && acm->dev && acm->used) Loading Loading @@ -432,7 +433,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) int i; dbg("Entering acm_tty_open.\n"); down(&open_sem); mutex_lock(&open_mutex); acm = acm_table[tty->index]; if (!acm || !acm->dev) Loading Loading @@ -474,14 +475,14 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) done: err_out: up(&open_sem); mutex_unlock(&open_mutex); return rv; full_bailout: usb_kill_urb(acm->ctrlurb); bail_out: acm->used--; up(&open_sem); mutex_unlock(&open_mutex); return -EIO; } Loading @@ -507,7 +508,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) if (!acm || !acm->used) return; down(&open_sem); mutex_lock(&open_mutex); if (!--acm->used) { if (acm->dev) { acm_set_control(acm, acm->ctrlout = 0); Loading @@ -518,7 +519,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) } else acm_tty_unregister(acm); } up(&open_sem); mutex_unlock(&open_mutex); } static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) Loading Loading @@ -1013,9 +1014,9 @@ static void acm_disconnect(struct usb_interface *intf) return; } down(&open_sem); mutex_lock(&open_mutex); if (!usb_get_intfdata(intf)) { up(&open_sem); mutex_unlock(&open_mutex); return; } acm->dev = NULL; Loading Loading @@ -1045,11 +1046,11 @@ static void acm_disconnect(struct usb_interface *intf) if (!acm->used) { acm_tty_unregister(acm); up(&open_sem); mutex_unlock(&open_mutex); return; } up(&open_sem); mutex_unlock(&open_mutex); if (acm->tty) tty_hangup(acm->tty); Loading drivers/usb/class/usblp.c +8 −7 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/lp.h> #include <linux/mutex.h> #undef DEBUG #include <linux/usb.h> Loading Loading @@ -223,7 +224,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp); /* forward reference to make our lives easier */ static struct usb_driver usblp_driver; static DECLARE_MUTEX(usblp_sem); /* locks the existence of usblp's */ static DEFINE_MUTEX(usblp_mutex); /* locks the existence of usblp's */ /* * Functions for usblp control messages. Loading Loading @@ -351,7 +352,7 @@ static int usblp_open(struct inode *inode, struct file *file) if (minor < 0) return -ENODEV; down (&usblp_sem); mutex_lock (&usblp_mutex); retval = -ENODEV; intf = usb_find_interface(&usblp_driver, minor); Loading Loading @@ -399,7 +400,7 @@ static int usblp_open(struct inode *inode, struct file *file) } } out: up (&usblp_sem); mutex_unlock (&usblp_mutex); return retval; } Loading @@ -425,13 +426,13 @@ static int usblp_release(struct inode *inode, struct file *file) { struct usblp *usblp = file->private_data; down (&usblp_sem); mutex_lock (&usblp_mutex); usblp->used = 0; if (usblp->present) { usblp_unlink_urbs(usblp); } else /* finish cleanup from disconnect */ usblp_cleanup (usblp); up (&usblp_sem); mutex_unlock (&usblp_mutex); return 0; } Loading Loading @@ -1152,7 +1153,7 @@ static void usblp_disconnect(struct usb_interface *intf) device_remove_file(&intf->dev, &dev_attr_ieee1284_id); down (&usblp_sem); mutex_lock (&usblp_mutex); down (&usblp->sem); usblp->present = 0; usb_set_intfdata (intf, NULL); Loading @@ -1166,7 +1167,7 @@ static void usblp_disconnect(struct usb_interface *intf) if (!usblp->used) usblp_cleanup (usblp); up (&usblp_sem); mutex_unlock (&usblp_mutex); } static struct usb_device_id usblp_ids [] = { Loading drivers/usb/core/devices.c +4 −3 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ #include <linux/usb.h> #include <linux/smp_lock.h> #include <linux/usbdevice_fs.h> #include <linux/mutex.h> #include <asm/uaccess.h> #include "usb.h" Loading Loading @@ -570,7 +571,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte if (!access_ok(VERIFY_WRITE, buf, nbytes)) return -EFAULT; down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); /* print devices for all busses */ list_for_each_entry(bus, &usb_bus_list, bus_list) { /* recurse through all children of the root hub */ Loading @@ -580,12 +581,12 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); usb_unlock_device(bus->root_hub); if (ret < 0) { up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return ret; } total_written += ret; } up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return total_written; } Loading drivers/usb/core/hcd.c +13 −12 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <asm/scatterlist.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/mutex.h> #include <asm/irq.h> #include <asm/byteorder.h> Loading Loading @@ -93,7 +94,7 @@ struct usb_busmap { static struct usb_busmap busmap; /* used when updating list of hcds */ DECLARE_MUTEX (usb_bus_list_lock); /* exported only for usbfs */ DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */ EXPORT_SYMBOL_GPL (usb_bus_list_lock); /* used for controlling access to virtual root hubs */ Loading Loading @@ -761,14 +762,14 @@ static int usb_register_bus(struct usb_bus *bus) { int busnum; down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); if (busnum < USB_MAXBUS) { set_bit (busnum, busmap.busmap); bus->busnum = busnum; } else { printk (KERN_ERR "%s: too many buses\n", usbcore_name); up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return -E2BIG; } Loading @@ -776,7 +777,7 @@ static int usb_register_bus(struct usb_bus *bus) bus->controller, "usb_host%d", busnum); if (IS_ERR(bus->class_dev)) { clear_bit(busnum, busmap.busmap); up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return PTR_ERR(bus->class_dev); } Loading @@ -784,7 +785,7 @@ static int usb_register_bus(struct usb_bus *bus) /* Add it to the local list of buses */ list_add (&bus->bus_list, &usb_bus_list); up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); usb_notify_add_bus(bus); Loading @@ -809,9 +810,9 @@ static void usb_deregister_bus (struct usb_bus *bus) * controller code, as well as having it call this when cleaning * itself up */ down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); list_del (&bus->bus_list); up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); usb_notify_remove_bus(bus); Loading Loading @@ -844,14 +845,14 @@ static int register_root_hub (struct usb_device *usb_dev, set_bit (devnum, usb_dev->bus->devmap.devicemap); usb_set_device_state(usb_dev, USB_STATE_ADDRESS); down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); usb_dev->bus->root_hub = usb_dev; usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); if (retval != sizeof usb_dev->descriptor) { usb_dev->bus->root_hub = NULL; up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); dev_dbg (parent_dev, "can't read %s device descriptor %d\n", usb_dev->dev.bus_id, retval); return (retval < 0) ? retval : -EMSGSIZE; Loading @@ -863,7 +864,7 @@ static int register_root_hub (struct usb_device *usb_dev, dev_err (parent_dev, "can't register root hub for %s, %d\n", usb_dev->dev.bus_id, retval); } up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); if (retval == 0) { spin_lock_irq (&hcd_root_hub_lock); Loading Loading @@ -1891,9 +1892,9 @@ void usb_remove_hcd(struct usb_hcd *hcd) hcd->rh_registered = 0; spin_unlock_irq (&hcd_root_hub_lock); down(&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); usb_disconnect(&hcd->self.root_hub); up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); hcd->poll_rh = 0; del_timer_sync(&hcd->rh_timer); Loading drivers/usb/core/hcd.h +1 −1 Original line number Diff line number Diff line Loading @@ -364,7 +364,7 @@ extern void usb_set_device_state(struct usb_device *udev, /* exported only within usbcore */ extern struct list_head usb_bus_list; extern struct semaphore usb_bus_list_lock; extern struct mutex usb_bus_list_lock; extern wait_queue_head_t usb_kill_urb_queue; extern struct usb_bus *usb_bus_get (struct usb_bus *bus); Loading Loading
drivers/usb/class/cdc-acm.c +12 −11 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ #include <linux/tty_flip.h> #include <linux/module.h> #include <linux/smp_lock.h> #include <linux/mutex.h> #include <asm/uaccess.h> #include <linux/usb.h> #include <linux/usb_cdc.h> Loading @@ -80,7 +81,7 @@ static struct usb_driver acm_driver; static struct tty_driver *acm_tty_driver; static struct acm *acm_table[ACM_TTY_MINORS]; static DECLARE_MUTEX(open_sem); static DEFINE_MUTEX(open_mutex); #define ACM_READY(acm) (acm && acm->dev && acm->used) Loading Loading @@ -432,7 +433,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) int i; dbg("Entering acm_tty_open.\n"); down(&open_sem); mutex_lock(&open_mutex); acm = acm_table[tty->index]; if (!acm || !acm->dev) Loading Loading @@ -474,14 +475,14 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) done: err_out: up(&open_sem); mutex_unlock(&open_mutex); return rv; full_bailout: usb_kill_urb(acm->ctrlurb); bail_out: acm->used--; up(&open_sem); mutex_unlock(&open_mutex); return -EIO; } Loading @@ -507,7 +508,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) if (!acm || !acm->used) return; down(&open_sem); mutex_lock(&open_mutex); if (!--acm->used) { if (acm->dev) { acm_set_control(acm, acm->ctrlout = 0); Loading @@ -518,7 +519,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) } else acm_tty_unregister(acm); } up(&open_sem); mutex_unlock(&open_mutex); } static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) Loading Loading @@ -1013,9 +1014,9 @@ static void acm_disconnect(struct usb_interface *intf) return; } down(&open_sem); mutex_lock(&open_mutex); if (!usb_get_intfdata(intf)) { up(&open_sem); mutex_unlock(&open_mutex); return; } acm->dev = NULL; Loading Loading @@ -1045,11 +1046,11 @@ static void acm_disconnect(struct usb_interface *intf) if (!acm->used) { acm_tty_unregister(acm); up(&open_sem); mutex_unlock(&open_mutex); return; } up(&open_sem); mutex_unlock(&open_mutex); if (acm->tty) tty_hangup(acm->tty); Loading
drivers/usb/class/usblp.c +8 −7 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <linux/lp.h> #include <linux/mutex.h> #undef DEBUG #include <linux/usb.h> Loading Loading @@ -223,7 +224,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp); /* forward reference to make our lives easier */ static struct usb_driver usblp_driver; static DECLARE_MUTEX(usblp_sem); /* locks the existence of usblp's */ static DEFINE_MUTEX(usblp_mutex); /* locks the existence of usblp's */ /* * Functions for usblp control messages. Loading Loading @@ -351,7 +352,7 @@ static int usblp_open(struct inode *inode, struct file *file) if (minor < 0) return -ENODEV; down (&usblp_sem); mutex_lock (&usblp_mutex); retval = -ENODEV; intf = usb_find_interface(&usblp_driver, minor); Loading Loading @@ -399,7 +400,7 @@ static int usblp_open(struct inode *inode, struct file *file) } } out: up (&usblp_sem); mutex_unlock (&usblp_mutex); return retval; } Loading @@ -425,13 +426,13 @@ static int usblp_release(struct inode *inode, struct file *file) { struct usblp *usblp = file->private_data; down (&usblp_sem); mutex_lock (&usblp_mutex); usblp->used = 0; if (usblp->present) { usblp_unlink_urbs(usblp); } else /* finish cleanup from disconnect */ usblp_cleanup (usblp); up (&usblp_sem); mutex_unlock (&usblp_mutex); return 0; } Loading Loading @@ -1152,7 +1153,7 @@ static void usblp_disconnect(struct usb_interface *intf) device_remove_file(&intf->dev, &dev_attr_ieee1284_id); down (&usblp_sem); mutex_lock (&usblp_mutex); down (&usblp->sem); usblp->present = 0; usb_set_intfdata (intf, NULL); Loading @@ -1166,7 +1167,7 @@ static void usblp_disconnect(struct usb_interface *intf) if (!usblp->used) usblp_cleanup (usblp); up (&usblp_sem); mutex_unlock (&usblp_mutex); } static struct usb_device_id usblp_ids [] = { Loading
drivers/usb/core/devices.c +4 −3 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ #include <linux/usb.h> #include <linux/smp_lock.h> #include <linux/usbdevice_fs.h> #include <linux/mutex.h> #include <asm/uaccess.h> #include "usb.h" Loading Loading @@ -570,7 +571,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte if (!access_ok(VERIFY_WRITE, buf, nbytes)) return -EFAULT; down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); /* print devices for all busses */ list_for_each_entry(bus, &usb_bus_list, bus_list) { /* recurse through all children of the root hub */ Loading @@ -580,12 +581,12 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); usb_unlock_device(bus->root_hub); if (ret < 0) { up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return ret; } total_written += ret; } up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return total_written; } Loading
drivers/usb/core/hcd.c +13 −12 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <asm/scatterlist.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/mutex.h> #include <asm/irq.h> #include <asm/byteorder.h> Loading Loading @@ -93,7 +94,7 @@ struct usb_busmap { static struct usb_busmap busmap; /* used when updating list of hcds */ DECLARE_MUTEX (usb_bus_list_lock); /* exported only for usbfs */ DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */ EXPORT_SYMBOL_GPL (usb_bus_list_lock); /* used for controlling access to virtual root hubs */ Loading Loading @@ -761,14 +762,14 @@ static int usb_register_bus(struct usb_bus *bus) { int busnum; down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); if (busnum < USB_MAXBUS) { set_bit (busnum, busmap.busmap); bus->busnum = busnum; } else { printk (KERN_ERR "%s: too many buses\n", usbcore_name); up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return -E2BIG; } Loading @@ -776,7 +777,7 @@ static int usb_register_bus(struct usb_bus *bus) bus->controller, "usb_host%d", busnum); if (IS_ERR(bus->class_dev)) { clear_bit(busnum, busmap.busmap); up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); return PTR_ERR(bus->class_dev); } Loading @@ -784,7 +785,7 @@ static int usb_register_bus(struct usb_bus *bus) /* Add it to the local list of buses */ list_add (&bus->bus_list, &usb_bus_list); up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); usb_notify_add_bus(bus); Loading @@ -809,9 +810,9 @@ static void usb_deregister_bus (struct usb_bus *bus) * controller code, as well as having it call this when cleaning * itself up */ down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); list_del (&bus->bus_list); up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); usb_notify_remove_bus(bus); Loading Loading @@ -844,14 +845,14 @@ static int register_root_hub (struct usb_device *usb_dev, set_bit (devnum, usb_dev->bus->devmap.devicemap); usb_set_device_state(usb_dev, USB_STATE_ADDRESS); down (&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); usb_dev->bus->root_hub = usb_dev; usb_dev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); if (retval != sizeof usb_dev->descriptor) { usb_dev->bus->root_hub = NULL; up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); dev_dbg (parent_dev, "can't read %s device descriptor %d\n", usb_dev->dev.bus_id, retval); return (retval < 0) ? retval : -EMSGSIZE; Loading @@ -863,7 +864,7 @@ static int register_root_hub (struct usb_device *usb_dev, dev_err (parent_dev, "can't register root hub for %s, %d\n", usb_dev->dev.bus_id, retval); } up (&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); if (retval == 0) { spin_lock_irq (&hcd_root_hub_lock); Loading Loading @@ -1891,9 +1892,9 @@ void usb_remove_hcd(struct usb_hcd *hcd) hcd->rh_registered = 0; spin_unlock_irq (&hcd_root_hub_lock); down(&usb_bus_list_lock); mutex_lock(&usb_bus_list_lock); usb_disconnect(&hcd->self.root_hub); up(&usb_bus_list_lock); mutex_unlock(&usb_bus_list_lock); hcd->poll_rh = 0; del_timer_sync(&hcd->rh_timer); Loading
drivers/usb/core/hcd.h +1 −1 Original line number Diff line number Diff line Loading @@ -364,7 +364,7 @@ extern void usb_set_device_state(struct usb_device *udev, /* exported only within usbcore */ extern struct list_head usb_bus_list; extern struct semaphore usb_bus_list_lock; extern struct mutex usb_bus_list_lock; extern wait_queue_head_t usb_kill_urb_queue; extern struct usb_bus *usb_bus_get (struct usb_bus *bus); Loading