Commit 44d27137 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Compress the size of struct hci_ctrl

We can reduce the size of the hci_ctrl struct by converting
'bool req_start' to 'u8 req_flags' and making the two function
pointers a union (since only one is ever set at a time).
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 5fcc86bd
...@@ -296,12 +296,17 @@ typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode); ...@@ -296,12 +296,17 @@ 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, typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
u16 opcode, struct sk_buff *skb); u16 opcode, struct sk_buff *skb);
#define HCI_REQ_START BIT(0)
#define HCI_REQ_SKB BIT(1)
struct hci_ctrl { struct hci_ctrl {
__u16 opcode; __u16 opcode;
bool req_start; u8 req_flags;
u8 req_event; u8 req_event;
hci_req_complete_t req_complete; union {
hci_req_complete_skb_t req_complete_skb; hci_req_complete_t req_complete;
hci_req_complete_skb_t req_complete_skb;
};
}; };
struct bt_skb_cb { struct bt_skb_cb {
......
...@@ -3695,7 +3695,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, ...@@ -3695,7 +3695,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
/* Stand-alone HCI commands must be flagged as /* Stand-alone HCI commands must be flagged as
* single-command requests. * single-command requests.
*/ */
bt_cb(skb)->hci.req_start = true; bt_cb(skb)->hci.req_flags |= HCI_REQ_START;
skb_queue_tail(&hdev->cmd_q, skb); skb_queue_tail(&hdev->cmd_q, skb);
queue_work(hdev->workqueue, &hdev->cmd_work); queue_work(hdev->workqueue, &hdev->cmd_work);
...@@ -4392,7 +4392,7 @@ static bool hci_req_is_complete(struct hci_dev *hdev) ...@@ -4392,7 +4392,7 @@ static bool hci_req_is_complete(struct hci_dev *hdev)
if (!skb) if (!skb)
return true; return true;
return bt_cb(skb)->hci.req_start; return (bt_cb(skb)->hci.req_flags & HCI_REQ_START);
} }
static void hci_resend_last(struct hci_dev *hdev) static void hci_resend_last(struct hci_dev *hdev)
...@@ -4452,20 +4452,20 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status, ...@@ -4452,20 +4452,20 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status,
* callback would be found in hdev->sent_cmd instead of the * callback would be found in hdev->sent_cmd instead of the
* command queue (hdev->cmd_q). * command queue (hdev->cmd_q).
*/ */
if (bt_cb(hdev->sent_cmd)->hci.req_complete) { if (bt_cb(hdev->sent_cmd)->hci.req_flags & HCI_REQ_SKB) {
*req_complete = bt_cb(hdev->sent_cmd)->hci.req_complete; *req_complete_skb = bt_cb(hdev->sent_cmd)->hci.req_complete_skb;
return; return;
} }
if (bt_cb(hdev->sent_cmd)->hci.req_complete_skb) { if (bt_cb(hdev->sent_cmd)->hci.req_complete) {
*req_complete_skb = bt_cb(hdev->sent_cmd)->hci.req_complete_skb; *req_complete = bt_cb(hdev->sent_cmd)->hci.req_complete;
return; return;
} }
/* Remove all pending commands belonging to this request */ /* Remove all pending commands belonging to this request */
spin_lock_irqsave(&hdev->cmd_q.lock, flags); spin_lock_irqsave(&hdev->cmd_q.lock, flags);
while ((skb = __skb_dequeue(&hdev->cmd_q))) { while ((skb = __skb_dequeue(&hdev->cmd_q))) {
if (bt_cb(skb)->hci.req_start) { if (bt_cb(skb)->hci.req_flags & HCI_REQ_START) {
__skb_queue_head(&hdev->cmd_q, skb); __skb_queue_head(&hdev->cmd_q, skb);
break; break;
} }
......
...@@ -56,8 +56,12 @@ static int req_run(struct hci_request *req, hci_req_complete_t complete, ...@@ -56,8 +56,12 @@ static int req_run(struct hci_request *req, hci_req_complete_t complete,
return -ENODATA; return -ENODATA;
skb = skb_peek_tail(&req->cmd_q); skb = skb_peek_tail(&req->cmd_q);
bt_cb(skb)->hci.req_complete = complete; if (complete) {
bt_cb(skb)->hci.req_complete_skb = complete_skb; bt_cb(skb)->hci.req_complete = complete;
} else if (complete_skb) {
bt_cb(skb)->hci.req_complete_skb = complete_skb;
bt_cb(skb)->hci.req_flags |= HCI_REQ_SKB;
}
spin_lock_irqsave(&hdev->cmd_q.lock, flags); spin_lock_irqsave(&hdev->cmd_q.lock, flags);
skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q); skb_queue_splice_tail(&req->cmd_q, &hdev->cmd_q);
...@@ -128,7 +132,7 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, ...@@ -128,7 +132,7 @@ void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
} }
if (skb_queue_empty(&req->cmd_q)) if (skb_queue_empty(&req->cmd_q))
bt_cb(skb)->hci.req_start = true; bt_cb(skb)->hci.req_flags |= HCI_REQ_START;
bt_cb(skb)->hci.req_event = event; bt_cb(skb)->hci.req_event = event;
......
...@@ -1249,7 +1249,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg, ...@@ -1249,7 +1249,7 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
/* Stand-alone HCI commands must be flagged as /* Stand-alone HCI commands must be flagged as
* single-command requests. * single-command requests.
*/ */
bt_cb(skb)->hci.req_start = true; bt_cb(skb)->hci.req_flags |= HCI_REQ_START;
skb_queue_tail(&hdev->cmd_q, skb); skb_queue_tail(&hdev->cmd_q, skb);
queue_work(hdev->workqueue, &hdev->cmd_work); queue_work(hdev->workqueue, &hdev->cmd_work);
......
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