msm_serial_hs: Add flush state machine for UART Tx Transfer

Handle below error cases with UART Tx transfer:
1. Application doing I/O to UART port and is being terminated abnormally.
2. Used ADM Channel for UART TX transfer stalls.

In both above conditions, queued Tx command to ADM is not flushed. Hence
restarting of application shows list corruption for queueing next UART
Tx command to ADM. This change fixes it by having state machine for UART
Tx, identifying such condition and flushing the queue Tx command before
closing the UART device.

Change-Id: I4e567a539d890dffed50b5837dde58d5cd62d641
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>
msm : Add support to get user defined TTY device for Uart port

Currently UART port is enumerating with platform device ID. It is not
necessary that TTY<ID> is same as available UART device ID. Provide
optional support which allows to override used platform device ID with
uart port by userid to get TTY based Uart device as /dev/ttyHS<userid>
instead of /dev/ttyHS<ID>.This support helps third party application/test
framework to use the same TTY uart device name across different platform
without changing in those applications as it is not necessary that on
different platform used UART device would be having same TTY<ID> name.
The userid value should be from 0 to 256

CRs-Fixed: 386736
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
(cherry picked from commit 51690e5e8c2d6199a0e1162aa2c0317a2c6a9f89)

Change-Id: I3d9546ceab48345d0e3456c6223e3ff82e5a2f8b
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Signed-off-by: Dilip Kota <c_dkota@codeaurora.org>
diag: Fix possible underflow/overflow issues

Add check in order to fix possible integer underflow
during HDLC encoding which may lead to buffer
overflow. Also added check for packet length to
avoid buffer overflow.

Change-Id: I72858e7625764652571aee3154e3c2eb61655168
CRs-Fixed: 483400
CRs-Fixed: 483408
Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
Merge "msm_serial_hs: Add flush state machine for UART Tx Transfer"
Merge "msm : Add support to get user defined TTY device for Uart port"
Merge "diag: Fix possible underflow/overflow issues"