* [PATCH] platform/chrome: cros_ec_typec: Check for device within remove function
@ 2021-03-19 1:51 Prashant Malani
2021-03-31 7:37 ` Enric Balletbo i Serra
0 siblings, 1 reply; 2+ messages in thread
From: Prashant Malani @ 2021-03-19 1:51 UTC (permalink / raw)
To: linux-kernel
Cc: Prashant Malani, Benson Leung, Enric Balletbo i Serra, Guenter Roeck
In a couple of call sites, we use the same pattern of checking for a
partner or cable device before attempting to remove it. Simplify this by
moving those checks into the remove functions.
Cc: Benson Leung <bleung@chromium.org>
Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
drivers/platform/chrome/cros_ec_typec.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 0811562deecc..8e7fde3e7032 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -220,6 +220,9 @@ static void cros_typec_remove_partner(struct cros_typec_data *typec,
{
struct cros_typec_port *port = typec->ports[port_num];
+ if (!port->partner)
+ return;
+
cros_typec_unregister_altmodes(typec, port_num, true);
cros_typec_usb_disconnect_state(port);
@@ -235,6 +238,9 @@ static void cros_typec_remove_cable(struct cros_typec_data *typec,
{
struct cros_typec_port *port = typec->ports[port_num];
+ if (!port->cable)
+ return;
+
cros_typec_unregister_altmodes(typec, port_num, false);
typec_unregister_plug(port->plug);
@@ -253,11 +259,8 @@ static void cros_unregister_ports(struct cros_typec_data *typec)
if (!typec->ports[i])
continue;
- if (typec->ports[i]->partner)
- cros_typec_remove_partner(typec, i);
-
- if (typec->ports[i]->cable)
- cros_typec_remove_cable(typec, i);
+ cros_typec_remove_partner(typec, i);
+ cros_typec_remove_cable(typec, i);
usb_role_switch_put(typec->ports[i]->role_sw);
typec_switch_put(typec->ports[i]->ori_sw);
@@ -647,11 +650,8 @@ static void cros_typec_set_port_params_v1(struct cros_typec_data *typec,
"Failed to register partner on port: %d\n",
port_num);
} else {
- if (typec->ports[port_num]->partner)
- cros_typec_remove_partner(typec, port_num);
-
- if (typec->ports[port_num]->cable)
- cros_typec_remove_cable(typec, port_num);
+ cros_typec_remove_partner(typec, port_num);
+ cros_typec_remove_cable(typec, port_num);
}
}
--
2.31.0.rc2.261.g7f71774620-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/chrome: cros_ec_typec: Check for device within remove function
2021-03-19 1:51 [PATCH] platform/chrome: cros_ec_typec: Check for device within remove function Prashant Malani
@ 2021-03-31 7:37 ` Enric Balletbo i Serra
0 siblings, 0 replies; 2+ messages in thread
From: Enric Balletbo i Serra @ 2021-03-31 7:37 UTC (permalink / raw)
To: linux-kernel, Prashant Malani; +Cc: Benson Leung, Guenter Roeck
On Thu, 18 Mar 2021 18:51:03 -0700, Prashant Malani wrote:
> In a couple of call sites, we use the same pattern of checking for a
> partner or cable device before attempting to remove it. Simplify this by
> moving those checks into the remove functions.
Applied, thanks!
[1/1] platform/chrome: cros_ec_typec: Check for device within remove function
commit: 639ff208cb37c5a3f0198e62d04962b677d25c9c
Best regards,
--
Enric Balletbo i Serra <enric.balletbo@collabora.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-31 7:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 1:51 [PATCH] platform/chrome: cros_ec_typec: Check for device within remove function Prashant Malani
2021-03-31 7:37 ` Enric Balletbo i Serra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).