Commit 2a123b86 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[BLUETOOTH]: Introduce skb->data accessor methods for hci_{acl,event,sco}_hdr

For consistency with other skb data accessors, reducing the number of direct
accesses to skb->data.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 03d4f879
...@@ -461,20 +461,20 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset) ...@@ -461,20 +461,20 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
switch (info->rx_state) { switch (info->rx_state) {
case RECV_WAIT_EVENT_HEADER: case RECV_WAIT_EVENT_HEADER:
eh = (struct hci_event_hdr *)(info->rx_skb->data); eh = hci_event_hdr(info->rx_skb);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = eh->plen; info->rx_count = eh->plen;
break; break;
case RECV_WAIT_ACL_HEADER: case RECV_WAIT_ACL_HEADER:
ah = (struct hci_acl_hdr *)(info->rx_skb->data); ah = hci_acl_hdr(info->rx_skb);
dlen = __le16_to_cpu(ah->dlen); dlen = __le16_to_cpu(ah->dlen);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = dlen; info->rx_count = dlen;
break; break;
case RECV_WAIT_SCO_HEADER: case RECV_WAIT_SCO_HEADER:
sh = (struct hci_sco_hdr *)(info->rx_skb->data); sh = hci_sco_hdr(info->rx_skb);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = sh->dlen; info->rx_count = sh->dlen;
break; break;
......
...@@ -303,20 +303,20 @@ static void bt3c_receive(bt3c_info_t *info) ...@@ -303,20 +303,20 @@ static void bt3c_receive(bt3c_info_t *info)
switch (info->rx_state) { switch (info->rx_state) {
case RECV_WAIT_EVENT_HEADER: case RECV_WAIT_EVENT_HEADER:
eh = (struct hci_event_hdr *)(info->rx_skb->data); eh = hci_event_hdr(info->rx_skb);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = eh->plen; info->rx_count = eh->plen;
break; break;
case RECV_WAIT_ACL_HEADER: case RECV_WAIT_ACL_HEADER:
ah = (struct hci_acl_hdr *)(info->rx_skb->data); ah = hci_acl_hdr(info->rx_skb);
dlen = __le16_to_cpu(ah->dlen); dlen = __le16_to_cpu(ah->dlen);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = dlen; info->rx_count = dlen;
break; break;
case RECV_WAIT_SCO_HEADER: case RECV_WAIT_SCO_HEADER:
sh = (struct hci_sco_hdr *)(info->rx_skb->data); sh = hci_sco_hdr(info->rx_skb);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = sh->dlen; info->rx_count = sh->dlen;
break; break;
......
...@@ -250,20 +250,20 @@ static void btuart_receive(btuart_info_t *info) ...@@ -250,20 +250,20 @@ static void btuart_receive(btuart_info_t *info)
switch (info->rx_state) { switch (info->rx_state) {
case RECV_WAIT_EVENT_HEADER: case RECV_WAIT_EVENT_HEADER:
eh = (struct hci_event_hdr *)(info->rx_skb->data); eh = hci_event_hdr(info->rx_skb);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = eh->plen; info->rx_count = eh->plen;
break; break;
case RECV_WAIT_ACL_HEADER: case RECV_WAIT_ACL_HEADER:
ah = (struct hci_acl_hdr *)(info->rx_skb->data); ah = hci_acl_hdr(info->rx_skb);
dlen = __le16_to_cpu(ah->dlen); dlen = __le16_to_cpu(ah->dlen);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = dlen; info->rx_count = dlen;
break; break;
case RECV_WAIT_SCO_HEADER: case RECV_WAIT_SCO_HEADER:
sh = (struct hci_sco_hdr *)(info->rx_skb->data); sh = hci_sco_hdr(info->rx_skb);
info->rx_state = RECV_WAIT_DATA; info->rx_state = RECV_WAIT_DATA;
info->rx_count = sh->dlen; info->rx_count = sh->dlen;
break; break;
......
...@@ -188,7 +188,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -188,7 +188,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue; continue;
case H4_W4_EVENT_HDR: case H4_W4_EVENT_HDR:
eh = (struct hci_event_hdr *) h4->rx_skb->data; eh = hci_event_hdr(h4->rx_skb);
BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen); BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen);
...@@ -196,7 +196,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -196,7 +196,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue; continue;
case H4_W4_ACL_HDR: case H4_W4_ACL_HDR:
ah = (struct hci_acl_hdr *) h4->rx_skb->data; ah = hci_acl_hdr(h4->rx_skb);
dlen = __le16_to_cpu(ah->dlen); dlen = __le16_to_cpu(ah->dlen);
BT_DBG("ACL header: dlen %d", dlen); BT_DBG("ACL header: dlen %d", dlen);
...@@ -205,7 +205,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -205,7 +205,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue; continue;
case H4_W4_SCO_HDR: case H4_W4_SCO_HDR:
sh = (struct hci_sco_hdr *) h4->rx_skb->data; sh = hci_sco_hdr(h4->rx_skb);
BT_DBG("SCO header: dlen %d", sh->dlen); BT_DBG("SCO header: dlen %d", sh->dlen);
......
...@@ -709,6 +709,24 @@ struct hci_sco_hdr { ...@@ -709,6 +709,24 @@ struct hci_sco_hdr {
__u8 dlen; __u8 dlen;
} __attribute__ ((packed)); } __attribute__ ((packed));
#ifdef __KERNEL__
#include <linux/skbuff.h>
static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
{
return (struct hci_event_hdr *)skb->data;
}
static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb)
{
return (struct hci_acl_hdr *)skb->data;
}
static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
{
return (struct hci_sco_hdr *)skb->data;
}
#endif
/* Command opcode pack/unpack */ /* Command opcode pack/unpack */
#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
#define hci_opcode_ogf(op) (op >> 10) #define hci_opcode_ogf(op) (op >> 10)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment