diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-08-08 02:32:52 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-08-14 02:49:18 -0400 |
commit | 711eafe345d993cf4831e890fa989d02c06cad62 (patch) | |
tree | 6a944b71657ef48d8df93441578ca4b2c90e71fd /net/bluetooth | |
parent | 54506918059a5bdbf396f34f2e0a2735803024db (diff) |
Bluetooth: Move SMP (de)initialization to smp.c
As preparation for moving SMP to use l2cap_chan infrastructure we need
to move the (de)initialization functions to smp.c (where they'll
eventually need access to the local L2CAP channel callbacks).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 32 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 26 | ||||
-rw-r--r-- | net/bluetooth/smp.h | 3 |
3 files changed, 31 insertions, 30 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 9eb2869b183b..88575a633601 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1764,34 +1764,6 @@ static void hci_init4_req(struct hci_request *req, unsigned long opt) | |||
1764 | } | 1764 | } |
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | static int hci_register_smp(struct hci_dev *hdev) | ||
1768 | { | ||
1769 | int err; | ||
1770 | |||
1771 | BT_DBG("%s", hdev->name); | ||
1772 | |||
1773 | hdev->tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, | ||
1774 | CRYPTO_ALG_ASYNC); | ||
1775 | if (IS_ERR(hdev->tfm_aes)) { | ||
1776 | BT_ERR("Unable to create crypto context"); | ||
1777 | err = PTR_ERR(hdev->tfm_aes); | ||
1778 | hdev->tfm_aes = NULL; | ||
1779 | return err; | ||
1780 | } | ||
1781 | |||
1782 | return 0; | ||
1783 | } | ||
1784 | |||
1785 | static void hci_unregister_smp(struct hci_dev *hdev) | ||
1786 | { | ||
1787 | BT_DBG("%s", hdev->name); | ||
1788 | |||
1789 | if (hdev->tfm_aes) { | ||
1790 | crypto_free_blkcipher(hdev->tfm_aes); | ||
1791 | hdev->tfm_aes = NULL; | ||
1792 | } | ||
1793 | } | ||
1794 | |||
1795 | static int __hci_init(struct hci_dev *hdev) | 1767 | static int __hci_init(struct hci_dev *hdev) |
1796 | { | 1768 | { |
1797 | int err; | 1769 | int err; |
@@ -1927,7 +1899,7 @@ static int __hci_init(struct hci_dev *hdev) | |||
1927 | hdev->debugfs, | 1899 | hdev->debugfs, |
1928 | &hdev->discov_interleaved_timeout); | 1900 | &hdev->discov_interleaved_timeout); |
1929 | 1901 | ||
1930 | hci_register_smp(hdev); | 1902 | smp_register(hdev); |
1931 | } | 1903 | } |
1932 | 1904 | ||
1933 | return 0; | 1905 | return 0; |
@@ -4224,7 +4196,7 @@ void hci_unregister_dev(struct hci_dev *hdev) | |||
4224 | rfkill_destroy(hdev->rfkill); | 4196 | rfkill_destroy(hdev->rfkill); |
4225 | } | 4197 | } |
4226 | 4198 | ||
4227 | hci_unregister_smp(hdev); | 4199 | smp_unregister(hdev); |
4228 | 4200 | ||
4229 | device_del(&hdev->dev); | 4201 | device_del(&hdev->dev); |
4230 | 4202 | ||
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 33016ec9b247..ab07649ecc77 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -1455,3 +1455,29 @@ int smp_distribute_keys(struct l2cap_conn *conn) | |||
1455 | 1455 | ||
1456 | return 0; | 1456 | return 0; |
1457 | } | 1457 | } |
1458 | |||
1459 | int smp_register(struct hci_dev *hdev) | ||
1460 | { | ||
1461 | BT_DBG("%s", hdev->name); | ||
1462 | |||
1463 | hdev->tfm_aes = crypto_alloc_blkcipher("ecb(aes)", 0, | ||
1464 | CRYPTO_ALG_ASYNC); | ||
1465 | if (IS_ERR(hdev->tfm_aes)) { | ||
1466 | int err = PTR_ERR(hdev->tfm_aes); | ||
1467 | BT_ERR("Unable to create crypto context"); | ||
1468 | hdev->tfm_aes = NULL; | ||
1469 | return err; | ||
1470 | } | ||
1471 | |||
1472 | return 0; | ||
1473 | } | ||
1474 | |||
1475 | void smp_unregister(struct hci_dev *hdev) | ||
1476 | { | ||
1477 | BT_DBG("%s", hdev->name); | ||
1478 | |||
1479 | if (hdev->tfm_aes) { | ||
1480 | crypto_free_blkcipher(hdev->tfm_aes); | ||
1481 | hdev->tfm_aes = NULL; | ||
1482 | } | ||
1483 | } | ||
diff --git a/net/bluetooth/smp.h b/net/bluetooth/smp.h index 796f4f45f92f..6e29359f60a3 100644 --- a/net/bluetooth/smp.h +++ b/net/bluetooth/smp.h | |||
@@ -136,4 +136,7 @@ bool smp_irk_matches(struct crypto_blkcipher *tfm, u8 irk[16], | |||
136 | bdaddr_t *bdaddr); | 136 | bdaddr_t *bdaddr); |
137 | int smp_generate_rpa(struct crypto_blkcipher *tfm, u8 irk[16], bdaddr_t *rpa); | 137 | int smp_generate_rpa(struct crypto_blkcipher *tfm, u8 irk[16], bdaddr_t *rpa); |
138 | 138 | ||
139 | int smp_register(struct hci_dev *hdev); | ||
140 | void smp_unregister(struct hci_dev *hdev); | ||
141 | |||
139 | #endif /* __SMP_H */ | 142 | #endif /* __SMP_H */ |