diff mbox series

[v2,09/15] usb: dwc2: Move exit hibernation to dwc2_port_resume() function

Message ID 20210416124755.E47F3A005D@mailhost.synopsys.com
State New
Headers show
Series None | expand

Commit Message

Artur Petrosyan April 16, 2021, 12:47 p.m. UTC
This move is done to call hibernation exit handler in
"dwc2_port_resume()" function when core receives port resume.
Otherwise it could be confusing to exit hibernation in
"dwc2_hcd_hub_control()" function but other power saving modes
in "dwc2_port_resume()" function.

Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>
---
 Changes in v2:
 - None

 drivers/usb/dwc2/hcd.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Minas Harutyunyan April 19, 2021, 7:31 a.m. UTC | #1
On 4/16/2021 4:47 PM, Artur Petrosyan wrote:
> This move is done to call hibernation exit handler in

> "dwc2_port_resume()" function when core receives port resume.

> Otherwise it could be confusing to exit hibernation in

> "dwc2_hcd_hub_control()" function but other power saving modes

> in "dwc2_port_resume()" function.

> 

> Signed-off-by: Artur Petrosyan <Arthur.Petrosyan@synopsys.com>


Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>


> ---

>   Changes in v2:

>   - None

> 

>   drivers/usb/dwc2/hcd.c | 13 +++++++------

>   1 file changed, 7 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c

> index 43a2298b7d42..cc9ad6cf02d9 100644

> --- a/drivers/usb/dwc2/hcd.c

> +++ b/drivers/usb/dwc2/hcd.c

> @@ -3383,6 +3383,11 @@ int dwc2_port_resume(struct dwc2_hsotg *hsotg)

>   				"exit partial_power_down failed.\n");

>   		break;

>   	case DWC2_POWER_DOWN_PARAM_HIBERNATION:

> +		/* Exit host hibernation. */

> +		ret = dwc2_exit_hibernation(hsotg, 0, 0, 1);

> +		if (ret)

> +			dev_err(hsotg->dev, "exit hibernation failed.\n");

> +		break;

>   	case DWC2_POWER_DOWN_PARAM_NONE:

>   		/*

>   		 * If not hibernation nor partial power down are supported,

> @@ -3446,12 +3451,8 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,

>   			dev_dbg(hsotg->dev,

>   				"ClearPortFeature USB_PORT_FEAT_SUSPEND\n");

>   

> -			if (hsotg->bus_suspended) {

> -				if (hsotg->hibernated)

> -					dwc2_exit_hibernation(hsotg, 0, 0, 1);

> -				else

> -					dwc2_port_resume(hsotg);

> -			}

> +			if (hsotg->bus_suspended)

> +				retval = dwc2_port_resume(hsotg);

>   			break;

>   

>   		case USB_PORT_FEAT_POWER:

>
diff mbox series

Patch

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 43a2298b7d42..cc9ad6cf02d9 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -3383,6 +3383,11 @@  int dwc2_port_resume(struct dwc2_hsotg *hsotg)
 				"exit partial_power_down failed.\n");
 		break;
 	case DWC2_POWER_DOWN_PARAM_HIBERNATION:
+		/* Exit host hibernation. */
+		ret = dwc2_exit_hibernation(hsotg, 0, 0, 1);
+		if (ret)
+			dev_err(hsotg->dev, "exit hibernation failed.\n");
+		break;
 	case DWC2_POWER_DOWN_PARAM_NONE:
 		/*
 		 * If not hibernation nor partial power down are supported,
@@ -3446,12 +3451,8 @@  static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq,
 			dev_dbg(hsotg->dev,
 				"ClearPortFeature USB_PORT_FEAT_SUSPEND\n");
 
-			if (hsotg->bus_suspended) {
-				if (hsotg->hibernated)
-					dwc2_exit_hibernation(hsotg, 0, 0, 1);
-				else
-					dwc2_port_resume(hsotg);
-			}
+			if (hsotg->bus_suspended)
+				retval = dwc2_port_resume(hsotg);
 			break;
 
 		case USB_PORT_FEAT_POWER: