diff options
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 22 |
1 files changed, 14 insertions, 8 deletions
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; |