Commit 7bd8f09f authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Add hdev parameter to hdev->send driver callback

Instead of masking hdev inside the skb->dev parameter, hand it
directly to the driver as a parameter to hdev->send. This makes
the driver interface more clear and simpler.

This patch fixes all drivers to accept and handle the new parameter
of hdev->send callback. Special care has been taken for bpa10x
and btusb drivers that require having skb->dev set to hdev for
the URB transmit complete handlers.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent e1a26170
...@@ -464,9 +464,8 @@ static int bfusb_close(struct hci_dev *hdev) ...@@ -464,9 +464,8 @@ static int bfusb_close(struct hci_dev *hdev)
return 0; return 0;
} }
static int bfusb_send_frame(struct sk_buff *skb) static int bfusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct bfusb_data *data; struct bfusb_data *data;
struct sk_buff *nskb; struct sk_buff *nskb;
unsigned char buf[3]; unsigned char buf[3];
......
...@@ -658,10 +658,9 @@ static int bluecard_hci_close(struct hci_dev *hdev) ...@@ -658,10 +658,9 @@ static int bluecard_hci_close(struct hci_dev *hdev)
} }
static int bluecard_hci_send_frame(struct sk_buff *skb) static int bluecard_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
bluecard_info_t *info; bluecard_info_t *info;
struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
if (!hdev) { if (!hdev) {
BT_ERR("Frame for unknown HCI device (hdev=NULL)"); BT_ERR("Frame for unknown HCI device (hdev=NULL)");
......
...@@ -350,9 +350,8 @@ static int bpa10x_flush(struct hci_dev *hdev) ...@@ -350,9 +350,8 @@ static int bpa10x_flush(struct hci_dev *hdev)
return 0; return 0;
} }
static int bpa10x_send_frame(struct sk_buff *skb) static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct bpa10x_data *data = hci_get_drvdata(hdev); struct bpa10x_data *data = hci_get_drvdata(hdev);
struct usb_ctrlrequest *dr; struct usb_ctrlrequest *dr;
struct urb *urb; struct urb *urb;
...@@ -364,6 +363,8 @@ static int bpa10x_send_frame(struct sk_buff *skb) ...@@ -364,6 +363,8 @@ static int bpa10x_send_frame(struct sk_buff *skb)
if (!test_bit(HCI_RUNNING, &hdev->flags)) if (!test_bit(HCI_RUNNING, &hdev->flags))
return -EBUSY; return -EBUSY;
skb->dev = (void *) hdev;
urb = usb_alloc_urb(0, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) if (!urb)
return -ENOMEM; return -ENOMEM;
......
...@@ -415,10 +415,9 @@ static int bt3c_hci_close(struct hci_dev *hdev) ...@@ -415,10 +415,9 @@ static int bt3c_hci_close(struct hci_dev *hdev)
} }
static int bt3c_hci_send_frame(struct sk_buff *skb) static int bt3c_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
bt3c_info_t *info; bt3c_info_t *info;
struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
unsigned long flags; unsigned long flags;
if (!hdev) { if (!hdev) {
......
...@@ -187,7 +187,6 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 cmd_no, ...@@ -187,7 +187,6 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 cmd_no,
bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb); skb_queue_head(&priv->adapter->tx_queue, skb);
priv->btmrvl_dev.sendcmdflag = true; priv->btmrvl_dev.sendcmdflag = true;
...@@ -356,9 +355,8 @@ static void btmrvl_free_adapter(struct btmrvl_private *priv) ...@@ -356,9 +355,8 @@ static void btmrvl_free_adapter(struct btmrvl_private *priv)
priv->adapter = NULL; priv->adapter = NULL;
} }
static int btmrvl_send_frame(struct sk_buff *skb) static int btmrvl_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct btmrvl_private *priv = NULL; struct btmrvl_private *priv = NULL;
BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len); BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
......
...@@ -254,9 +254,8 @@ static int btsdio_flush(struct hci_dev *hdev) ...@@ -254,9 +254,8 @@ static int btsdio_flush(struct hci_dev *hdev)
return 0; return 0;
} }
static int btsdio_send_frame(struct sk_buff *skb) static int btsdio_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct btsdio_data *data = hci_get_drvdata(hdev); struct btsdio_data *data = hci_get_drvdata(hdev);
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
......
...@@ -423,10 +423,9 @@ static int btuart_hci_close(struct hci_dev *hdev) ...@@ -423,10 +423,9 @@ static int btuart_hci_close(struct hci_dev *hdev)
} }
static int btuart_hci_send_frame(struct sk_buff *skb) static int btuart_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
btuart_info_t *info; btuart_info_t *info;
struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
if (!hdev) { if (!hdev) {
BT_ERR("Frame for unknown HCI device (hdev=NULL)"); BT_ERR("Frame for unknown HCI device (hdev=NULL)");
......
...@@ -716,9 +716,8 @@ static int btusb_flush(struct hci_dev *hdev) ...@@ -716,9 +716,8 @@ static int btusb_flush(struct hci_dev *hdev)
return 0; return 0;
} }
static int btusb_send_frame(struct sk_buff *skb) static int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct btusb_data *data = hci_get_drvdata(hdev); struct btusb_data *data = hci_get_drvdata(hdev);
struct usb_ctrlrequest *dr; struct usb_ctrlrequest *dr;
struct urb *urb; struct urb *urb;
...@@ -730,6 +729,8 @@ static int btusb_send_frame(struct sk_buff *skb) ...@@ -730,6 +729,8 @@ static int btusb_send_frame(struct sk_buff *skb)
if (!test_bit(HCI_RUNNING, &hdev->flags)) if (!test_bit(HCI_RUNNING, &hdev->flags))
return -EBUSY; return -EBUSY;
skb->dev = (void *) hdev;
switch (bt_cb(skb)->pkt_type) { switch (bt_cb(skb)->pkt_type) {
case HCI_COMMAND_PKT: case HCI_COMMAND_PKT:
urb = usb_alloc_urb(0, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC);
......
...@@ -251,14 +251,11 @@ static int ti_st_close(struct hci_dev *hdev) ...@@ -251,14 +251,11 @@ static int ti_st_close(struct hci_dev *hdev)
return err; return err;
} }
static int ti_st_send_frame(struct sk_buff *skb) static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev *hdev;
struct ti_st *hst; struct ti_st *hst;
long len; long len;
hdev = (struct hci_dev *)skb->dev;
if (!test_bit(HCI_RUNNING, &hdev->flags)) if (!test_bit(HCI_RUNNING, &hdev->flags))
return -EBUSY; return -EBUSY;
......
...@@ -382,10 +382,9 @@ static int dtl1_hci_close(struct hci_dev *hdev) ...@@ -382,10 +382,9 @@ static int dtl1_hci_close(struct hci_dev *hdev)
} }
static int dtl1_hci_send_frame(struct sk_buff *skb) static int dtl1_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
dtl1_info_t *info; dtl1_info_t *info;
struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
struct sk_buff *s; struct sk_buff *s;
nsh_t nsh; nsh_t nsh;
......
...@@ -234,9 +234,8 @@ static int hci_uart_close(struct hci_dev *hdev) ...@@ -234,9 +234,8 @@ static int hci_uart_close(struct hci_dev *hdev)
} }
/* Send frames from HCI layer */ /* Send frames from HCI layer */
static int hci_uart_send_frame(struct sk_buff *skb) static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev* hdev = (struct hci_dev *) skb->dev;
struct hci_uart *hu; struct hci_uart *hu;
if (!hdev) { if (!hdev) {
......
...@@ -110,7 +110,6 @@ static int send_hcill_cmd(u8 cmd, struct hci_uart *hu) ...@@ -110,7 +110,6 @@ static int send_hcill_cmd(u8 cmd, struct hci_uart *hu)
/* prepare packet */ /* prepare packet */
hcill_packet = (struct hcill_cmd *) skb_put(skb, 1); hcill_packet = (struct hcill_cmd *) skb_put(skb, 1);
hcill_packet->cmd = cmd; hcill_packet->cmd = cmd;
skb->dev = (void *) hu->hdev;
/* send packet */ /* send packet */
skb_queue_tail(&ll->txq, skb); skb_queue_tail(&ll->txq, skb);
......
...@@ -81,9 +81,8 @@ static int vhci_flush(struct hci_dev *hdev) ...@@ -81,9 +81,8 @@ static int vhci_flush(struct hci_dev *hdev)
return 0; return 0;
} }
static int vhci_send_frame(struct sk_buff *skb) static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{ {
struct hci_dev* hdev = (struct hci_dev *) skb->dev;
struct vhci_data *data; struct vhci_data *data;
if (!hdev) { if (!hdev) {
......
...@@ -285,7 +285,7 @@ struct hci_dev { ...@@ -285,7 +285,7 @@ struct hci_dev {
int (*close)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev);
int (*setup)(struct hci_dev *hdev); int (*setup)(struct hci_dev *hdev);
int (*send)(struct sk_buff *skb); int (*send)(struct hci_dev *hdev, struct sk_buff *skb);
void (*notify)(struct hci_dev *hdev, unsigned int evt); void (*notify)(struct hci_dev *hdev, unsigned int evt);
}; };
......
...@@ -2713,9 +2713,7 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2713,9 +2713,7 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
/* Get rid of skb owner, prior to sending to the driver. */ /* Get rid of skb owner, prior to sending to the driver. */
skb_orphan(skb); skb_orphan(skb);
skb->dev = (void *) hdev; if (hdev->send(hdev, skb) < 0)
if (hdev->send(skb) < 0)
BT_ERR("%s sending frame failed", hdev->name); BT_ERR("%s sending frame failed", hdev->name);
} }
......
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