Skip to content

Commit

Permalink
usb: typec: Block mode entry if the port has the mode disabled
Browse files Browse the repository at this point in the history
Originally the port drivers were expected to check does the
connector have the mode enabled or disabled when the alt
mode drivers attempted to enter the mode, but since
typec_altmode_enter() puts the connector into USB Safe
State before calling the port driver, it really has to do
the check on its own, and before changing the state.
Otherwise the connector may be left in USB Safe State if the
port driver does not move it back to normal USB operation
when the mode is disabled.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20191230142611.24921-2-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Jan 9, 2020
1 parent 497210f commit cf2f58f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/typec/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ int typec_altmode_enter(struct typec_altmode *adev)
if (!pdev->ops || !pdev->ops->enter)
return -EOPNOTSUPP;

if (is_typec_port(pdev->dev.parent) && !pdev->active)
return -EPERM;

/* Moving to USB Safe State */
ret = typec_altmode_set_state(adev, TYPEC_STATE_SAFE);
if (ret)
Expand Down

0 comments on commit cf2f58f

Please sign in to comment.