From: Peter Chen <peter.chen@nxp.com>
To: Jun Li <jun.li@nxp.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
dl-linux-imx <linux-imx@nxp.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH 1/2] usb: chipidea: handle single role for usb role class
Date: Mon, 30 Dec 2019 02:27:03 +0000 [thread overview]
Message-ID: <20191230022700.GE5283@b29397-desktop> (raw)
In-Reply-To: <1577442705-6873-1-git-send-email-jun.li@nxp.com>
On 19-12-27 10:35:05, Jun Li wrote:
> From: Li Jun <jun.li@nxp.com>
>
> If usb port is configed to be single role, but usb role class
%s/configed/configured
I will add above change, and apply it.
Peter
> is trying to set unavailable role, don't try to do role change.
>
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
> drivers/usb/chipidea/ci.h | 10 ++++++++++
> drivers/usb/chipidea/core.c | 4 +++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
> index 6911aef..d49d5e1 100644
> --- a/drivers/usb/chipidea/ci.h
> +++ b/drivers/usb/chipidea/ci.h
> @@ -302,6 +302,16 @@ static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)
> return USB_ROLE_NONE;
> }
>
> +static inline enum ci_role usb_role_to_ci_role(enum usb_role role)
> +{
> + if (role == USB_ROLE_HOST)
> + return CI_ROLE_HOST;
> + else if (role == USB_ROLE_DEVICE)
> + return CI_ROLE_GADGET;
> + else
> + return CI_ROLE_END;
> +}
> +
> /**
> * hw_read_id_reg: reads from a identification register
> * @ci: the controller
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index dce5db4..52139c2 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -618,9 +618,11 @@ static int ci_usb_role_switch_set(struct device *dev, enum usb_role role)
> struct ci_hdrc *ci = dev_get_drvdata(dev);
> struct ci_hdrc_cable *cable = NULL;
> enum usb_role current_role = ci_role_to_usb_role(ci);
> + enum ci_role ci_role = usb_role_to_ci_role(role);
> unsigned long flags;
>
> - if (current_role == role)
> + if ((ci_role != CI_ROLE_END && !ci->roles[ci_role]) ||
> + (current_role == role))
> return 0;
>
> pm_runtime_get_sync(ci->dev);
> --
> 2.7.4
>
--
Thanks,
Peter Chen
next prev parent reply other threads:[~2019-12-30 2:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-27 10:35 [PATCH 1/2] usb: chipidea: handle single role for usb role class Jun Li
2019-12-30 2:27 ` Peter Chen [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-01-22 1:46 [PATCH 0/2] usb: chipidea changes for v5.6-rc1 Peter Chen
2020-01-22 1:46 ` [PATCH 1/2] usb: chipidea: handle single role for usb role class Peter Chen
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=20191230022700.GE5283@b29397-desktop \
--to=peter.chen@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=jun.li@nxp.com \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.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