From: Peter Chen <peter.chen@kernel.org>
To: xiehongyu1@kylinos.cn
Cc: pawell@cadence.com, rogerq@kernel.org, frank.li@nxp.com,
gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: cdns3: remove redundant if branch
Date: Mon, 30 Dec 2024 20:01:26 +0800 [thread overview]
Message-ID: <20241230120126.GA837002@nchen-desktop> (raw)
In-Reply-To: <20241230083855.52482-1-xiehongyu1@kylinos.cn>
On 24-12-30 16:38:55, xiehongyu1@kylinos.cn wrote:
> From: Hongyu Xie <xiehongyu1@kylinos.cn>
>
> cdns->role_sw->dev->driver_data gets set in routines showing bellow,
%s/bellow/below, others are okay for me.
> cdns_init
> sw_desc.driver_data = cdns;
> cdns->role_sw = usb_role_switch_register(dev, &sw_desc);
> dev_set_drvdata(&sw->dev, desc->driver_data);
>
> In cdns_resume,
> cdns->role = cdns_role_get(cdns->role_sw); //line redundant
> struct cdns *cdns = usb_role_switch_get_drvdata(sw);
> dev_get_drvdata(&sw->dev)
> return dev->driver_data
> return cdns->role;
>
> "line redundant" equals to,
> cdns->role = cdns->role;
>
> So fix this if branch.
>
> Fixes: 2cf2581cd229 ("usb: cdns3: add power lost support for system resume")
> Signed-off-by: Hongyu Xie <xiehongyu1@kylinos.cn>
Acked-by: Peter Chen <peter.chen@kernel.org>
> ---
> drivers/usb/cdns3/core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> index 465e9267b49c..98980a23e1c2 100644
> --- a/drivers/usb/cdns3/core.c
> +++ b/drivers/usb/cdns3/core.c
> @@ -529,9 +529,7 @@ int cdns_resume(struct cdns *cdns)
> int ret = 0;
>
> if (cdns_power_is_lost(cdns)) {
> - if (cdns->role_sw) {
> - cdns->role = cdns_role_get(cdns->role_sw);
> - } else {
> + if (!cdns->role_sw) {
> real_role = cdns_hw_role_state_machine(cdns);
> if (real_role != cdns->role) {
> ret = cdns_hw_role_switch(cdns);
> --
> 2.25.1
>
prev parent reply other threads:[~2024-12-30 12:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 8:38 [PATCH] usb: cdns3: remove redundant if branch xiehongyu1
2024-12-30 12:01 ` Peter Chen [this message]
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=20241230120126.GA837002@nchen-desktop \
--to=peter.chen@kernel.org \
--cc=frank.li@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=rogerq@kernel.org \
--cc=xiehongyu1@kylinos.cn \
/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;
as well as URLs for NNTP newsgroup(s).