diff mbox series

[3/6] usb: chipidea: Check usb_phy exists before using it

Message ID 1629825378-8089-4-git-send-email-manish.narani@xilinx.com
State New
Headers show
Series Chipidea USB driver Enhancements and Bug Fixes | expand

Commit Message

Manish Narani Aug. 24, 2021, 5:16 p.m. UTC
usb_phy and usb_phy->set_vbus may not be present all the times
based on PHY driver used. So check for it.

Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Manish Narani <manish.narani@xilinx.com>
---
 drivers/usb/chipidea/otg_fsm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Peter Chen Oct. 7, 2021, 4:54 a.m. UTC | #1
On 21-08-24 22:46:15, Manish Narani wrote:
> usb_phy and usb_phy->set_vbus may not be present all the times

> based on PHY driver used. So check for it.


Please squash this one with the first one.

Peter
> 

> Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com>

> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

> Signed-off-by: Manish Narani <manish.narani@xilinx.com>

> ---

>  drivers/usb/chipidea/otg_fsm.c | 6 ++++--

>  1 file changed, 4 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c

> index 2f7f94d..5f8f5d2 100644

> --- a/drivers/usb/chipidea/otg_fsm.c

> +++ b/drivers/usb/chipidea/otg_fsm.c

> @@ -472,7 +472,8 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)

>  			}

>  		}

>  

> -		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)

> +		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL &&

> +		    ci->usb_phy && ci->usb_phy->set_vbus)

>  			ci->usb_phy->set_vbus(ci->usb_phy, 1);

>  

>  		/* Disable data pulse irq */

> @@ -484,7 +485,8 @@ static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)

>  		if (ci->platdata->reg_vbus)

>  			regulator_disable(ci->platdata->reg_vbus);

>  

> -		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)

> +		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL &&

> +		    ci->usb_phy && ci->usb_phy->set_vbus)

>  			ci->usb_phy->set_vbus(ci->usb_phy, 0);

>  

>  		fsm->a_bus_drop = 1;

> -- 

> 2.1.1

> 


-- 

Thanks,
Peter Chen
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 2f7f94d..5f8f5d2 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -472,7 +472,8 @@  static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
 			}
 		}
 
-		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
+		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL &&
+		    ci->usb_phy && ci->usb_phy->set_vbus)
 			ci->usb_phy->set_vbus(ci->usb_phy, 1);
 
 		/* Disable data pulse irq */
@@ -484,7 +485,8 @@  static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
 		if (ci->platdata->reg_vbus)
 			regulator_disable(ci->platdata->reg_vbus);
 
-		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL)
+		if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL &&
+		    ci->usb_phy && ci->usb_phy->set_vbus)
 			ci->usb_phy->set_vbus(ci->usb_phy, 0);
 
 		fsm->a_bus_drop = 1;