Skip to content

Commit 94d0539

Browse files
dolciniVudentz
authored andcommitted
Bluetooth: btnxpuart: fix recv_buf() return value
Serdev recv_buf() callback is supposed to return the amount of bytes consumed, therefore an int in between 0 and count. Do not return a negative number in case of issue, just print an error and return count. Before this change, in case of error, the returned negative number was internally converted to 0 in ttyport_receive_buf, now when the receive buffer is corrupted we return the size of the whole received data (`count`). This should allow for better recovery in case receiver/transmitter get out of sync if some data is lost. This fixes a WARN in ttyport_receive_buf(). Bluetooth: hci0: Frame reassembly failed (-84) ------------[ cut here ]------------ serial serial0: receive_buf returns -84 (count = 6) WARNING: CPU: 0 PID: 37 at drivers/tty/serdev/serdev-ttyport.c:37 ttyport_receive_buf+0xd8/0xf8 Modules linked in: mwifiex_sdio(+) ... CPU: 0 PID: 37 Comm: kworker/u4:2 Not tainted 6.7.0-rc2-00147-gf1a09972a45a #1 Hardware name: Toradex Verdin AM62 WB on Verdin Development Board (DT) Workqueue: events_unbound flush_to_ldisc pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : ttyport_receive_buf+0xd8/0xf8 lr : ttyport_receive_buf+0xd8/0xf8 ... Call trace: ttyport_receive_buf+0xd8/0xf8 flush_to_ldisc+0xbc/0x1a4 process_scheduled_works+0x16c/0x28c Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 689ca16 ("Bluetooth: NXP: Add protocol support for NXP Bluetooth chipsets") Signed-off-by: Francesco Dolcini <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent ca6d2ad commit 94d0539

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/bluetooth/btnxpuart.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,11 +1276,10 @@ static int btnxpuart_receive_buf(struct serdev_device *serdev, const u8 *data,
12761276
if (IS_ERR(nxpdev->rx_skb)) {
12771277
int err = PTR_ERR(nxpdev->rx_skb);
12781278
/* Safe to ignore out-of-sync bootloader signatures */
1279-
if (is_fw_downloading(nxpdev))
1280-
return count;
1281-
bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err);
1279+
if (!is_fw_downloading(nxpdev))
1280+
bt_dev_err(nxpdev->hdev, "Frame reassembly failed (%d)", err);
12821281
nxpdev->rx_skb = NULL;
1283-
return err;
1282+
return count;
12841283
}
12851284
if (!is_fw_downloading(nxpdev))
12861285
nxpdev->hdev->stat.byte_rx += count;

0 commit comments

Comments
 (0)