From: Xu Yang <xu.yang_2@nxp.com>
To: peter.chen@kernel.org, gregkh@linuxfoundation.org
Cc: jun.li@nxp.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev
Subject: [PATCH v2 1/3] usb: chipidea: core: refactor ci_usb_role_switch_set()
Date: Thu, 2 Apr 2026 15:14:55 +0800 [thread overview]
Message-ID: <20260402071457.2516021-1-xu.yang_2@nxp.com> (raw)
Current code is redundant, refactor the code, no function change.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v2:
- new patch
---
drivers/usb/chipidea/core.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index fac11f20cf0a..87be716dff3e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -618,28 +618,13 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw,
struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw);
struct ci_hdrc_cable *cable;
- if (role == USB_ROLE_HOST) {
- cable = &ci->platdata->id_extcon;
- cable->changed = true;
- cable->connected = true;
- cable = &ci->platdata->vbus_extcon;
- cable->changed = true;
- cable->connected = false;
- } else if (role == USB_ROLE_DEVICE) {
- cable = &ci->platdata->id_extcon;
- cable->changed = true;
- cable->connected = false;
- cable = &ci->platdata->vbus_extcon;
- cable->changed = true;
- cable->connected = true;
- } else {
- cable = &ci->platdata->id_extcon;
- cable->changed = true;
- cable->connected = false;
- cable = &ci->platdata->vbus_extcon;
- cable->changed = true;
- cable->connected = false;
- }
+ cable = &ci->platdata->id_extcon;
+ cable->changed = true;
+ cable->connected = (role == USB_ROLE_HOST);
+
+ cable = &ci->platdata->vbus_extcon;
+ cable->changed = true;
+ cable->connected = (role == USB_ROLE_DEVICE);
ci_irq(ci);
return 0;
--
2.34.1
next reply other threads:[~2026-04-02 7:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 7:14 Xu Yang [this message]
2026-04-02 7:14 ` [PATCH v2 2/3] usb: chipidea: core: allow ci_irq_handler() handle both ID and VBUS change Xu Yang
2026-04-08 5:39 ` Peter Chen (CIX)
2026-04-09 6:11 ` Xu Yang
2026-04-02 7:14 ` [PATCH v2 3/3] usb: chipidea: otg: not wait vbus drop if use role_switch Xu Yang
2026-04-08 5:24 ` [PATCH v2 1/3] usb: chipidea: core: refactor ci_usb_role_switch_set() Peter Chen (CIX)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260402071457.2516021-1-xu.yang_2@nxp.com \
--to=xu.yang_2@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®