usb: musb: mediatek: don't unregister something that wasn't registered
authorDan Carpenter <error27@gmail.com>
Tue, 24 Jan 2023 15:20:46 +0000 (18:20 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Feb 2023 10:12:02 +0000 (11:12 +0100)
This function only calls mtk_otg_switch_init() when the ->port_mode
is MUSB_OTG so the clean up code should only call mtk_otg_switch_exit()
for that mode.

Fixes: 0990366bab3c ("usb: musb: Add support for MediaTek musb controller")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/Y8/3TqpqiSr0RxFH@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/mediatek.c

index cad9913..27b9bd2 100644 (file)
@@ -294,7 +294,8 @@ static int mtk_musb_init(struct musb *musb)
 err_phy_power_on:
        phy_exit(glue->phy);
 err_phy_init:
-       mtk_otg_switch_exit(glue);
+       if (musb->port_mode == MUSB_OTG)
+               mtk_otg_switch_exit(glue);
        return ret;
 }