Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1592481
| From | Sebastian Reichel <sre@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 03/10] Bluetooth: hci_uart: add support for word alignment |
| Date | 2017-03-04 13:10 +0100 |
| Message-ID | <thgFA-sD-33@gated-at.bofh.it> (permalink) |
| References | <thgFz-sD-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This will be used by Nokia's H4+ protocol, which
uses 2-byte aligned packets.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/bluetooth/hci_h4.c | 17 +++++++++++++++++
drivers/bluetooth/hci_ldisc.c | 4 ++++
drivers/bluetooth/hci_uart.h | 3 +++
3 files changed, 24 insertions(+)
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 635597b6e168..9c59807ebbdd 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -171,9 +171,20 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
const unsigned char *buffer, int count,
const struct h4_recv_pkt *pkts, int pkts_count)
{
+ struct hci_uart *hu = hci_get_drvdata(hdev);
+ uint8_t alignment = hu->alignment;
+
while (count) {
int i, len;
+ /* remove padding bytes from buffer */
+ for (; hu->padding && count > 0; hu->padding--) {
+ count--;
+ buffer++;
+ }
+ if (!count)
+ break;
+
if (!skb) {
for (i = 0; i < pkts_count; i++) {
if (buffer[0] != (&pkts[i])->type)
@@ -253,11 +264,17 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
}
if (!dlen) {
+ hu->padding = (skb->len - 1) % alignment;
+ hu->padding = (alignment - hu->padding) % alignment;
+
/* No more data, complete frame */
(&pkts[i])->recv(hdev, skb);
skb = NULL;
}
} else {
+ hu->padding = (skb->len - 1) % alignment;
+ hu->padding = (alignment - hu->padding) % alignment;
+
/* Complete frame */
(&pkts[i])->recv(hdev, skb);
skb = NULL;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 9497c469efd2..0ec8a94bd712 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -459,6 +459,10 @@ static int hci_uart_tty_open(struct tty_struct *tty)
hu->tty = tty;
tty->receive_room = 65536;
+ /* disable alignment support by default */
+ hu->alignment = 1;
+ hu->padding = 0;
+
INIT_WORK(&hu->init_ready, hci_uart_init_work);
INIT_WORK(&hu->write_work, hci_uart_write_work);
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 070139513e65..4aff50960cac 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -92,6 +92,9 @@ struct hci_uart {
unsigned int init_speed;
unsigned int oper_speed;
+
+ u8 alignment;
+ u8 padding;
};
/* HCI_UART proto flag bits */
--
2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] Nokia H4+ support Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 09/10] serdev: add serdev_device_set_rts Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
Re: [PATCH 09/10] serdev: add serdev_device_set_rts Rob Herring <robh+dt@kernel.org> - 2017-03-07 17:10 +0100
Re: [PATCH 09/10] serdev: add serdev_device_set_rts Sebastian Reichel <sre@kernel.org> - 2017-03-07 22:20 +0100
[PATCH 10/10] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Rob Herring <robh+dt@kernel.org> - 2017-03-07 17:50 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-07 22:50 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Marcel Holtmann <marcel@holtmann.org> - 2017-03-07 23:00 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-08 00:10 +0100
Re: [PATCH 10/10] Bluetooth: add nokia driver Rob Herring <robh+dt@kernel.org> - 2017-03-08 15:40 +0100
[PATCH 03/10] Bluetooth: hci_uart: add support for word alignment Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 04/10] Bluetooth: hci_uart: add serdev driver support library Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 05/10] Bluetooth: hci_serdev: do not open device in hci open Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
[PATCH 07/10] serdev: add serdev_device_wait_until_sent Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
Re: [PATCH 07/10] serdev: add serdev_device_wait_until_sent Rob Herring <robh+dt@kernel.org> - 2017-03-07 16:50 +0100
Re: [PATCH 07/10] serdev: add serdev_device_wait_until_sent Rob Herring <robh+dt@kernel.org> - 2017-03-07 18:00 +0100
Re: [PATCH 07/10] serdev: add serdev_device_wait_until_sent Sebastian Reichel <sre@kernel.org> - 2017-03-07 18:20 +0100
csiph-web