Bluetooth: Remove unnecessary error checks for bt_uart_read() calls
When the 'len' and 'min' parameters passed to bt_uart_read() are equal the function is guaranteed to always return 'len' (it will keep looping until that). This patch removes bt_uart_read() error checks which would never occur in practice. Change-Id: Icd879f1e15c6d33acc549155aabd24490098ffc5 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
099ecbfa7c
commit
caf5141de5
|
@ -91,14 +91,9 @@ static struct bt_buf *bt_uart_evt_recv(int *remaining)
|
|||
{
|
||||
struct bt_hci_evt_hdr hdr;
|
||||
struct bt_buf *buf;
|
||||
int read;
|
||||
|
||||
read = bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
|
||||
if (read != sizeof(hdr)) {
|
||||
BT_ERR("Cannot read event header\n");
|
||||
*remaining = -EIO;
|
||||
return NULL;
|
||||
}
|
||||
/* We can ignore the return value since we pass len == min */
|
||||
bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
|
||||
|
||||
*remaining = hdr.len;
|
||||
|
||||
|
@ -117,14 +112,9 @@ static struct bt_buf *bt_uart_acl_recv(int *remaining)
|
|||
{
|
||||
struct bt_hci_acl_hdr hdr;
|
||||
struct bt_buf *buf;
|
||||
int read;
|
||||
|
||||
read = bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
|
||||
if (read != sizeof(hdr)) {
|
||||
BT_ERR("Cannot read ACL header\n");
|
||||
*remaining = -EIO;
|
||||
return NULL;
|
||||
}
|
||||
/* We can ignore the return value since we pass len == min */
|
||||
bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
|
||||
|
||||
buf = bt_buf_get(BT_ACL_IN, 0);
|
||||
if (buf)
|
||||
|
@ -180,12 +170,6 @@ void bt_uart_isr(void *unused)
|
|||
return;
|
||||
}
|
||||
|
||||
if (remaining < 0) {
|
||||
BT_ERR("Corrupted data received\n");
|
||||
remaining = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (remaining > bt_buf_tailroom(buf)) {
|
||||
BT_ERR("Not enough space in buffer\n");
|
||||
goto failed;
|
||||
|
|
Loading…
Reference in a new issue