USB: core: Add hub_get() and hub_put() routines
commit ee113b860aa169e9a4d2c167c95d0f1961c6e1b8 upstream. Create hub_get() and hub_put() routines to encapsulate the kref_get() and kref_put() calls in hub.c. The new routines will be used by the next patch in this series. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/604da420-ae8a-4a9e-91a4-2d511ff404fb@rowland.harvard.edu Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
6f4953255b
commit
8e047bc5a5
@@ -116,7 +116,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
|
|||||||
#define HUB_DEBOUNCE_STEP 25
|
#define HUB_DEBOUNCE_STEP 25
|
||||||
#define HUB_DEBOUNCE_STABLE 100
|
#define HUB_DEBOUNCE_STABLE 100
|
||||||
|
|
||||||
static void hub_release(struct kref *kref);
|
|
||||||
static int usb_reset_and_verify_device(struct usb_device *udev);
|
static int usb_reset_and_verify_device(struct usb_device *udev);
|
||||||
static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
|
static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
|
||||||
static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
|
static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
|
||||||
@@ -678,14 +677,14 @@ static void kick_hub_wq(struct usb_hub *hub)
|
|||||||
*/
|
*/
|
||||||
intf = to_usb_interface(hub->intfdev);
|
intf = to_usb_interface(hub->intfdev);
|
||||||
usb_autopm_get_interface_no_resume(intf);
|
usb_autopm_get_interface_no_resume(intf);
|
||||||
kref_get(&hub->kref);
|
hub_get(hub);
|
||||||
|
|
||||||
if (queue_work(hub_wq, &hub->events))
|
if (queue_work(hub_wq, &hub->events))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* the work has already been scheduled */
|
/* the work has already been scheduled */
|
||||||
usb_autopm_put_interface_async(intf);
|
usb_autopm_put_interface_async(intf);
|
||||||
kref_put(&hub->kref, hub_release);
|
hub_put(hub);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_kick_hub_wq(struct usb_device *hdev)
|
void usb_kick_hub_wq(struct usb_device *hdev)
|
||||||
@@ -1053,7 +1052,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||||||
goto init2;
|
goto init2;
|
||||||
goto init3;
|
goto init3;
|
||||||
}
|
}
|
||||||
kref_get(&hub->kref);
|
hub_get(hub);
|
||||||
|
|
||||||
/* The superspeed hub except for root hub has to use Hub Depth
|
/* The superspeed hub except for root hub has to use Hub Depth
|
||||||
* value as an offset into the route string to locate the bits
|
* value as an offset into the route string to locate the bits
|
||||||
@@ -1301,7 +1300,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
|
|||||||
device_unlock(&hdev->dev);
|
device_unlock(&hdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
kref_put(&hub->kref, hub_release);
|
hub_put(hub);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implement the continuations for the delays above */
|
/* Implement the continuations for the delays above */
|
||||||
@@ -1717,6 +1716,16 @@ static void hub_release(struct kref *kref)
|
|||||||
kfree(hub);
|
kfree(hub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hub_get(struct usb_hub *hub)
|
||||||
|
{
|
||||||
|
kref_get(&hub->kref);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hub_put(struct usb_hub *hub)
|
||||||
|
{
|
||||||
|
kref_put(&hub->kref, hub_release);
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned highspeed_hubs;
|
static unsigned highspeed_hubs;
|
||||||
|
|
||||||
static void hub_disconnect(struct usb_interface *intf)
|
static void hub_disconnect(struct usb_interface *intf)
|
||||||
@@ -1763,7 +1772,7 @@ static void hub_disconnect(struct usb_interface *intf)
|
|||||||
if (hub->quirk_disable_autosuspend)
|
if (hub->quirk_disable_autosuspend)
|
||||||
usb_autopm_put_interface(intf);
|
usb_autopm_put_interface(intf);
|
||||||
|
|
||||||
kref_put(&hub->kref, hub_release);
|
hub_put(hub);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hub_descriptor_is_sane(struct usb_host_interface *desc)
|
static bool hub_descriptor_is_sane(struct usb_host_interface *desc)
|
||||||
@@ -5857,7 +5866,7 @@ out_hdev_lock:
|
|||||||
|
|
||||||
/* Balance the stuff in kick_hub_wq() and allow autosuspend */
|
/* Balance the stuff in kick_hub_wq() and allow autosuspend */
|
||||||
usb_autopm_put_interface(intf);
|
usb_autopm_put_interface(intf);
|
||||||
kref_put(&hub->kref, hub_release);
|
hub_put(hub);
|
||||||
|
|
||||||
kcov_remote_stop();
|
kcov_remote_stop();
|
||||||
}
|
}
|
||||||
|
@@ -117,6 +117,8 @@ extern void usb_hub_remove_port_device(struct usb_hub *hub,
|
|||||||
extern int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub,
|
extern int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub,
|
||||||
int port1, bool set);
|
int port1, bool set);
|
||||||
extern struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev);
|
extern struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev);
|
||||||
|
extern void hub_get(struct usb_hub *hub);
|
||||||
|
extern void hub_put(struct usb_hub *hub);
|
||||||
extern int hub_port_debounce(struct usb_hub *hub, int port1,
|
extern int hub_port_debounce(struct usb_hub *hub, int port1,
|
||||||
bool must_be_connected);
|
bool must_be_connected);
|
||||||
extern int usb_clear_port_feature(struct usb_device *hdev,
|
extern int usb_clear_port_feature(struct usb_device *hdev,
|
||||||
|
Reference in New Issue
Block a user