From nobody Fri Sep 20 09:49:23 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DDB3C4167B for ; Mon, 11 Dec 2023 16:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344607AbjLKQk3 (ORCPT ); Mon, 11 Dec 2023 11:40:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234986AbjLKQkW (ORCPT ); Mon, 11 Dec 2023 11:40:22 -0500 Received: from mail11.truemail.it (mail11.truemail.it [217.194.8.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC5CBD; Mon, 11 Dec 2023 08:40:27 -0800 (PST) Received: from francesco-nb.pivistrello.it (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id 17F492094C; Mon, 11 Dec 2023 17:40:26 +0100 (CET) From: Francesco Dolcini To: Sean Wang , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Matthias Brugger , AngeloGioacchino Del Regno Cc: Francesco Dolcini , linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jiri Slaby Subject: [PATCH v2 2/3] Bluetooth: btmtkuart: fix recv_buf() return value Date: Mon, 11 Dec 2023 17:40:19 +0100 Message-Id: <20231211164020.173253-3-francesco@dolcini.it> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231211164020.173253-1-francesco@dolcini.it> References: <20231211164020.173253-1-francesco@dolcini.it> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Francesco Dolcini Serdev recv_buf() callback is supposed to return the amount of bytes consumed, therefore an int in between 0 and count. Do not return negative number in case of issue, just print an error and return count. This fixes a WARN in ttyport_receive_buf(). Link: https://lore.kernel.org/all/087be419-ec6b-47ad-851a-5e1e3ea5cfcc@kern= el.org/ Fixes: 7237c4c9ec92 ("Bluetooth: mediatek: Add protocol support for MediaTe= k serial devices") Signed-off-by: Francesco Dolcini --- drivers/bluetooth/btmtkuart.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c index 935feab815d9..203a000a84e3 100644 --- a/drivers/bluetooth/btmtkuart.c +++ b/drivers/bluetooth/btmtkuart.c @@ -336,7 +336,7 @@ mtk_stp_split(struct btmtkuart_dev *bdev, const unsigne= d char *data, int count, return data; } =20 -static int btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t cou= nt) +static void btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t co= unt) { struct btmtkuart_dev *bdev =3D hci_get_drvdata(hdev); const unsigned char *p_left =3D data, *p_h4; @@ -375,25 +375,20 @@ static int btmtkuart_recv(struct hci_dev *hdev, const= u8 *data, size_t count) bt_dev_err(bdev->hdev, "Frame reassembly failed (%d)", err); bdev->rx_skb =3D NULL; - return err; + return; } =20 sz_left -=3D sz_h4; p_left +=3D sz_h4; } - - return 0; } =20 static int btmtkuart_receive_buf(struct serdev_device *serdev, const u8 *d= ata, size_t count) { struct btmtkuart_dev *bdev =3D serdev_device_get_drvdata(serdev); - int err; =20 - err =3D btmtkuart_recv(bdev->hdev, data, count); - if (err < 0) - return err; + btmtkuart_recv(bdev->hdev, data, count); =20 bdev->hdev->stat.byte_rx +=3D count; =20 --=20 2.25.1