From 4521bf77afa586578a2fe32b387ebd2f94fae522 Mon Sep 17 00:00:00 2001 From: Li Jun Date: Thu, 15 Jan 2015 21:26:05 +0800 Subject: [PATCH] MLK-10102-9 usb: chipidea: host: add ci_hdrc_host_has_device API This patch adds a new API ci_hdrc_host_has_device to check if there is usb device connected on host port. Signed-off-by: Li Jun (cherry picked from commit fd68eb8ef9cdac1ca861ccbc3d01d874123bf52a) --- drivers/usb/chipidea/host.c | 15 +++++++++++++++ drivers/usb/chipidea/host.h | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 2bcbc0227ec7..3c8e09ca75a1 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -199,6 +199,21 @@ static void host_stop(struct ci_hdrc *ci) ci->otg.host = NULL; } +bool ci_hdrc_host_has_device(struct ci_hdrc *ci) +{ + struct usb_device *roothub; + int i; + + if ((ci->role == CI_ROLE_HOST) && ci->hcd) { + roothub = ci->hcd->self.root_hub; + for (i = 0; i < roothub->maxchild; ++i) { + if (usb_hub_find_child(roothub, (i + 1))) + return true; + } + } + return false; +} + static void ci_hdrc_host_save_for_power_lost(struct ci_hdrc *ci) { struct ehci_hcd *ehci; diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h index 0f12f131bdd3..527c9607b2ba 100644 --- a/drivers/usb/chipidea/host.h +++ b/drivers/usb/chipidea/host.h @@ -6,6 +6,7 @@ int ci_hdrc_host_init(struct ci_hdrc *ci); void ci_hdrc_host_destroy(struct ci_hdrc *ci); void ci_hdrc_host_driver_init(void); +bool ci_hdrc_host_has_device(struct ci_hdrc *ci); #else @@ -24,6 +25,11 @@ static void ci_hdrc_host_driver_init(void) } +static inline bool ci_hdrc_host_has_device(struct ci_hdrc *ci) +{ + return false; +} + #endif #endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */ -- 2.17.1