aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bluetooth/smp.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 72743f87b22f..efb73fdf710d 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -60,8 +60,6 @@ struct smp_chan {
60 struct smp_ltk *slave_ltk; 60 struct smp_ltk *slave_ltk;
61 struct smp_irk *remote_irk; 61 struct smp_irk *remote_irk;
62 unsigned long smp_flags; 62 unsigned long smp_flags;
63 struct work_struct confirm;
64 struct work_struct random;
65}; 63};
66 64
67static inline void swap128(const u8 src[16], u8 dst[16]) 65static inline void swap128(const u8 src[16], u8 dst[16])
@@ -470,9 +468,8 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
470 return ret; 468 return ret;
471} 469}
472 470
473static void confirm_work(struct work_struct *work) 471static void smp_confirm(struct smp_chan *smp)
474{ 472{
475 struct smp_chan *smp = container_of(work, struct smp_chan, confirm);
476 struct l2cap_conn *conn = smp->conn; 473 struct l2cap_conn *conn = smp->conn;
477 struct hci_dev *hdev = conn->hcon->hdev; 474 struct hci_dev *hdev = conn->hcon->hdev;
478 struct crypto_blkcipher *tfm = hdev->tfm_aes; 475 struct crypto_blkcipher *tfm = hdev->tfm_aes;
@@ -507,9 +504,8 @@ error:
507 smp_failure(conn, reason); 504 smp_failure(conn, reason);
508} 505}
509 506
510static void random_work(struct work_struct *work) 507static void smp_random(struct smp_chan *smp)
511{ 508{
512 struct smp_chan *smp = container_of(work, struct smp_chan, random);
513 struct l2cap_conn *conn = smp->conn; 509 struct l2cap_conn *conn = smp->conn;
514 struct hci_conn *hcon = conn->hcon; 510 struct hci_conn *hcon = conn->hcon;
515 struct hci_dev *hdev = hcon->hdev; 511 struct hci_dev *hdev = hcon->hdev;
@@ -593,9 +589,6 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn)
593 if (!smp) 589 if (!smp)
594 return NULL; 590 return NULL;
595 591
596 INIT_WORK(&smp->confirm, confirm_work);
597 INIT_WORK(&smp->random, random_work);
598
599 smp->conn = conn; 592 smp->conn = conn;
600 conn->smp_chan = smp; 593 conn->smp_chan = smp;
601 conn->hcon->smp_conn = conn; 594 conn->hcon->smp_conn = conn;
@@ -676,7 +669,7 @@ int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey)
676 669
677 /* If it is our turn to send Pairing Confirm, do so now */ 670 /* If it is our turn to send Pairing Confirm, do so now */
678 if (test_bit(SMP_FLAG_CFM_PENDING, &smp->smp_flags)) 671 if (test_bit(SMP_FLAG_CFM_PENDING, &smp->smp_flags))
679 queue_work(hcon->hdev->workqueue, &smp->confirm); 672 smp_confirm(smp);
680 673
681 return 0; 674 return 0;
682} 675}
@@ -740,7 +733,6 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
740{ 733{
741 struct smp_cmd_pairing *req, *rsp = (void *) skb->data; 734 struct smp_cmd_pairing *req, *rsp = (void *) skb->data;
742 struct smp_chan *smp = conn->smp_chan; 735 struct smp_chan *smp = conn->smp_chan;
743 struct hci_dev *hdev = conn->hcon->hdev;
744 u8 key_size, auth = SMP_AUTH_NONE; 736 u8 key_size, auth = SMP_AUTH_NONE;
745 int ret; 737 int ret;
746 738
@@ -784,7 +776,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
784 776
785 /* Can't compose response until we have been confirmed */ 777 /* Can't compose response until we have been confirmed */
786 if (test_bit(SMP_FLAG_TK_VALID, &smp->smp_flags)) 778 if (test_bit(SMP_FLAG_TK_VALID, &smp->smp_flags))
787 queue_work(hdev->workqueue, &smp->confirm); 779 smp_confirm(smp);
788 780
789 return 0; 781 return 0;
790} 782}
@@ -792,7 +784,6 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
792static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) 784static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
793{ 785{
794 struct smp_chan *smp = conn->smp_chan; 786 struct smp_chan *smp = conn->smp_chan;
795 struct hci_dev *hdev = conn->hcon->hdev;
796 787
797 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); 788 BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
798 789
@@ -806,7 +797,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
806 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), 797 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd),
807 smp->prnd); 798 smp->prnd);
808 else if (test_bit(SMP_FLAG_TK_VALID, &smp->smp_flags)) 799 else if (test_bit(SMP_FLAG_TK_VALID, &smp->smp_flags))
809 queue_work(hdev->workqueue, &smp->confirm); 800 smp_confirm(smp);
810 else 801 else
811 set_bit(SMP_FLAG_CFM_PENDING, &smp->smp_flags); 802 set_bit(SMP_FLAG_CFM_PENDING, &smp->smp_flags);
812 803
@@ -816,7 +807,6 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
816static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) 807static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
817{ 808{
818 struct smp_chan *smp = conn->smp_chan; 809 struct smp_chan *smp = conn->smp_chan;
819 struct hci_dev *hdev = conn->hcon->hdev;
820 810
821 BT_DBG("conn %p", conn); 811 BT_DBG("conn %p", conn);
822 812
@@ -826,7 +816,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
826 memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); 816 memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd));
827 skb_pull(skb, sizeof(smp->rrnd)); 817 skb_pull(skb, sizeof(smp->rrnd));
828 818
829 queue_work(hdev->workqueue, &smp->random); 819 smp_random(smp);
830 820
831 return 0; 821 return 0;
832} 822}