MLK-17108-4 staging: typec: tcpci: correct read data msg length
Per tcpci spec, the TCPC_RX_BYTE_CNT is the number of bytes in the RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE and RX_BUF_HEADER), so after read out the header, we should only read TCPC_RX_BYTE_CNT-3 bytes for data if this is a data message. Acked-by: Peter Chen <peter.chen@nxp.com> Signed-off-by: Li Jun <jun.li@nxp.com>pull/10/head
parent
4adece561e
commit
a7246ec48c
|
@ -581,6 +581,12 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id)
|
|||
tcpci_read16(tcpci, TCPC_RX_HDR, ®);
|
||||
msg.header = reg;
|
||||
|
||||
/*
|
||||
* TCPC_RX_BYTE_CNT is the number of bytes in the
|
||||
* RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE
|
||||
* and RX_BUF_HEADER).
|
||||
*/
|
||||
cnt -= 3;
|
||||
if (WARN_ON(cnt > sizeof(msg.payload)))
|
||||
cnt = sizeof(msg.payload);
|
||||
|
||||
|
|
Loading…
Reference in New Issue