* [PATCH v1 2/3] Bluetooth: btmtkuart: fix recv_buf() return value
2023-11-27 19:14 [PATCH v1 0/3] Bluetooth: fix recv_buf() return value Francesco Dolcini
@ 2023-11-27 19:14 ` Francesco Dolcini
2023-11-27 19:23 ` [PATCH v1 0/3] Bluetooth: " Francesco Dolcini
1 sibling, 0 replies; 4+ messages in thread
From: Francesco Dolcini @ 2023-11-27 19:14 UTC (permalink / raw)
To: Sean Wang, Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: Francesco Dolcini, linux-bluetooth, linux-mediatek, linux-kernel,
linux-arm-kernel, Jiri Slaby, linux-serial
From: Francesco Dolcini <francesco.dolcini@toradex.com>
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@kernel.org/
Fixes: 7237c4c9ec92 ("Bluetooth: mediatek: Add protocol support for MediaTek serial devices")
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
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 unsigned char *data, int count,
return data;
}
-static int btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
+static void btmtkuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
{
struct btmtkuart_dev *bdev = hci_get_drvdata(hdev);
const unsigned char *p_left = 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 = NULL;
- return err;
+ return;
}
sz_left -= sz_h4;
p_left += sz_h4;
}
-
- return 0;
}
static int btmtkuart_receive_buf(struct serdev_device *serdev, const u8 *data,
size_t count)
{
struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev);
- int err;
- err = btmtkuart_recv(bdev->hdev, data, count);
- if (err < 0)
- return err;
+ btmtkuart_recv(bdev->hdev, data, count);
bdev->hdev->stat.byte_rx += count;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v1 0/3] Bluetooth: fix recv_buf() return value
2023-11-27 19:14 [PATCH v1 0/3] Bluetooth: fix recv_buf() return value Francesco Dolcini
2023-11-27 19:14 ` [PATCH v1 2/3] Bluetooth: btmtkuart: " Francesco Dolcini
@ 2023-11-27 19:23 ` Francesco Dolcini
2023-11-28 5:17 ` Jiri Slaby
1 sibling, 1 reply; 4+ messages in thread
From: Francesco Dolcini @ 2023-11-27 19:23 UTC (permalink / raw)
To: Jiri Slaby
Cc: Francesco Dolcini, Sean Wang, Marcel Holtmann, Johan Hedberg,
Luiz Augusto von Dentz, Matthias Brugger,
AngeloGioacchino Del Regno, Amitkumar Karwar, Neeraj Kale,
Francesco Dolcini, linux-bluetooth, linux-mediatek, linux-kernel,
linux-arm-kernel, linux-serial
Hello Jiri,
On Mon, Nov 27, 2023 at 08:14:05PM +0100, Francesco Dolcini wrote:
> From: Francesco Dolcini <francesco.dolcini@toradex.com>
>
> Serdev recv_buf() callback is supposed to return the amount of bytes
> consumed, therefore an int in between 0 and count.
I have also a patch ready to convert the return value of serdev
recv_buf() from int to size_t.
I would be inclined to wait for this series to go though first, given
that these are fixes, while the change from int to size_t is just a
cleanup to prevent future mistakes. Do you agree of would you do it
differently?
Francesco
^ permalink raw reply [flat|nested] 4+ messages in thread