Revert "USB: ks_bridge: Enable autosuspend only for remote wakeup capable devices"

This reverts commit dff38fbce185c1c86917de6a776ca140d9d01e96.
Revert "USB: ks_bridge: Abort suspend when data is received during unlink"

This reverts commit da0e93715f4848b88421c6e4294c3b7af8594baa.
Revert "USB: ks_bridge: Prevent freeing buffers while copy is in progress"

This reverts commit 8ccaa1d4c02a985ee79f612e4384bc66ae8c2626.
Revert "usb: ks_bridge: Free up stale buffers in probe"

This reverts commit c999d43720a580fb721d8b6599d735e629e24db4.
Revert "usb: ks_bridge: Synchronize disconnect with ongoing IO"

This reverts commit ea4b0b08ce177e268291f6f27f507b7103b9078d.
Revert "usb: ks_bridge: Add support for multiple instance of driver"

This reverts commit 54aeb828d25f916d23a593162ceb8bd5568da8d2.
usb: ks_bridge: Synchronize disconnect with ongoing IO

Following scenarios possible for interface disconnect racing
with ongoing IO:-

1) Interface disconnect setting interface pointer to NULL and
rx work is executing on other core dereferencing interface
pointer, causing kernel panic. Cancel a work and wait for it
to finish during disconnect.

2) Interface disconnect setting interface pointer to NULL and
tx completion running on other core dereferencing interface
pointer while calling usb_autopm_put_interface_async() API.
Check for USB_DEV_CONNECTED flag(cleared at the time of
disconnect) before dereferencing the interface pointer.

3) Interface unbound and driver is accessing already freed
interface pointer in tx completion or usb device pointer to
re-submit rx urb in rx completion. Add rx and tx urb pending
counters and wait for them to become zero (or timeout) during
disconnect.

(cherry picked from commit b3779d1e3ed31d10c97094256c6d398af8484faa)

Conflicts:

	drivers/usb/misc/ks_bridge.c

CRs-Fixed: 448142
Change-Id: I50341173b94200bcfa60715b4b26b2117fc37c2c
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Conflicts:
	drivers/usb/misc/ks_bridge.c
usb: ks_bridge: Free up stale buffers in probe

Driver can add data buffer to the link list of rx/tx
buffers after emptying the list during disconnect.
These stale buffers can confuse efs sync server when
mdm device connects back. Hence free up the rx/tx
buffers again during probe. Avoid further addition of
tx buffers after disconnect by checking device
connection status in write API. Also, move
misc_deregister() after cancelling the work in order
to remove device node early during disconnect to avoid
any write call further.

(cherry picked from commit 2f20bda7837d6f9a172b433af72a02f907b2ed2f)

Conflicts:

	drivers/usb/misc/ks_bridge.c

CRs-Fixed: 448142
Change-Id: Ifff58d2adc113257809eb80b7f91c1a0f4a0adeb
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Conflicts:
	drivers/usb/misc/ks_bridge.c
USB: ks_bridge: Prevent freeing buffers while copy is in progress

The completed read buffers are added to to_ks_list in Rx URB
completion handler.  The buffer is deleted from this list by
reader process after copying to user space buffer.  If disconnect
happens during this copy, the buffer is freed from disconnect
context.  Hence detach the buffer from to_ks_list before copying
to user space buffer.

CRs-Fixed: 448142
Change-Id: Ia4484b2709065162b0d32782a30e2b2fd36f5fda
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: ks_bridge: Abort suspend when data is received during unlink

All the submitted URBs are unlinked during suspend.  Abort suspend
if data is received during unlink.  This avoids unnecessary suspend
and resume of remaining interfaces.

CRs-Fixed: 449097
Change-Id: Ia4009775ec29df0222b475581649c3a9f4f1899f
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: ks_bridge: Enable autosuspend only for remote wakeup capable devices

USB core marks a device wakeup capable if it supports remote wakeup.
Check this wakeup capable flag before enabling autosuspend.

CRs-Fixed: 449100
Change-Id: I055bf5801859e4d83782916c71e0245c455becbf
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>