usb: dwc3: fix NULL pointer issue

The phy_bulk pointer *usb_phys is used before allocated,
fix it by using a phy_bulk variable instead in
xhci_dwc3_platdata struct

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
This commit is contained in:
Chunfeng Yun 2020-05-14 13:55:11 +08:00 committed by Marek Vasut
parent 94ed66194f
commit 58221d7e87

View File

@ -21,7 +21,7 @@
#include <linux/usb/otg.h> #include <linux/usb/otg.h>
struct xhci_dwc3_platdata { struct xhci_dwc3_platdata {
struct phy_bulk *usb_phys; struct phy_bulk phys;
}; };
void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode) void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode)
@ -126,7 +126,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
hcor = (struct xhci_hcor *)((uintptr_t)hccr + hcor = (struct xhci_hcor *)((uintptr_t)hccr +
HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
ret = dwc3_setup_phy(dev, plat->usb_phys); ret = dwc3_setup_phy(dev, &plat->phys);
if (ret && (ret != -ENOTSUPP)) if (ret && (ret != -ENOTSUPP))
return ret; return ret;
@ -169,7 +169,7 @@ static int xhci_dwc3_remove(struct udevice *dev)
{ {
struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
dwc3_shutdown_phy(dev, plat->usb_phys); dwc3_shutdown_phy(dev, &plat->phys);
return xhci_deregister(dev); return xhci_deregister(dev);
} }