From: Lee Jones <lee@kernel.org>
To: Neill Kapron <nkapron@google.com>
Cc: Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Chris Zhong <zyw@rock-chips.com>,
Kever Yang <kever.yang@rock-chips.com>,
Guenter Roeck <groeck@chromium.org>,
linux-kernel@vger.kernel.org, kernel-team@android.com,
Kishon Vijay Abraham I <kishon@ti.com>
Subject: Re: [PATCH] phy: rockchip-typec: fix tcphy_get_mode error case
Date: Thu, 26 Jan 2023 16:41:42 +0000 [thread overview]
Message-ID: <Y9KtRpsioQNTc4oc@google.com> (raw)
In-Reply-To: <20230126001013.3707873-1-nkapron@google.com>
On Thu, 26 Jan 2023, Neill Kapron wrote:
> The existing logic in tcphy_get_mode() can cause the phy to be
> incorrectly configured to USB UFP or DisplayPort mode when
> extcon_get_state returns an error code.
>
> extcon_get_state() can return 0, 1, or a negative error code.
>
> It is possible to get into the failing state with an extcon driver
> which does not support the extcon connector id specified as the
> second argument to extcon_get_state().
>
> tcphy_get_mode()
> ->extcon_get_state()
> -->find_cable_index_by_id()
> --->return -EINVAL;
>
> Fixes: e96be45cb84e ("phy: Add USB Type-C PHY driver for rk3399")
> Signed-off-by: Neill Kapron <nkapron@google.com>
> ---
> drivers/phy/rockchip/phy-rockchip-typec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Good catch.
Reviewed-by: Lee Jones <lee@kernel.org>
> diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c
> index d76440ae10ff..6aea512e5d4e 100644
> --- a/drivers/phy/rockchip/phy-rockchip-typec.c
> +++ b/drivers/phy/rockchip/phy-rockchip-typec.c
> @@ -821,10 +821,10 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)
> mode = MODE_DFP_USB;
> id = EXTCON_USB_HOST;
>
> - if (ufp) {
> + if (ufp > 0) {
> mode = MODE_UFP_USB;
> id = EXTCON_USB;
> - } else if (dp) {
> + } else if (dp > 0) {
> mode = MODE_DFP_DP;
> id = EXTCON_DISP_DP;
>
> --
> 2.39.1.456.gfc5497dd1b-goog
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2023-01-26 16:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 0:10 Neill Kapron
2023-01-26 16:41 ` Lee Jones [this message]
2023-02-03 11:43 ` Vinod Koul
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=Y9KtRpsioQNTc4oc@google.com \
--to=lee@kernel.org \
--cc=groeck@chromium.org \
--cc=heiko@sntech.de \
--cc=kernel-team@android.com \
--cc=kever.yang@rock-chips.com \
--cc=kishon@kernel.org \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nkapron@google.com \
--cc=vkoul@kernel.org \
--cc=zyw@rock-chips.com \
/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®