usb: otg: add proxy_wait handler to otg_id
authorErik Gilling <konkers@android.com>
Tue, 9 Aug 2011 21:18:21 +0000 (14:18 -0700)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:22:42 +0000 (12:22 -0800)
Some otg_id handlers can detect what's connected but can't detect a change.
This allows that handler to pass off the waiting for ID change to a proxy.

Change-Id: Ib38b750c3da4bffc35e37b620ecee37c5d64d31f
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/usb/otg/otg_id.c
include/linux/usb/otg_id.h

index 2398b1a..ce22b46 100644 (file)
@@ -44,16 +44,24 @@ static void __otg_id_notify(void)
 {
        int ret;
        struct otg_id_notifier_block *otg_id_nb;
-
+       bool proxy_wait = false;
        if (plist_head_empty(&otg_id_plist))
                return;
 
        plist_for_each_entry(otg_id_nb, &otg_id_plist, p) {
-               ret = otg_id_nb->detect(otg_id_nb);
+               if (proxy_wait) {
+                       if (otg_id_nb->proxy_wait)
+                               ret = otg_id_nb->proxy_wait(otg_id_nb);
+               } else {
+                       ret = otg_id_nb->detect(otg_id_nb);
+               }
                if (ret == OTG_ID_HANDLED) {
                        otg_id_active = otg_id_nb;
                        return;
                }
+               if (ret == OTG_ID_PROXY_WAIT)
+                       proxy_wait = true;
+
        }
 
        WARN(1, "otg id event not handled");
index b686ab0..46a4463 100644 (file)
  *    get called first.
  * @detect: Called during otg_id_notify.  Return OTG_ID_HANDLED if the USB cable
  *    has been identified
+ * @proxy_wait: Called during otg_id_notify if a previous handler returns
+ *    OTG_ID_PROXY_WAIT.  This should wait on ID change then call otg_id_notify.
+ *    This is used when a handler knows what's connected but can't detect
+ *    the change itself.
  * @cancel: Called after detect has returned OTG_ID_HANDLED to ask it to
  *    release detection resources to allow a new identification to occur.
  */
 struct otg_id_notifier_block {
        int priority;
        int (*detect)(struct otg_id_notifier_block *otg_id_nb);
+       int (*proxy_wait)(struct otg_id_notifier_block *otg_id_nb);
        void (*cancel)(struct otg_id_notifier_block *otg_id_nb);
        struct plist_node p;
 };
 
+#define OTG_ID_PROXY_WAIT 2
 #define OTG_ID_HANDLED 1
 #define OTG_ID_UNHANDLED 0