From d56fb5f89b1501dd7922c1c6d3c97f963df7a4af Mon Sep 17 00:00:00 2001 From: Christoph Muellner Date: Fri, 14 Jun 2019 14:39:02 +0200 Subject: usb: dwc_otg_310: Prevent phy access if not probed. In case the PHY is not successfully probed, we cannot access PHY functions like usb20otg_hw_init(), because they assume successful probing and might dereference NULL pointers otherwise. This patch addresses this by introducing a flag 'is_probed', which can be checked during controller probing time to verify, that the PHY has been probed. If this was not the case, controller probing will be deferred. Signed-off-by: Christoph Muellner --- drivers/usb/dwc_otg_310/usbdev_rk3368.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/usb/dwc_otg_310/usbdev_rk3368.c') diff --git a/drivers/usb/dwc_otg_310/usbdev_rk3368.c b/drivers/usb/dwc_otg_310/usbdev_rk3368.c index 65739aa3b7e3..789898d00a4f 100644 --- a/drivers/usb/dwc_otg_310/usbdev_rk3368.c +++ b/drivers/usb/dwc_otg_310/usbdev_rk3368.c @@ -5,6 +5,13 @@ static struct dwc_otg_control_usb *control_usb; +static int usb20_is_probed(void) +{ + if (!control_usb) + return 0; + return control_usb->is_probed; +} + static u32 uoc_read(u32 reg) { unsigned int val; @@ -216,6 +223,7 @@ struct dwc_otg_platform_data usb20otg_pdata_rk3368 = { .power_enable = usb20otg_power_enable, .dwc_otg_uart_mode = dwc_otg_uart_mode, .bc_detect_cb = rk_battery_charger_detect_cb, + .is_probed = usb20_is_probed, }; #endif @@ -498,6 +506,8 @@ static int dwc_otg_control_usb_probe(struct platform_device *pdev) if (ret < 0) goto err; + control_usb->is_probed = 1; + return 0; err: -- cgit v1.2.3