]> git.baikalelectronics.ru Git - kernel.git/commit
staging: typec: tcpm: Report role swap complete after entering READY state
authorGuenter Roeck <linux@roeck-us.net>
Fri, 11 Aug 2017 04:15:40 +0000 (21:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 18 Aug 2017 22:57:15 +0000 (15:57 -0700)
commitb94cc7a658efd0fa9eaf585feeee2d6d5c2eeb64
treee50f176ba5f0fa49833d5387da2d49dacf35c555
parentb2bfdb69cff3c28c71aaecc94a34980280cc7bf8
staging: typec: tcpm: Report role swap complete after entering READY state

Role swap requests fail unless the current role is either SRC_READY or
SNK_READY. This works fine for VCONN and data role swaps, where we
immediately enter READY state after reporting a successful role swap
to user space. However, on power role changes, the role swap is currently
reported as successful while power negotiation is still in process.
User space does not know this, and may request another role swap
immediately after a power role swap is reported to be complete.
This second role swap will fail with -EAGAIN.

To fix the problem, report role swap completion after power negotiation
is complete and the state machine enters SRC_READY or SNK_READY state.
This is better anyway since it captures errors due to failed power
negotiations. It also simplifies the code since the number of calls
needed to report successful role swaps is reduced.

Reported-by: Howard Yen <howard_yen@htc.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/typec/tcpm.c