diff mbox series

[v2,7/9] usb: cdns3: core: removed 'goto not_otg'

Message ID 20200713100554.28530-8-pawell@cadence.com (mailing list archive)
State Mainlined
Commit 5c2cf30f14cc3973f2d288e33b0153f5d9a357fb
Headers show
Series usb: cdns3: Improvements for cdns3 DRD code | expand

Commit Message

Pawel Laszczak July 13, 2020, 10:05 a.m. UTC
Patch removes 'goto not_otg' instruction from
cdns3_hw_role_state_machine function.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/core.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Comments

Peter Chen July 22, 2020, 2:41 a.m. UTC | #1
On 20-07-13 12:05:52, Pawel Laszczak wrote:
> Patch removes 'goto not_otg' instruction from
> cdns3_hw_role_state_machine function.
> 
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
>  drivers/usb/cdns3/core.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> index c498b585eb13..8e3996f211a8 100644
> --- a/drivers/usb/cdns3/core.c
> +++ b/drivers/usb/cdns3/core.c
> @@ -191,11 +191,17 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
>   */
>  static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
>  {
> -	enum usb_role role;
> +	enum usb_role role = USB_ROLE_NONE;
>  	int id, vbus;
>  
> -	if (cdns->dr_mode != USB_DR_MODE_OTG)
> -		goto not_otg;
> +	if (cdns->dr_mode != USB_DR_MODE_OTG) {
> +		if (cdns3_is_host(cdns))
> +			role = USB_ROLE_HOST;
> +		if (cdns3_is_device(cdns))
> +			role = USB_ROLE_DEVICE;
> +
> +		return role;
> +	}

Would you please improve it a bit like below:

	if (cdns->dr_mode != USB_DR_MODE_OTG) {
		if (cdns3_is_host(cdns))
			role = USB_ROLE_HOST;
		else if (cdns3_is_device(cdns))
			role = USB_ROLE_DEVICE;
		else
			role = USB_ROLE_NONE;

		return role;
	}

Peter
>  
>  	id = cdns3_get_id(cdns);
>  	vbus = cdns3_get_vbus(cdns);
> @@ -232,14 +238,6 @@ static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
>  	dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role);
>  
>  	return role;
> -
> -not_otg:
> -	if (cdns3_is_host(cdns))
> -		role = USB_ROLE_HOST;
> -	if (cdns3_is_device(cdns))
> -		role = USB_ROLE_DEVICE;
> -
> -	return role;
>  }
>  
>  static int cdns3_idle_role_start(struct cdns3 *cdns)
> -- 
> 2.17.1
>
Pawel Laszczak Aug. 3, 2020, 4:27 a.m. UTC | #2
>
>On 20-07-13 12:05:52, Pawel Laszczak wrote:
>> Patch removes 'goto not_otg' instruction from
>> cdns3_hw_role_state_machine function.
>>
>> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>> ---
>>  drivers/usb/cdns3/core.c | 20 +++++++++-----------
>>  1 file changed, 9 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
>> index c498b585eb13..8e3996f211a8 100644
>> --- a/drivers/usb/cdns3/core.c
>> +++ b/drivers/usb/cdns3/core.c
>> @@ -191,11 +191,17 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
>>   */
>>  static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
>>  {
>> -	enum usb_role role;
>> +	enum usb_role role = USB_ROLE_NONE;
>>  	int id, vbus;
>>
>> -	if (cdns->dr_mode != USB_DR_MODE_OTG)
>> -		goto not_otg;
>> +	if (cdns->dr_mode != USB_DR_MODE_OTG) {
>> +		if (cdns3_is_host(cdns))
>> +			role = USB_ROLE_HOST;
>> +		if (cdns3_is_device(cdns))
>> +			role = USB_ROLE_DEVICE;
>> +
>> +		return role;
>> +	}
>
>Would you please improve it a bit like below:
>
>	if (cdns->dr_mode != USB_DR_MODE_OTG) {
>		if (cdns3_is_host(cdns))
>			role = USB_ROLE_HOST;
>		else if (cdns3_is_device(cdns))
>			role = USB_ROLE_DEVICE;
>		else
>			role = USB_ROLE_NONE;
>
>		return role;
>	}
>

Sorry for delay, I had holiday. 
Currently this patch was added by Greg to his usb-next branch, so 
I don't want to change anything.  Next time I will add such changes. 

>Peter
>>
>>  	id = cdns3_get_id(cdns);
>>  	vbus = cdns3_get_vbus(cdns);
>> @@ -232,14 +238,6 @@ static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
>>  	dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role);
>>
>>  	return role;
>> -
>> -not_otg:
>> -	if (cdns3_is_host(cdns))
>> -		role = USB_ROLE_HOST;
>> -	if (cdns3_is_device(cdns))
>> -		role = USB_ROLE_DEVICE;
>> -
>> -	return role;
>>  }
>>
>>  static int cdns3_idle_role_start(struct cdns3 *cdns)
>> --
>> 2.17.1
>>
>
>--
>
>Thanks,
>Peter Chen

Thanks,
Pawel
diff mbox series

Patch

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index c498b585eb13..8e3996f211a8 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -191,11 +191,17 @@  static int cdns3_core_init_role(struct cdns3 *cdns)
  */
 static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
 {
-	enum usb_role role;
+	enum usb_role role = USB_ROLE_NONE;
 	int id, vbus;
 
-	if (cdns->dr_mode != USB_DR_MODE_OTG)
-		goto not_otg;
+	if (cdns->dr_mode != USB_DR_MODE_OTG) {
+		if (cdns3_is_host(cdns))
+			role = USB_ROLE_HOST;
+		if (cdns3_is_device(cdns))
+			role = USB_ROLE_DEVICE;
+
+		return role;
+	}
 
 	id = cdns3_get_id(cdns);
 	vbus = cdns3_get_vbus(cdns);
@@ -232,14 +238,6 @@  static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
 	dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role);
 
 	return role;
-
-not_otg:
-	if (cdns3_is_host(cdns))
-		role = USB_ROLE_HOST;
-	if (cdns3_is_device(cdns))
-		role = USB_ROLE_DEVICE;
-
-	return role;
 }
 
 static int cdns3_idle_role_start(struct cdns3 *cdns)