Skip to contentSkip to conversation

usb: typec: tcpm: turn tcpm_ams_finish into void function

PATCH Superseded Yang Li 3 participants 3 messages Mar 8, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 usb: typec: tcpm: turn tcpm_ams_finish into void function

This function always return '0' and no callers use the return value. So make it a void function.

This eliminates the following coccicheck warning:
./drivers/usb/typec/tcpm/tcpm.c:778:5-8: Unneeded variable: "ret". Return "0" on line 794

---
 drivers/usb/typec/tcpm/tcpm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +2 -4
index be0b646..6ee984e 100644
@@ -773,10 +773,8 @@ static enum typec_cc_status tcpm_rp_cc(struct tcpm_port *port)
 	return TYPEC_CC_RP_DEF;
 }
 
-static int tcpm_ams_finish(struct tcpm_port *port)
+static void tcpm_ams_finish(struct tcpm_port *port)
 {
-	int ret = 0;
-
 	tcpm_log(port, "AMS %s finished", tcpm_ams_str[port->ams]);
 
 	if (port->pd_capable && port->pwr_role == TYPEC_SOURCE) {
@@ -791,7 +789,7 @@ static int tcpm_ams_finish(struct tcpm_port *port)
 	port->in_ams = false;
 	port->ams = NONE_AMS;
 
-	return ret;
+	return;
 }
 
 static int tcpm_pd_transmit(struct tcpm_port *port,
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 30 lines · Yang Li

This function always return '0' and no callers use the return value. So make it a void function.

This eliminates the following coccicheck warning:
./drivers/usb/typec/tcpm/tcpm.c:778:5-8: Unneeded variable: "ret". Return "0" on line 794

---
 drivers/usb/typec/tcpm/tcpm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -3
index be0b646..6ee984e 100644
@@ -773,10 +773,8 @@ static enum typec_cc_status tcpm_rp_cc(struct tcpm_port *port)
 	return TYPEC_CC_RP_DEF;
 }
 
-static int tcpm_ams_finish(struct tcpm_port *port)
+static void tcpm_ams_finish(struct tcpm_port *port)
 {
-	int ret = 0;
-
 	tcpm_log(port, "AMS %s finished", tcpm_ams_str[port->ams]);
 
 	if (port->pd_capable && port->pwr_role == TYPEC_SOURCE) {

drivers/usb/typec/tcpm/tcpm.c static int tcpm_ams_finish(struct tcpm_port *port) · line 792

Quoted 5 lines
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -791,7 +789,7 @@ static int tcpm_ams_finish(struct tcpm_port *port)
 	port->in_ams = false;
 	port->ams = NONE_AMS;
 
-	return ret;
+	return;

Unnecessary return statement

Guenter

Quoted 4 lines
drivers/usb/typec/tcpm/tcpm.c +0 -0
 }
 
 static int tcpm_pd_transmit(struct tcpm_port *port,
#2 lore raw
In reply to Yang Li

Hello!

Quoted 1 line · Yang Li

This function always return '0' and no callers use the return value.

Returns.

Quoted 29 lines

So make it a void function.

This eliminates the following coccicheck warning:
./drivers/usb/typec/tcpm/tcpm.c:778:5-8: Unneeded variable: "ret". Return "0" on line 794

---
  drivers/usb/typec/tcpm/tcpm.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +1 -3
index be0b646..6ee984e 100644
@@ -773,10 +773,8 @@ static enum typec_cc_status tcpm_rp_cc(struct tcpm_port *port)
  	return TYPEC_CC_RP_DEF;
  }
 
-static int tcpm_ams_finish(struct tcpm_port *port)
+static void tcpm_ams_finish(struct tcpm_port *port)
  {
-	int ret = 0;
-
  	tcpm_log(port, "AMS %s finished", tcpm_ams_str[port->ams]);
 
  	if (port->pd_capable && port->pwr_role == TYPEC_SOURCE) {

drivers/usb/typec/tcpm/tcpm.c static int tcpm_ams_finish(struct tcpm_port *port) · line 792

Quoted 5 lines
drivers/usb/typec/tcpm/tcpm.c +1 -1
@@ -791,7 +789,7 @@ static int tcpm_ams_finish(struct tcpm_port *port)
  	port->in_ams = false;
  	port->ams = NONE_AMS;
 
-	return ret;
+	return;

Just remove that *return*.

drivers/usb/typec/tcpm/tcpm.c static int tcpm_ams_finish(struct tcpm_port *port) · line 793

Quoted 1 line
drivers/usb/typec/tcpm/tcpm.c +0 -0
  }

[...]

MBR, Sergei