Commit a4b5d606 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Greg Kroah-Hartman

usb: core: rename mutex usb_bus_list_lock to usb_bus_idr_lock

Now that usb_bus_list has been removed and switched to idr
rename the related mutex accordingly.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1586ba0c
...@@ -620,7 +620,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, ...@@ -620,7 +620,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf,
if (!access_ok(VERIFY_WRITE, buf, nbytes)) if (!access_ok(VERIFY_WRITE, buf, nbytes))
return -EFAULT; return -EFAULT;
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
/* print devices for all busses */ /* print devices for all busses */
idr_for_each_entry(&usb_bus_idr, bus, id) { idr_for_each_entry(&usb_bus_idr, bus, id) {
/* recurse through all children of the root hub */ /* recurse through all children of the root hub */
...@@ -631,12 +631,12 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, ...@@ -631,12 +631,12 @@ static ssize_t usb_device_read(struct file *file, char __user *buf,
bus->root_hub, bus, 0, 0, 0); bus->root_hub, bus, 0, 0, 0);
usb_unlock_device(bus->root_hub); usb_unlock_device(bus->root_hub);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
return ret; return ret;
} }
total_written += ret; total_written += ret;
} }
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
return total_written; return total_written;
} }
......
...@@ -97,8 +97,8 @@ EXPORT_SYMBOL_GPL (usb_bus_idr); ...@@ -97,8 +97,8 @@ EXPORT_SYMBOL_GPL (usb_bus_idr);
#define USB_MAXBUS 64 #define USB_MAXBUS 64
/* used when updating list of hcds */ /* used when updating list of hcds */
DEFINE_MUTEX(usb_bus_list_lock); /* exported only for usbfs */ DEFINE_MUTEX(usb_bus_idr_lock); /* exported only for usbfs */
EXPORT_SYMBOL_GPL (usb_bus_list_lock); EXPORT_SYMBOL_GPL (usb_bus_idr_lock);
/* used for controlling access to virtual root hubs */ /* used for controlling access to virtual root hubs */
static DEFINE_SPINLOCK(hcd_root_hub_lock); static DEFINE_SPINLOCK(hcd_root_hub_lock);
...@@ -1014,14 +1014,14 @@ static int usb_register_bus(struct usb_bus *bus) ...@@ -1014,14 +1014,14 @@ static int usb_register_bus(struct usb_bus *bus)
int result = -E2BIG; int result = -E2BIG;
int busnum; int busnum;
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
busnum = idr_alloc(&usb_bus_idr, bus, 1, USB_MAXBUS, GFP_KERNEL); busnum = idr_alloc(&usb_bus_idr, bus, 1, USB_MAXBUS, GFP_KERNEL);
if (busnum < 0) { if (busnum < 0) {
pr_err("%s: failed to get bus number\n", usbcore_name); pr_err("%s: failed to get bus number\n", usbcore_name);
goto error_find_busnum; goto error_find_busnum;
} }
bus->busnum = busnum; bus->busnum = busnum;
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
usb_notify_add_bus(bus); usb_notify_add_bus(bus);
...@@ -1030,7 +1030,7 @@ static int usb_register_bus(struct usb_bus *bus) ...@@ -1030,7 +1030,7 @@ static int usb_register_bus(struct usb_bus *bus)
return 0; return 0;
error_find_busnum: error_find_busnum:
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
return result; return result;
} }
...@@ -1051,9 +1051,9 @@ static void usb_deregister_bus (struct usb_bus *bus) ...@@ -1051,9 +1051,9 @@ static void usb_deregister_bus (struct usb_bus *bus)
* controller code, as well as having it call this when cleaning * controller code, as well as having it call this when cleaning
* itself up * itself up
*/ */
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
idr_remove(&usb_bus_idr, bus->busnum); idr_remove(&usb_bus_idr, bus->busnum);
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
usb_notify_remove_bus(bus); usb_notify_remove_bus(bus);
} }
...@@ -1083,12 +1083,12 @@ static int register_root_hub(struct usb_hcd *hcd) ...@@ -1083,12 +1083,12 @@ static int register_root_hub(struct usb_hcd *hcd)
set_bit (devnum, usb_dev->bus->devmap.devicemap); set_bit (devnum, usb_dev->bus->devmap.devicemap);
usb_set_device_state(usb_dev, USB_STATE_ADDRESS); usb_set_device_state(usb_dev, USB_STATE_ADDRESS);
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
usb_dev->ep0.desc.wMaxPacketSize = cpu_to_le16(64); usb_dev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE); retval = usb_get_device_descriptor(usb_dev, USB_DT_DEVICE_SIZE);
if (retval != sizeof usb_dev->descriptor) { if (retval != sizeof usb_dev->descriptor) {
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
dev_dbg (parent_dev, "can't read %s device descriptor %d\n", dev_dbg (parent_dev, "can't read %s device descriptor %d\n",
dev_name(&usb_dev->dev), retval); dev_name(&usb_dev->dev), retval);
return (retval < 0) ? retval : -EMSGSIZE; return (retval < 0) ? retval : -EMSGSIZE;
...@@ -1099,7 +1099,7 @@ static int register_root_hub(struct usb_hcd *hcd) ...@@ -1099,7 +1099,7 @@ static int register_root_hub(struct usb_hcd *hcd)
if (!retval) { if (!retval) {
usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev); usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev);
} else if (usb_dev->speed >= USB_SPEED_SUPER) { } else if (usb_dev->speed >= USB_SPEED_SUPER) {
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
dev_dbg(parent_dev, "can't read %s bos descriptor %d\n", dev_dbg(parent_dev, "can't read %s bos descriptor %d\n",
dev_name(&usb_dev->dev), retval); dev_name(&usb_dev->dev), retval);
return retval; return retval;
...@@ -1119,7 +1119,7 @@ static int register_root_hub(struct usb_hcd *hcd) ...@@ -1119,7 +1119,7 @@ static int register_root_hub(struct usb_hcd *hcd)
if (HCD_DEAD(hcd)) if (HCD_DEAD(hcd))
usb_hc_died (hcd); /* This time clean up */ usb_hc_died (hcd); /* This time clean up */
} }
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
return retval; return retval;
} }
...@@ -2885,9 +2885,9 @@ int usb_add_hcd(struct usb_hcd *hcd, ...@@ -2885,9 +2885,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
#ifdef CONFIG_PM #ifdef CONFIG_PM
cancel_work_sync(&hcd->wakeup_work); cancel_work_sync(&hcd->wakeup_work);
#endif #endif
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
usb_disconnect(&rhdev); /* Sets rhdev to NULL */ usb_disconnect(&rhdev); /* Sets rhdev to NULL */
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
err_register_root_hub: err_register_root_hub:
hcd->rh_pollable = 0; hcd->rh_pollable = 0;
clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
...@@ -2954,9 +2954,9 @@ void usb_remove_hcd(struct usb_hcd *hcd) ...@@ -2954,9 +2954,9 @@ void usb_remove_hcd(struct usb_hcd *hcd)
cancel_work_sync(&hcd->wakeup_work); cancel_work_sync(&hcd->wakeup_work);
#endif #endif
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
usb_disconnect(&rhdev); /* Sets rhdev to NULL */ usb_disconnect(&rhdev); /* Sets rhdev to NULL */
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
/* /*
* tasklet_kill() isn't needed here because: * tasklet_kill() isn't needed here because:
......
...@@ -2145,7 +2145,7 @@ static void hub_disconnect_children(struct usb_device *udev) ...@@ -2145,7 +2145,7 @@ static void hub_disconnect_children(struct usb_device *udev)
* Something got disconnected. Get rid of it and all of its children. * Something got disconnected. Get rid of it and all of its children.
* *
* If *pdev is a normal device then the parent hub must already be locked. * If *pdev is a normal device then the parent hub must already be locked.
* If *pdev is a root hub then the caller must hold the usb_bus_list_lock, * If *pdev is a root hub then the caller must hold the usb_bus_idr_lock,
* which protects the set of root hubs as well as the list of buses. * which protects the set of root hubs as well as the list of buses.
* *
* Only hub drivers (including virtual root hub drivers for host * Only hub drivers (including virtual root hub drivers for host
...@@ -2443,7 +2443,7 @@ static void set_usb_port_removable(struct usb_device *udev) ...@@ -2443,7 +2443,7 @@ static void set_usb_port_removable(struct usb_device *udev)
* enumerated. The device descriptor is available, but not descriptors * enumerated. The device descriptor is available, but not descriptors
* for any device configuration. The caller must have locked either * for any device configuration. The caller must have locked either
* the parent hub (if udev is a normal device) or else the * the parent hub (if udev is a normal device) or else the
* usb_bus_list_lock (if udev is a root hub). The parent's pointer to * usb_bus_idr_lock (if udev is a root hub). The parent's pointer to
* udev has already been installed, but udev is not yet visible through * udev has already been installed, but udev is not yet visible through
* sysfs or other filesystem code. * sysfs or other filesystem code.
* *
......
...@@ -365,11 +365,11 @@ static int __init mon_init(void) ...@@ -365,11 +365,11 @@ static int __init mon_init(void)
} }
// MOD_INC_USE_COUNT(which_module?); // MOD_INC_USE_COUNT(which_module?);
mutex_lock(&usb_bus_list_lock); mutex_lock(&usb_bus_idr_lock);
idr_for_each_entry(&usb_bus_idr, ubus, id) idr_for_each_entry(&usb_bus_idr, ubus, id)
mon_bus_init(ubus); mon_bus_init(ubus);
usb_register_notify(&mon_nb); usb_register_notify(&mon_nb);
mutex_unlock(&usb_bus_list_lock); mutex_unlock(&usb_bus_idr_lock);
return 0; return 0;
err_reg: err_reg:
......
...@@ -632,7 +632,7 @@ extern void usb_set_device_state(struct usb_device *udev, ...@@ -632,7 +632,7 @@ extern void usb_set_device_state(struct usb_device *udev,
/* exported only within usbcore */ /* exported only within usbcore */
extern struct idr usb_bus_idr; extern struct idr usb_bus_idr;
extern struct mutex usb_bus_list_lock; extern struct mutex usb_bus_idr_lock;
extern wait_queue_head_t usb_kill_urb_queue; extern wait_queue_head_t usb_kill_urb_queue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment