Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit ee113b8

Browse files
AlanSterngregkh
authored andcommitted
USB: core: Add hub_get() and hub_put() routines
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>
1 parent 0be3870 commit ee113b8

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

drivers/usb/core/hub.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem);
130130
#define HUB_DEBOUNCE_STEP 25
131131
#define HUB_DEBOUNCE_STABLE 100
132132

133-
static void hub_release(struct kref *kref);
134133
static int usb_reset_and_verify_device(struct usb_device *udev);
135134
static int hub_port_disable(struct usb_hub *hub, int port1, int set_state);
136135
static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
@@ -720,14 +719,14 @@ static void kick_hub_wq(struct usb_hub *hub)
720719
*/
721720
intf = to_usb_interface(hub->intfdev);
722721
usb_autopm_get_interface_no_resume(intf);
723-
kref_get(&hub->kref);
722+
hub_get(hub);
724723

725724
if (queue_work(hub_wq, &hub->events))
726725
return;
727726

728727
/* the work has already been scheduled */
729728
usb_autopm_put_interface_async(intf);
730-
kref_put(&hub->kref, hub_release);
729+
hub_put(hub);
731730
}
732731

733732
void usb_kick_hub_wq(struct usb_device *hdev)
@@ -1095,7 +1094,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
10951094
goto init2;
10961095
goto init3;
10971096
}
1098-
kref_get(&hub->kref);
1097+
hub_get(hub);
10991098

11001099
/* The superspeed hub except for root hub has to use Hub Depth
11011100
* value as an offset into the route string to locate the bits
@@ -1343,7 +1342,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
13431342
device_unlock(&hdev->dev);
13441343
}
13451344

1346-
kref_put(&hub->kref, hub_release);
1345+
hub_put(hub);
13471346
}
13481347

13491348
/* Implement the continuations for the delays above */
@@ -1759,6 +1758,16 @@ static void hub_release(struct kref *kref)
17591758
kfree(hub);
17601759
}
17611760

1761+
void hub_get(struct usb_hub *hub)
1762+
{
1763+
kref_get(&hub->kref);
1764+
}
1765+
1766+
void hub_put(struct usb_hub *hub)
1767+
{
1768+
kref_put(&hub->kref, hub_release);
1769+
}
1770+
17621771
static unsigned highspeed_hubs;
17631772

17641773
static void hub_disconnect(struct usb_interface *intf)
@@ -1807,7 +1816,7 @@ static void hub_disconnect(struct usb_interface *intf)
18071816

18081817
onboard_hub_destroy_pdevs(&hub->onboard_hub_devs);
18091818

1810-
kref_put(&hub->kref, hub_release);
1819+
hub_put(hub);
18111820
}
18121821

18131822
static bool hub_descriptor_is_sane(struct usb_host_interface *desc)
@@ -5934,7 +5943,7 @@ static void hub_event(struct work_struct *work)
59345943

59355944
/* Balance the stuff in kick_hub_wq() and allow autosuspend */
59365945
usb_autopm_put_interface(intf);
5937-
kref_put(&hub->kref, hub_release);
5946+
hub_put(hub);
59385947

59395948
kcov_remote_stop();
59405949
}

drivers/usb/core/hub.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ extern void usb_hub_remove_port_device(struct usb_hub *hub,
129129
extern int usb_hub_set_port_power(struct usb_device *hdev, struct usb_hub *hub,
130130
int port1, bool set);
131131
extern struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev);
132+
extern void hub_get(struct usb_hub *hub);
133+
extern void hub_put(struct usb_hub *hub);
132134
extern int hub_port_debounce(struct usb_hub *hub, int port1,
133135
bool must_be_connected);
134136
extern int usb_clear_port_feature(struct usb_device *hdev,

0 commit comments

Comments
 (0)