diff options
| author | Valentine Barshak <valentine.barshak@cogentembedded.com> | 2013-12-03 16:42:21 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-08 21:00:51 -0500 |
| commit | 103e127d1f8f985e8a662da6537ebc5e08902ee3 (patch) | |
| tree | a9ae5594b47919a5bb652172abbb61c9e61d66b0 | |
| parent | e5fc70d5ccc3d005bb038c0275ffdf57a34b1496 (diff) | |
usb: hcd: Remove USB phy if needed
This adds remove_phy flag to the HCD structure. If the flag is
set and if hcd->phy is valid, the phy is shutdown and released
whenever usb_add_hcd fails or usb_hcd_remove is called.
This can be used by the HCD drivers to auto-remove
the external USB phy when it is no longer needed.
Signed-off-by: Valentine Barshak <valentine.barshak@cogentembedded.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/usb/core/hcd.c | 14 | ||||
| -rw-r--r-- | include/linux/usb/hcd.h | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 6bffb8c87bc9..7527c8e4ec64 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | 44 | ||
| 45 | #include <linux/usb.h> | 45 | #include <linux/usb.h> |
| 46 | #include <linux/usb/hcd.h> | 46 | #include <linux/usb/hcd.h> |
| 47 | #include <linux/usb/phy.h> | ||
| 47 | 48 | ||
| 48 | #include "usb.h" | 49 | #include "usb.h" |
| 49 | 50 | ||
| @@ -2603,7 +2604,7 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
| 2603 | */ | 2604 | */ |
| 2604 | if ((retval = hcd_buffer_create(hcd)) != 0) { | 2605 | if ((retval = hcd_buffer_create(hcd)) != 0) { |
| 2605 | dev_dbg(hcd->self.controller, "pool alloc failed\n"); | 2606 | dev_dbg(hcd->self.controller, "pool alloc failed\n"); |
| 2606 | return retval; | 2607 | goto err_remove_phy; |
| 2607 | } | 2608 | } |
| 2608 | 2609 | ||
| 2609 | if ((retval = usb_register_bus(&hcd->self)) < 0) | 2610 | if ((retval = usb_register_bus(&hcd->self)) < 0) |
| @@ -2734,6 +2735,12 @@ err_allocate_root_hub: | |||
| 2734 | usb_deregister_bus(&hcd->self); | 2735 | usb_deregister_bus(&hcd->self); |
| 2735 | err_register_bus: | 2736 | err_register_bus: |
| 2736 | hcd_buffer_destroy(hcd); | 2737 | hcd_buffer_destroy(hcd); |
| 2738 | err_remove_phy: | ||
| 2739 | if (hcd->remove_phy && hcd->phy) { | ||
| 2740 | usb_phy_shutdown(hcd->phy); | ||
| 2741 | usb_put_phy(hcd->phy); | ||
| 2742 | hcd->phy = NULL; | ||
| 2743 | } | ||
| 2737 | return retval; | 2744 | return retval; |
| 2738 | } | 2745 | } |
| 2739 | EXPORT_SYMBOL_GPL(usb_add_hcd); | 2746 | EXPORT_SYMBOL_GPL(usb_add_hcd); |
| @@ -2806,6 +2813,11 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
| 2806 | usb_put_dev(hcd->self.root_hub); | 2813 | usb_put_dev(hcd->self.root_hub); |
| 2807 | usb_deregister_bus(&hcd->self); | 2814 | usb_deregister_bus(&hcd->self); |
| 2808 | hcd_buffer_destroy(hcd); | 2815 | hcd_buffer_destroy(hcd); |
| 2816 | if (hcd->remove_phy && hcd->phy) { | ||
| 2817 | usb_phy_shutdown(hcd->phy); | ||
| 2818 | usb_put_phy(hcd->phy); | ||
| 2819 | hcd->phy = NULL; | ||
| 2820 | } | ||
| 2809 | } | 2821 | } |
| 2810 | EXPORT_SYMBOL_GPL(usb_remove_hcd); | 2822 | EXPORT_SYMBOL_GPL(usb_remove_hcd); |
| 2811 | 2823 | ||
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index b8aba196f7f1..758ce80d085f 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
| @@ -134,6 +134,7 @@ struct usb_hcd { | |||
| 134 | unsigned rh_registered:1;/* is root hub registered? */ | 134 | unsigned rh_registered:1;/* is root hub registered? */ |
| 135 | unsigned rh_pollable:1; /* may we poll the root hub? */ | 135 | unsigned rh_pollable:1; /* may we poll the root hub? */ |
| 136 | unsigned msix_enabled:1; /* driver has MSI-X enabled? */ | 136 | unsigned msix_enabled:1; /* driver has MSI-X enabled? */ |
| 137 | unsigned remove_phy:1; /* auto-remove USB phy */ | ||
| 137 | 138 | ||
| 138 | /* The next flag is a stopgap, to be removed when all the HCDs | 139 | /* The next flag is a stopgap, to be removed when all the HCDs |
| 139 | * support the new root-hub polling mechanism. */ | 140 | * support the new root-hub polling mechanism. */ |
