Commit e1a26170 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Provide hdev parameter to hci_recv_frame() driver callback

To avoid casting skb->dev into hdev, just let the drivers provide
the hdev directly when calling hci_recv_frame() function.

This patch also fixes up all drivers to provide the hdev.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 8909f6d2
...@@ -318,7 +318,6 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch ...@@ -318,7 +318,6 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
return -ENOMEM; return -ENOMEM;
} }
skb->dev = (void *) data->hdev;
bt_cb(skb)->pkt_type = pkt_type; bt_cb(skb)->pkt_type = pkt_type;
data->reassembly = skb; data->reassembly = skb;
...@@ -333,7 +332,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch ...@@ -333,7 +332,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
memcpy(skb_put(data->reassembly, len), buf, len); memcpy(skb_put(data->reassembly, len), buf, len);
if (hdr & 0x08) { if (hdr & 0x08) {
hci_recv_frame(data->reassembly); hci_recv_frame(data->hdev, data->reassembly);
data->reassembly = NULL; data->reassembly = NULL;
} }
......
...@@ -399,7 +399,6 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset) ...@@ -399,7 +399,6 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
if (info->rx_state == RECV_WAIT_PACKET_TYPE) { if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
info->rx_skb->dev = (void *) info->hdev;
bt_cb(info->rx_skb)->pkt_type = buf[i]; bt_cb(info->rx_skb)->pkt_type = buf[i];
switch (bt_cb(info->rx_skb)->pkt_type) { switch (bt_cb(info->rx_skb)->pkt_type) {
...@@ -477,7 +476,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset) ...@@ -477,7 +476,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
break; break;
case RECV_WAIT_DATA: case RECV_WAIT_DATA:
hci_recv_frame(info->rx_skb); hci_recv_frame(info->hdev, info->rx_skb);
info->rx_skb = NULL; info->rx_skb = NULL;
break; break;
......
...@@ -129,8 +129,6 @@ static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count) ...@@ -129,8 +129,6 @@ static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count)
return -ENOMEM; return -ENOMEM;
} }
skb->dev = (void *) hdev;
data->rx_skb[queue] = skb; data->rx_skb[queue] = skb;
scb = (void *) skb->cb; scb = (void *) skb->cb;
...@@ -155,7 +153,7 @@ static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count) ...@@ -155,7 +153,7 @@ static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count)
data->rx_skb[queue] = NULL; data->rx_skb[queue] = NULL;
bt_cb(skb)->pkt_type = scb->type; bt_cb(skb)->pkt_type = scb->type;
hci_recv_frame(skb); hci_recv_frame(hdev, skb);
} }
count -= len; buf += len; count -= len; buf += len;
......
...@@ -247,7 +247,6 @@ static void bt3c_receive(bt3c_info_t *info) ...@@ -247,7 +247,6 @@ static void bt3c_receive(bt3c_info_t *info)
if (info->rx_state == RECV_WAIT_PACKET_TYPE) { if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
info->rx_skb->dev = (void *) info->hdev;
bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L); bt_cb(info->rx_skb)->pkt_type = inb(iobase + DATA_L);
inb(iobase + DATA_H); inb(iobase + DATA_H);
//printk("bt3c: PACKET_TYPE=%02x\n", bt_cb(info->rx_skb)->pkt_type); //printk("bt3c: PACKET_TYPE=%02x\n", bt_cb(info->rx_skb)->pkt_type);
...@@ -318,7 +317,7 @@ static void bt3c_receive(bt3c_info_t *info) ...@@ -318,7 +317,7 @@ static void bt3c_receive(bt3c_info_t *info)
break; break;
case RECV_WAIT_DATA: case RECV_WAIT_DATA:
hci_recv_frame(info->rx_skb); hci_recv_frame(info->hdev, info->rx_skb);
info->rx_skb = NULL; info->rx_skb = NULL;
break; break;
......
...@@ -600,15 +600,14 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv) ...@@ -600,15 +600,14 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
case HCI_SCODATA_PKT: case HCI_SCODATA_PKT:
case HCI_EVENT_PKT: case HCI_EVENT_PKT:
bt_cb(skb)->pkt_type = type; bt_cb(skb)->pkt_type = type;
skb->dev = (void *)hdev;
skb_put(skb, buf_len); skb_put(skb, buf_len);
skb_pull(skb, SDIO_HEADER_LEN); skb_pull(skb, SDIO_HEADER_LEN);
if (type == HCI_EVENT_PKT) { if (type == HCI_EVENT_PKT) {
if (btmrvl_check_evtpkt(priv, skb)) if (btmrvl_check_evtpkt(priv, skb))
hci_recv_frame(skb); hci_recv_frame(hdev, skb);
} else { } else {
hci_recv_frame(skb); hci_recv_frame(hdev, skb);
} }
hdev->stat.byte_rx += buf_len; hdev->stat.byte_rx += buf_len;
...@@ -616,12 +615,11 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv) ...@@ -616,12 +615,11 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
case MRVL_VENDOR_PKT: case MRVL_VENDOR_PKT:
bt_cb(skb)->pkt_type = HCI_VENDOR_PKT; bt_cb(skb)->pkt_type = HCI_VENDOR_PKT;
skb->dev = (void *)hdev;
skb_put(skb, buf_len); skb_put(skb, buf_len);
skb_pull(skb, SDIO_HEADER_LEN); skb_pull(skb, SDIO_HEADER_LEN);
if (btmrvl_process_event(priv, skb)) if (btmrvl_process_event(priv, skb))
hci_recv_frame(skb); hci_recv_frame(hdev, skb);
hdev->stat.byte_rx += buf_len; hdev->stat.byte_rx += buf_len;
break; break;
......
...@@ -157,10 +157,9 @@ static int btsdio_rx_packet(struct btsdio_data *data) ...@@ -157,10 +157,9 @@ static int btsdio_rx_packet(struct btsdio_data *data)
data->hdev->stat.byte_rx += len; data->hdev->stat.byte_rx += len;
skb->dev = (void *) data->hdev;
bt_cb(skb)->pkt_type = hdr[3]; bt_cb(skb)->pkt_type = hdr[3];
err = hci_recv_frame(skb); err = hci_recv_frame(data->hdev, skb);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -198,7 +198,6 @@ static void btuart_receive(btuart_info_t *info) ...@@ -198,7 +198,6 @@ static void btuart_receive(btuart_info_t *info)
if (info->rx_state == RECV_WAIT_PACKET_TYPE) { if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
info->rx_skb->dev = (void *) info->hdev;
bt_cb(info->rx_skb)->pkt_type = inb(iobase + UART_RX); bt_cb(info->rx_skb)->pkt_type = inb(iobase + UART_RX);
switch (bt_cb(info->rx_skb)->pkt_type) { switch (bt_cb(info->rx_skb)->pkt_type) {
...@@ -265,7 +264,7 @@ static void btuart_receive(btuart_info_t *info) ...@@ -265,7 +264,7 @@ static void btuart_receive(btuart_info_t *info)
break; break;
case RECV_WAIT_DATA: case RECV_WAIT_DATA:
hci_recv_frame(info->rx_skb); hci_recv_frame(info->hdev, info->rx_skb);
info->rx_skb = NULL; info->rx_skb = NULL;
break; break;
......
...@@ -108,10 +108,8 @@ static long st_receive(void *priv_data, struct sk_buff *skb) ...@@ -108,10 +108,8 @@ static long st_receive(void *priv_data, struct sk_buff *skb)
return -EFAULT; return -EFAULT;
} }
skb->dev = (void *) lhst->hdev;
/* Forward skb to HCI core layer */ /* Forward skb to HCI core layer */
err = hci_recv_frame(skb); err = hci_recv_frame(lhst->hdev, skb);
if (err < 0) { if (err < 0) {
BT_ERR("Unable to push skb to HCI core(%d)", err); BT_ERR("Unable to push skb to HCI core(%d)", err);
return err; return err;
......
...@@ -256,9 +256,8 @@ static void dtl1_receive(dtl1_info_t *info) ...@@ -256,9 +256,8 @@ static void dtl1_receive(dtl1_info_t *info)
case 0x83: case 0x83:
case 0x84: case 0x84:
/* send frame to the HCI layer */ /* send frame to the HCI layer */
info->rx_skb->dev = (void *) info->hdev;
bt_cb(info->rx_skb)->pkt_type &= 0x0f; bt_cb(info->rx_skb)->pkt_type &= 0x0f;
hci_recv_frame(info->rx_skb); hci_recv_frame(info->hdev, info->rx_skb);
break; break;
default: default:
/* unknown packet */ /* unknown packet */
......
...@@ -522,7 +522,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu) ...@@ -522,7 +522,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu)
memcpy(skb_push(bcsp->rx_skb, HCI_EVENT_HDR_SIZE), &hdr, HCI_EVENT_HDR_SIZE); memcpy(skb_push(bcsp->rx_skb, HCI_EVENT_HDR_SIZE), &hdr, HCI_EVENT_HDR_SIZE);
bt_cb(bcsp->rx_skb)->pkt_type = HCI_EVENT_PKT; bt_cb(bcsp->rx_skb)->pkt_type = HCI_EVENT_PKT;
hci_recv_frame(bcsp->rx_skb); hci_recv_frame(hu->hdev, bcsp->rx_skb);
} else { } else {
BT_ERR ("Packet for unknown channel (%u %s)", BT_ERR ("Packet for unknown channel (%u %s)",
bcsp->rx_skb->data[1] & 0x0f, bcsp->rx_skb->data[1] & 0x0f,
...@@ -536,7 +536,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu) ...@@ -536,7 +536,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu)
/* Pull out BCSP hdr */ /* Pull out BCSP hdr */
skb_pull(bcsp->rx_skb, 4); skb_pull(bcsp->rx_skb, 4);
hci_recv_frame(bcsp->rx_skb); hci_recv_frame(hu->hdev, bcsp->rx_skb);
} }
bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
...@@ -655,7 +655,6 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count) ...@@ -655,7 +655,6 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
bcsp->rx_count = 0; bcsp->rx_count = 0;
return 0; return 0;
} }
bcsp->rx_skb->dev = (void *) hu->hdev;
break; break;
} }
break; break;
......
...@@ -340,7 +340,7 @@ static void h5_complete_rx_pkt(struct hci_uart *hu) ...@@ -340,7 +340,7 @@ static void h5_complete_rx_pkt(struct hci_uart *hu)
/* Remove Three-wire header */ /* Remove Three-wire header */
skb_pull(h5->rx_skb, 4); skb_pull(h5->rx_skb, 4);
hci_recv_frame(h5->rx_skb); hci_recv_frame(hu->hdev, h5->rx_skb);
h5->rx_skb = NULL; h5->rx_skb = NULL;
break; break;
......
...@@ -346,14 +346,14 @@ static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb) ...@@ -346,14 +346,14 @@ static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
return 0; return 0;
} }
static inline int ll_check_data_len(struct ll_struct *ll, int len) static inline int ll_check_data_len(struct hci_dev *hdev, struct ll_struct *ll, int len)
{ {
int room = skb_tailroom(ll->rx_skb); int room = skb_tailroom(ll->rx_skb);
BT_DBG("len %d room %d", len, room); BT_DBG("len %d room %d", len, room);
if (!len) { if (!len) {
hci_recv_frame(ll->rx_skb); hci_recv_frame(hdev, ll->rx_skb);
} else if (len > room) { } else if (len > room) {
BT_ERR("Data length is too large"); BT_ERR("Data length is too large");
kfree_skb(ll->rx_skb); kfree_skb(ll->rx_skb);
...@@ -395,7 +395,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count) ...@@ -395,7 +395,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
switch (ll->rx_state) { switch (ll->rx_state) {
case HCILL_W4_DATA: case HCILL_W4_DATA:
BT_DBG("Complete data"); BT_DBG("Complete data");
hci_recv_frame(ll->rx_skb); hci_recv_frame(hu->hdev, ll->rx_skb);
ll->rx_state = HCILL_W4_PACKET_TYPE; ll->rx_state = HCILL_W4_PACKET_TYPE;
ll->rx_skb = NULL; ll->rx_skb = NULL;
...@@ -406,7 +406,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count) ...@@ -406,7 +406,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
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);
ll_check_data_len(ll, eh->plen); ll_check_data_len(hu->hdev, ll, eh->plen);
continue; continue;
case HCILL_W4_ACL_HDR: case HCILL_W4_ACL_HDR:
...@@ -415,7 +415,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count) ...@@ -415,7 +415,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
BT_DBG("ACL header: dlen %d", dlen); BT_DBG("ACL header: dlen %d", dlen);
ll_check_data_len(ll, dlen); ll_check_data_len(hu->hdev, ll, dlen);
continue; continue;
case HCILL_W4_SCO_HDR: case HCILL_W4_SCO_HDR:
...@@ -423,7 +423,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count) ...@@ -423,7 +423,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
BT_DBG("SCO header: dlen %d", sh->dlen); BT_DBG("SCO header: dlen %d", sh->dlen);
ll_check_data_len(ll, sh->dlen); ll_check_data_len(hu->hdev, ll, sh->dlen);
continue; continue;
} }
} }
...@@ -494,7 +494,6 @@ static int ll_recv(struct hci_uart *hu, void *data, int count) ...@@ -494,7 +494,6 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
return -ENOMEM; return -ENOMEM;
} }
ll->rx_skb->dev = (void *) hu->hdev;
bt_cb(ll->rx_skb)->pkt_type = type; bt_cb(ll->rx_skb)->pkt_type = type;
} }
......
...@@ -179,10 +179,9 @@ static inline ssize_t vhci_get_user(struct vhci_data *data, ...@@ -179,10 +179,9 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
return -ENODEV; return -ENODEV;
} }
skb->dev = (void *) data->hdev;
bt_cb(skb)->pkt_type = pkt_type; bt_cb(skb)->pkt_type = pkt_type;
ret = hci_recv_frame(skb); ret = hci_recv_frame(data->hdev, skb);
break; break;
case HCI_VENDOR_PKT: case HCI_VENDOR_PKT:
......
...@@ -755,7 +755,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); ...@@ -755,7 +755,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
int hci_recv_frame(struct sk_buff *skb); int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb);
int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);
int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
......
...@@ -2485,9 +2485,8 @@ int hci_resume_dev(struct hci_dev *hdev) ...@@ -2485,9 +2485,8 @@ int hci_resume_dev(struct hci_dev *hdev)
EXPORT_SYMBOL(hci_resume_dev); EXPORT_SYMBOL(hci_resume_dev);
/* Receive frame from HCI drivers */ /* Receive frame from HCI drivers */
int hci_recv_frame(struct sk_buff *skb) int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags) if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
&& !test_bit(HCI_INIT, &hdev->flags))) { && !test_bit(HCI_INIT, &hdev->flags))) {
kfree_skb(skb); kfree_skb(skb);
...@@ -2546,7 +2545,6 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data, ...@@ -2546,7 +2545,6 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data,
scb->expect = hlen; scb->expect = hlen;
scb->pkt_type = type; scb->pkt_type = type;
skb->dev = (void *) hdev;
hdev->reassembly[index] = skb; hdev->reassembly[index] = skb;
} }
...@@ -2606,7 +2604,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data, ...@@ -2606,7 +2604,7 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data,
/* Complete frame */ /* Complete frame */
bt_cb(skb)->pkt_type = type; bt_cb(skb)->pkt_type = type;
hci_recv_frame(skb); hci_recv_frame(hdev, skb);
hdev->reassembly[index] = NULL; hdev->reassembly[index] = NULL;
return remain; return remain;
......
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