diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-03-02 17:19:06 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-03-02 18:28:47 -0500 |
commit | 2b4bf3974249da74f4aef1e9180d4beaf6332515 (patch) | |
tree | d6b32d4c9fbebd723963cb24475b2cd6630be133 /net | |
parent | 4f87da80a5210e66fb47b0e839f4d05016986f78 (diff) |
Bluetooth: mgmt: Fix updating local name when powering on
When powering on we need to apply whatever name has been set through
mgmt_set_local_name. The appropriate place for this is mgmt_powered()
and not hci_setup() since this needs to be applied also if the HCI init
sequence was already completed but the adapter was still "powered off"
from a mgmt perspective due the the HCI_AUTO_OFF still being set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_event.c | 8 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 22 |
2 files changed, 14 insertions, 16 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d6c41bbfe759..6a817daf095b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -552,14 +552,6 @@ static void hci_setup(struct hci_dev *hdev) | |||
552 | if (hdev->hci_ver > BLUETOOTH_VER_1_1) | 552 | if (hdev->hci_ver > BLUETOOTH_VER_1_1) |
553 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); | 553 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL); |
554 | 554 | ||
555 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | ||
556 | test_bit(HCI_MGMT, &hdev->dev_flags)) { | ||
557 | struct hci_cp_write_local_name cp; | ||
558 | |||
559 | memcpy(cp.name, hdev->dev_name, sizeof(cp.name)); | ||
560 | hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp); | ||
561 | } | ||
562 | |||
563 | if (hdev->features[6] & LMP_SIMPLE_PAIR) { | 555 | if (hdev->features[6] & LMP_SIMPLE_PAIR) { |
564 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | 556 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { |
565 | u8 mode = 0x01; | 557 | u8 mode = 0x01; |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4b1efedc18c5..4ca009268afb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2104,11 +2104,19 @@ static int user_passkey_neg_reply(struct sock *sk, struct hci_dev *hdev, | |||
2104 | HCI_OP_USER_PASSKEY_NEG_REPLY, 0); | 2104 | HCI_OP_USER_PASSKEY_NEG_REPLY, 0); |
2105 | } | 2105 | } |
2106 | 2106 | ||
2107 | static int update_name(struct hci_dev *hdev, const char *name) | ||
2108 | { | ||
2109 | struct hci_cp_write_local_name cp; | ||
2110 | |||
2111 | memcpy(cp.name, name, sizeof(cp.name)); | ||
2112 | |||
2113 | return hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(cp), &cp); | ||
2114 | } | ||
2115 | |||
2107 | static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, | 2116 | static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, |
2108 | u16 len) | 2117 | u16 len) |
2109 | { | 2118 | { |
2110 | struct mgmt_cp_set_local_name *mgmt_cp = data; | 2119 | struct mgmt_cp_set_local_name *cp = data; |
2111 | struct hci_cp_write_local_name hci_cp; | ||
2112 | struct pending_cmd *cmd; | 2120 | struct pending_cmd *cmd; |
2113 | int err; | 2121 | int err; |
2114 | 2122 | ||
@@ -2116,11 +2124,10 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, | |||
2116 | 2124 | ||
2117 | hci_dev_lock(hdev); | 2125 | hci_dev_lock(hdev); |
2118 | 2126 | ||
2119 | memcpy(hdev->short_name, mgmt_cp->short_name, | 2127 | memcpy(hdev->short_name, cp->short_name, sizeof(hdev->short_name)); |
2120 | sizeof(hdev->short_name)); | ||
2121 | 2128 | ||
2122 | if (!hdev_is_powered(hdev)) { | 2129 | if (!hdev_is_powered(hdev)) { |
2123 | memcpy(hdev->dev_name, mgmt_cp->name, sizeof(hdev->dev_name)); | 2130 | memcpy(hdev->dev_name, cp->name, sizeof(hdev->dev_name)); |
2124 | 2131 | ||
2125 | err = cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, | 2132 | err = cmd_complete(sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, |
2126 | data, len); | 2133 | data, len); |
@@ -2139,9 +2146,7 @@ static int set_local_name(struct sock *sk, struct hci_dev *hdev, void *data, | |||
2139 | goto failed; | 2146 | goto failed; |
2140 | } | 2147 | } |
2141 | 2148 | ||
2142 | memcpy(hci_cp.name, mgmt_cp->name, sizeof(hci_cp.name)); | 2149 | err = update_name(hdev, cp->name); |
2143 | err = hci_send_cmd(hdev, HCI_OP_WRITE_LOCAL_NAME, sizeof(hci_cp), | ||
2144 | &hci_cp); | ||
2145 | if (err < 0) | 2150 | if (err < 0) |
2146 | mgmt_pending_remove(cmd); | 2151 | mgmt_pending_remove(cmd); |
2147 | 2152 | ||
@@ -2794,6 +2799,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) | |||
2794 | hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); | 2799 | hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); |
2795 | 2800 | ||
2796 | update_class(hdev); | 2801 | update_class(hdev); |
2802 | update_name(hdev, hdev->dev_name); | ||
2797 | update_eir(hdev); | 2803 | update_eir(hdev); |
2798 | } else { | 2804 | } else { |
2799 | u8 status = MGMT_STATUS_NOT_POWERED; | 2805 | u8 status = MGMT_STATUS_NOT_POWERED; |