diff options
author | Petr Mladek <pmladek@suse.cz> | 2014-09-19 11:32:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-09-24 01:31:11 -0400 |
commit | 5d14f323834eeb0cd428bcec4a9cd8d8839467fb (patch) | |
tree | 3ba33ad527e7d931635594a7b6727e4888415bc2 /drivers/usb | |
parent | 3512e7bfea6a459cad84712a021d856bd78cd7e4 (diff) |
usb: hub: keep hub->dev reference all the time when struct usb_hub lives
This is just a small optimization of the fix from the commit c605f3cdff53a743f6
("usb: hub: take hub->hdev reference when processing from eventlist).
We do not need to take the reference for each event. Instead we could get it
when struct usb_hub is allocated and put it when it is released. By other words,
we could handle it the same way as the reference for hub->intfdev.
The motivation is that it will make the life easier when switching from khubd
kthread to a workqueue.
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Petr Mladek <pmladek@suse.cz>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/hub.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d5419292f89f..6a9f11fbc2eb 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -1635,6 +1635,7 @@ static void hub_release(struct kref *kref) | |||
1635 | { | 1635 | { |
1636 | struct usb_hub *hub = container_of(kref, struct usb_hub, kref); | 1636 | struct usb_hub *hub = container_of(kref, struct usb_hub, kref); |
1637 | 1637 | ||
1638 | usb_put_dev(hub->hdev); | ||
1638 | usb_put_intf(to_usb_interface(hub->intfdev)); | 1639 | usb_put_intf(to_usb_interface(hub->intfdev)); |
1639 | kfree(hub); | 1640 | kfree(hub); |
1640 | } | 1641 | } |
@@ -1800,6 +1801,7 @@ descriptor_error: | |||
1800 | INIT_DELAYED_WORK(&hub->leds, led_work); | 1801 | INIT_DELAYED_WORK(&hub->leds, led_work); |
1801 | INIT_DELAYED_WORK(&hub->init_work, NULL); | 1802 | INIT_DELAYED_WORK(&hub->init_work, NULL); |
1802 | usb_get_intf(intf); | 1803 | usb_get_intf(intf); |
1804 | usb_get_dev(hdev); | ||
1803 | 1805 | ||
1804 | usb_set_intfdata (intf, hub); | 1806 | usb_set_intfdata (intf, hub); |
1805 | intf->needs_remote_wakeup = 1; | 1807 | intf->needs_remote_wakeup = 1; |
@@ -5026,10 +5028,9 @@ static void hub_events(void) | |||
5026 | 5028 | ||
5027 | hub = list_entry(tmp, struct usb_hub, event_list); | 5029 | hub = list_entry(tmp, struct usb_hub, event_list); |
5028 | kref_get(&hub->kref); | 5030 | kref_get(&hub->kref); |
5029 | hdev = hub->hdev; | ||
5030 | usb_get_dev(hdev); | ||
5031 | spin_unlock_irq(&hub_event_lock); | 5031 | spin_unlock_irq(&hub_event_lock); |
5032 | 5032 | ||
5033 | hdev = hub->hdev; | ||
5033 | hub_dev = hub->intfdev; | 5034 | hub_dev = hub->intfdev; |
5034 | intf = to_usb_interface(hub_dev); | 5035 | intf = to_usb_interface(hub_dev); |
5035 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", | 5036 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", |
@@ -5142,7 +5143,6 @@ static void hub_events(void) | |||
5142 | usb_autopm_put_interface(intf); | 5143 | usb_autopm_put_interface(intf); |
5143 | loop_disconnected: | 5144 | loop_disconnected: |
5144 | usb_unlock_device(hdev); | 5145 | usb_unlock_device(hdev); |
5145 | usb_put_dev(hdev); | ||
5146 | kref_put(&hub->kref, hub_release); | 5146 | kref_put(&hub->kref, hub_release); |
5147 | 5147 | ||
5148 | } /* end while (1) */ | 5148 | } /* end while (1) */ |