Skip to content

Commit

Permalink
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: bluetooth-next 2015-10-28

Here are a some more Bluetooth patches for 4.4 which collected up during
the past week. The most important ones are from Kuba Pawlak for fixing
locking issues with SCO sockets. There's also a fix from Alexander Aring
for 6lowpan, a memleak fix from Julia Lawall for the btmrvl driver and
some cleanup patches from Marcel.

Please let me know if there are any issues pulling. Thanks.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 30, 2015
2 parents b7b0b1d + 324e786 commit 5bf8921
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 55 deletions.
5 changes: 4 additions & 1 deletion drivers/bluetooth/btmrvl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,17 @@ static int btmrvl_check_device_tree(struct btmrvl_private *priv)
ret = of_property_read_u8_array(dt_node, "btmrvl,cal-data",
cal_data + BT_CAL_HDR_LEN,
BT_CAL_DATA_SIZE);
if (ret)
if (ret) {
of_node_put(dt_node);
return ret;
}

BT_DBG("Use cal data from device tree");
ret = btmrvl_download_cal_data(priv, cal_data,
BT_CAL_DATA_SIZE);
if (ret) {
BT_ERR("Fail to download calibrate data");
of_node_put(dt_node);
return ret;
}
}
Expand Down
14 changes: 7 additions & 7 deletions include/net/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,22 +296,22 @@ typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
u16 opcode, struct sk_buff *skb);

struct req_ctrl {
bool start;
u8 event;
hci_req_complete_t complete;
hci_req_complete_skb_t complete_skb;
struct hci_ctrl {
__u16 opcode;
bool req_start;
u8 req_event;
hci_req_complete_t req_complete;
hci_req_complete_skb_t req_complete_skb;
};

struct bt_skb_cb {
__u8 pkt_type;
__u8 force_active;
__u16 opcode;
__u16 expect;
__u8 incoming:1;
union {
struct l2cap_ctrl l2cap;
struct req_ctrl req;
struct hci_ctrl hci;
};
};
#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
if (!skb_cp)
return NET_RX_DROP;

return netif_rx(skb_cp);
return netif_rx_ni(skb_cp);
}

static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev,
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,

BT_DBG("sock %p sk %p len %zu", sock, sk, len);

if (flags & (MSG_OOB))
if (flags & MSG_OOB)
return -EOPNOTSUPP;

skb = skb_recv_datagram(sk, flags, noblock, &err);
Expand Down
43 changes: 18 additions & 25 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ static DEFINE_IDA(hci_index_ida);
#define hci_req_lock(d) mutex_lock(&d->req_lock)
#define hci_req_unlock(d) mutex_unlock(&d->req_lock)

/* ---- HCI notifications ---- */

static void hci_notify(struct hci_dev *hdev, int event)
{
hci_sock_dev_event(hdev, event);
}

/* ---- HCI debugfs entries ---- */

static ssize_t dut_mode_read(struct file *file, char __user *user_buf,
Expand Down Expand Up @@ -1455,7 +1448,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
}

set_bit(HCI_RUNNING, &hdev->flags);
hci_notify(hdev, HCI_DEV_OPEN);
hci_sock_dev_event(hdev, HCI_DEV_OPEN);

atomic_set(&hdev->cmd_cnt, 1);
set_bit(HCI_INIT, &hdev->flags);
Expand Down Expand Up @@ -1524,7 +1517,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
hci_dev_hold(hdev);
hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
set_bit(HCI_UP, &hdev->flags);
hci_notify(hdev, HCI_DEV_UP);
hci_sock_dev_event(hdev, HCI_DEV_UP);
if (!hci_dev_test_flag(hdev, HCI_SETUP) &&
!hci_dev_test_flag(hdev, HCI_CONFIG) &&
!hci_dev_test_flag(hdev, HCI_UNCONFIGURED) &&
Expand Down Expand Up @@ -1552,7 +1545,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
}

clear_bit(HCI_RUNNING, &hdev->flags);
hci_notify(hdev, HCI_DEV_CLOSE);
hci_sock_dev_event(hdev, HCI_DEV_CLOSE);

hdev->close(hdev);
hdev->flags &= BIT(HCI_RAW);
Expand Down Expand Up @@ -1708,7 +1701,7 @@ int hci_dev_do_close(struct hci_dev *hdev)

smp_unregister(hdev);

hci_notify(hdev, HCI_DEV_DOWN);
hci_sock_dev_event(hdev, HCI_DEV_DOWN);

if (hdev->flush)
hdev->flush(hdev);
Expand Down Expand Up @@ -1739,7 +1732,7 @@ int hci_dev_do_close(struct hci_dev *hdev)
}

clear_bit(HCI_RUNNING, &hdev->flags);
hci_notify(hdev, HCI_DEV_CLOSE);
hci_sock_dev_event(hdev, HCI_DEV_CLOSE);

/* After this point our queues are empty
* and no tasks are scheduled. */
Expand Down Expand Up @@ -3414,7 +3407,7 @@ int hci_register_dev(struct hci_dev *hdev)
if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
hci_dev_set_flag(hdev, HCI_UNCONFIGURED);

hci_notify(hdev, HCI_DEV_REG);
hci_sock_dev_event(hdev, HCI_DEV_REG);
hci_dev_hold(hdev);

queue_work(hdev->req_workqueue, &hdev->power_on);
Expand Down Expand Up @@ -3462,7 +3455,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
* pending list */
BUG_ON(!list_empty(&hdev->mgmt_pending));

hci_notify(hdev, HCI_DEV_UNREG);
hci_sock_dev_event(hdev, HCI_DEV_UNREG);

if (hdev->rfkill) {
rfkill_unregister(hdev->rfkill);
Expand Down Expand Up @@ -3499,15 +3492,15 @@ EXPORT_SYMBOL(hci_unregister_dev);
/* Suspend HCI device */
int hci_suspend_dev(struct hci_dev *hdev)
{
hci_notify(hdev, HCI_DEV_SUSPEND);
hci_sock_dev_event(hdev, HCI_DEV_SUSPEND);
return 0;
}
EXPORT_SYMBOL(hci_suspend_dev);

/* Resume HCI device */
int hci_resume_dev(struct hci_dev *hdev)
{
hci_notify(hdev, HCI_DEV_RESUME);
hci_sock_dev_event(hdev, HCI_DEV_RESUME);
return 0;
}
EXPORT_SYMBOL(hci_resume_dev);
Expand Down Expand Up @@ -3650,7 +3643,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
/* Stand-alone HCI commands must be flagged as
* single-command requests.
*/
bt_cb(skb)->req.start = true;
bt_cb(skb)->hci.req_start = true;

skb_queue_tail(&hdev->cmd_q, skb);
queue_work(hdev->workqueue, &hdev->cmd_work);
Expand Down Expand Up @@ -4347,7 +4340,7 @@ static bool hci_req_is_complete(struct hci_dev *hdev)
if (!skb)
return true;

return bt_cb(skb)->req.start;
return bt_cb(skb)->hci.req_start;
}

static void hci_resend_last(struct hci_dev *hdev)
Expand Down Expand Up @@ -4407,26 +4400,26 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status,
* callback would be found in hdev->sent_cmd instead of the
* command queue (hdev->cmd_q).
*/
if (bt_cb(hdev->sent_cmd)->req.complete) {
*req_complete = bt_cb(hdev->sent_cmd)->req.complete;
if (bt_cb(hdev->sent_cmd)->hci.req_complete) {
*req_complete = bt_cb(hdev->sent_cmd)->hci.req_complete;
return;
}

if (bt_cb(hdev->sent_cmd)->req.complete_skb) {
*req_complete_skb = bt_cb(hdev->sent_cmd)->req.complete_skb;
if (bt_cb(hdev->sent_cmd)->hci.req_complete_skb) {
*req_complete_skb = bt_cb(hdev->sent_cmd)->hci.req_complete_skb;
return;
}

/* Remove all pending commands belonging to this request */
spin_lock_irqsave(&hdev->cmd_q.lock, flags);
while ((skb = __skb_dequeue(&hdev->cmd_q))) {
if (bt_cb(skb)->req.start) {
if (bt_cb(skb)->hci.req_start) {
__skb_queue_head(&hdev->cmd_q, skb);
break;
}

*req_complete = bt_cb(skb)->req.complete;
*req_complete_skb = bt_cb(skb)->req.complete_skb;
*req_complete = bt_cb(skb)->hci.req_complete;
*req_complete_skb = bt_cb(skb)->hci.req_complete_skb;
kfree_skb(skb);
}
spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -3138,7 +3138,7 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb,
* complete event).
*/
if (ev->status ||
(hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->req.event))
(hdev->sent_cmd && !bt_cb(hdev->sent_cmd)->hci.req_event))
hci_req_cmd_complete(hdev, *opcode, ev->status, req_complete,
req_complete_skb);

Expand Down Expand Up @@ -5209,7 +5209,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
u8 status = 0, event = hdr->evt, req_evt = 0;
u16 opcode = HCI_OP_NOP;

if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->req.event == event) {
if (hdev->sent_cmd && bt_cb(hdev->sent_cmd)->hci.req_event == event) {
struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data;
opcode = __le16_to_cpu(cmd_hdr->opcode);
hci_req_cmd_complete(hdev, opcode, status, &req_complete,
Expand Down
10 changes: 5 additions & 5 deletions net/bluetooth/hci_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ static int req_run(struct hci_request *req, hci_req_complete_t complete,
return -ENODATA;

skb = skb_peek_tail(&req->cmd_q);
bt_cb(skb)->req.complete = complete;
bt_cb(skb)->req.complete_skb = complete_skb;
bt_cb(skb)->hci.req_complete = complete;
bt_cb(skb)->hci.req_complete_skb = complete_skb;

spin_lock_irqsave(&hdev->cmd_q.lock, flags);
skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
Expand Down Expand Up @@ -99,7 +99,7 @@ struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,
BT_DBG("skb len %d", skb->len);

bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
bt_cb(skb)->opcode = opcode;
bt_cb(skb)->hci.opcode = opcode;

return skb;
}
Expand Down Expand Up @@ -128,9 +128,9 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
}

if (skb_queue_empty(&req->cmd_q))
bt_cb(skb)->req.start = true;
bt_cb(skb)->hci.req_start = true;

bt_cb(skb)->req.event = event;
bt_cb(skb)->hci.req_event = event;

skb_queue_tail(&req->cmd_q, skb);
}
Expand Down
4 changes: 2 additions & 2 deletions net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,

BT_DBG("sock %p, sk %p", sock, sk);

if (flags & (MSG_OOB))
if (flags & MSG_OOB)
return -EOPNOTSUPP;

if (sk->sk_state == BT_CLOSED)
Expand Down Expand Up @@ -1249,7 +1249,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
/* Stand-alone HCI commands must be flagged as
* single-command requests.
*/
bt_cb(skb)->req.start = true;
bt_cb(skb)->hci.req_start = true;

skb_queue_tail(&hdev->cmd_q, skb);
queue_work(hdev->workqueue, &hdev->cmd_work);
Expand Down
Loading

0 comments on commit 5bf8921

Please sign in to comment.