Needed on the Mele A210, as usbc1 is always on. Without this fix,
the kernel segfaults.

Signed-off-by: Luc Verhaegen <l...@skynet.be>
---
 drivers/usb/host/sw_hci_sunxi.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/sw_hci_sunxi.c b/drivers/usb/host/sw_hci_sunxi.c
index 5dc4103..a9b1948 100644
--- a/drivers/usb/host/sw_hci_sunxi.c
+++ b/drivers/usb/host/sw_hci_sunxi.c
@@ -455,6 +455,9 @@ static void __sw_set_vbus(struct sw_hci_hcd *sw_hci, int 
is_on)
        DMSG_INFO("[%s]: Set USB Power %s\n", sw_hci->hci_name,
                  (is_on ? "ON" : "OFF"));
 
+       if (!sw_hci->drv_vbus_Handle)
+               return;
+
        /* set power flag */
        sw_hci->power_flag = is_on;
 
@@ -811,12 +814,15 @@ static int init_sw_hci(struct sw_hci_hcd *sw_hci, u32 
usbc_no, u32 ohci,
 
        get_usb_cfg(sw_hci);
 
-       drv_vbus_Handle = alloc_pin(&sw_hci->drv_vbus_gpio_set);
-       if (drv_vbus_Handle == 0) {
-               DMSG_PANIC("ERR: alloc_pin failed\n");
-               goto failed1;
-       }
-       sw_hci->drv_vbus_Handle = drv_vbus_Handle;
+       if (sw_hci->drv_vbus_gpio_set.port) {
+               drv_vbus_Handle = alloc_pin(&sw_hci->drv_vbus_gpio_set);
+               if (drv_vbus_Handle == 0) {
+                       DMSG_PANIC("ERR: alloc_pin failed\n");
+                       goto failed1;
+               }
+               sw_hci->drv_vbus_Handle = drv_vbus_Handle;
+       } else
+               sw_hci->drv_vbus_Handle = 0;
 
        sw_hci->open_clock = open_clock;
        sw_hci->close_clock = close_clock;
@@ -891,7 +897,8 @@ static void __exit sw_hci_sunxi_exit(void)
                clock_exit(&sw_ehci1, 0);
                clock_exit(&sw_ohci1, 1);
 
-               free_pin(sw_ehci1.drv_vbus_Handle);
+               if (sw_ehci1.drv_vbus_Handle)
+                       free_pin(sw_ehci1.drv_vbus_Handle);
        }
 
        if (sw_ehci2.used) {
@@ -901,7 +908,8 @@ static void __exit sw_hci_sunxi_exit(void)
                clock_exit(&sw_ehci2, 0);
                clock_exit(&sw_ohci2, 1);
 
-               free_pin(sw_ehci2.drv_vbus_Handle);
+               if (sw_ehci2.drv_vbus_Handle)
+                       free_pin(sw_ehci2.drv_vbus_Handle);
        }
 
        return;
-- 
1.7.7

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to