Bluetooth: Rename cmd_status() to mgmt_cmd_status()

This patch renames the cmd_status() function to mgmt_cmd_status() in
preparation of making it a generic helper for other modules to use too.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
Johan Hedberg 2015-03-06 21:08:53 +02:00 коммит произвёл Marcel Holtmann
Родитель b9a245fb12
Коммит a69e8375a1
1 изменённых файлов: 230 добавлений и 229 удалений

Просмотреть файл

@ -249,7 +249,7 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 data_len,
return 0; return 0;
} }
static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) static int mgmt_cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status)
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct mgmt_hdr *hdr; struct mgmt_hdr *hdr;
@ -1396,13 +1396,13 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_POWERED,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
@ -1492,7 +1492,7 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
{ {
u8 *status = data; u8 *status = data;
cmd_status(cmd->sk, cmd->index, cmd->opcode, *status); mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
} }
@ -1560,7 +1560,7 @@ static void set_discoverable_complete(struct hci_dev *hdev, u8 status,
if (status) { if (status) {
u8 mgmt_err = mgmt_status(status); u8 mgmt_err = mgmt_status(status);
cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags); clear_bit(HCI_LIMITED_DISCOVERABLE, &hdev->dev_flags);
goto remove_cmd; goto remove_cmd;
} }
@ -1616,11 +1616,11 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) && if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) &&
!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
timeout = __le16_to_cpu(cp->timeout); timeout = __le16_to_cpu(cp->timeout);
@ -1630,26 +1630,26 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
*/ */
if ((cp->val == 0x00 && timeout > 0) || if ((cp->val == 0x00 && timeout > 0) ||
(cp->val == 0x02 && timeout == 0)) (cp->val == 0x02 && timeout == 0))
return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!hdev_is_powered(hdev) && timeout > 0) { if (!hdev_is_powered(hdev) && timeout > 0) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_NOT_POWERED); MGMT_STATUS_NOT_POWERED);
goto failed; goto failed;
} }
if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) ||
mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) { if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
goto failed; goto failed;
} }
@ -1819,7 +1819,7 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status,
if (status) { if (status) {
u8 mgmt_err = mgmt_status(status); u8 mgmt_err = mgmt_status(status);
cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
goto remove_cmd; goto remove_cmd;
} }
@ -1894,11 +1894,11 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) && if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags) &&
!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -1910,7 +1910,7 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) ||
mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
@ -1996,7 +1996,7 @@ static int set_bondable(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_BONDABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BONDABLE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -2030,11 +2030,11 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
status = mgmt_bredr_support(hdev); status = mgmt_bredr_support(hdev);
if (status) if (status)
return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
status); status);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -2059,7 +2059,7 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data,
} }
if (mgmt_pending_find(MGMT_OP_SET_LINK_SECURITY, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_LINK_SECURITY, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
@ -2099,14 +2099,14 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
status = mgmt_bredr_support(hdev); status = mgmt_bredr_support(hdev);
if (status) if (status)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, status); return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, status);
if (!lmp_ssp_capable(hdev)) if (!lmp_ssp_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -2138,7 +2138,7 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
} }
if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
@ -2180,24 +2180,24 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
status = mgmt_bredr_support(hdev); status = mgmt_bredr_support(hdev);
if (status) if (status)
return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, status); return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS, status);
if (!lmp_ssp_capable(hdev)) if (!lmp_ssp_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_HS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_HS, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -2206,7 +2206,7 @@ static int set_hs(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
changed = !test_and_set_bit(HCI_HS_ENABLED, &hdev->dev_flags); changed = !test_and_set_bit(HCI_HS_ENABLED, &hdev->dev_flags);
} else { } else {
if (hdev_is_powered(hdev)) { if (hdev_is_powered(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_HS, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_HS,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
goto unlock; goto unlock;
} }
@ -2278,16 +2278,16 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_LE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_LE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
/* LE-only devices do not allow toggling LE on/off */ /* LE-only devices do not allow toggling LE on/off */
if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags)) if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_LE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -2320,7 +2320,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
if (mgmt_pending_find(MGMT_OP_SET_LE, hdev) || if (mgmt_pending_find(MGMT_OP_SET_LE, hdev) ||
mgmt_pending_find(MGMT_OP_SET_ADVERTISING, hdev)) { mgmt_pending_find(MGMT_OP_SET_ADVERTISING, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -2436,7 +2436,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (pending_eir_or_class(hdev)) { if (pending_eir_or_class(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_UUID,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
@ -2517,7 +2517,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (pending_eir_or_class(hdev)) { if (pending_eir_or_class(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -2546,7 +2546,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
} }
if (found == 0) { if (found == 0) {
err = cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_REMOVE_UUID,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
goto unlock; goto unlock;
} }
@ -2598,19 +2598,19 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_bredr_capable(hdev)) if (!lmp_bredr_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (pending_eir_or_class(hdev)) { if (pending_eir_or_class(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0) { if ((cp->minor & 0x03) != 0 || (cp->major & 0xe0) != 0) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEV_CLASS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
goto unlock; goto unlock;
} }
@ -2671,14 +2671,14 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_bredr_capable(hdev)) if (!lmp_bredr_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
key_count = __le16_to_cpu(cp->key_count); key_count = __le16_to_cpu(cp->key_count);
if (key_count > max_key_count) { if (key_count > max_key_count) {
BT_ERR("load_link_keys: too big key_count value %u", BT_ERR("load_link_keys: too big key_count value %u",
key_count); key_count);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -2687,12 +2687,12 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_link_keys: expected %u bytes, got %u bytes", BT_ERR("load_link_keys: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
if (cp->debug_keys != 0x00 && cp->debug_keys != 0x01) if (cp->debug_keys != 0x00 && cp->debug_keys != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
BT_DBG("%s debug_keys %u key_count %u", hdev->name, cp->debug_keys, BT_DBG("%s debug_keys %u key_count %u", hdev->name, cp->debug_keys,
@ -2702,7 +2702,8 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
struct mgmt_link_key_info *key = &cp->keys[i]; struct mgmt_link_key_info *key = &cp->keys[i];
if (key->addr.type != BDADDR_BREDR || key->type > 0x08) if (key->addr.type != BDADDR_BREDR || key->type > 0x08)
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LINK_KEYS, return mgmt_cmd_status(sk, hdev->id,
MGMT_OP_LOAD_LINK_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -2961,7 +2962,7 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data,
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!hdev_is_powered(hdev)) { if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_GET_CONNECTIONS, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_CONNECTIONS,
MGMT_STATUS_NOT_POWERED); MGMT_STATUS_NOT_POWERED);
goto unlock; goto unlock;
} }
@ -3038,14 +3039,14 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data,
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!hdev_is_powered(hdev)) { if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY,
MGMT_STATUS_NOT_POWERED); MGMT_STATUS_NOT_POWERED);
goto failed; goto failed;
} }
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr); conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr);
if (!conn) { if (!conn) {
err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY,
MGMT_STATUS_NOT_CONNECTED); MGMT_STATUS_NOT_CONNECTED);
goto failed; goto failed;
} }
@ -3059,7 +3060,7 @@ static int pin_code_reply(struct sock *sk, struct hci_dev *hdev, void *data,
err = send_pin_code_neg_reply(sk, hdev, &ncp); err = send_pin_code_neg_reply(sk, hdev, &ncp);
if (err >= 0) if (err >= 0)
err = cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_PIN_CODE_REPLY,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
goto failed; goto failed;
@ -3344,14 +3345,14 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!hdev_is_powered(hdev)) { if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE,
MGMT_STATUS_NOT_POWERED); MGMT_STATUS_NOT_POWERED);
goto unlock; goto unlock;
} }
cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev); cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev);
if (!cmd) { if (!cmd) {
err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
goto unlock; goto unlock;
} }
@ -3359,7 +3360,7 @@ static int cancel_pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
conn = cmd->user_data; conn = cmd->user_data;
if (bacmp(&addr->bdaddr, &conn->dst) != 0) { if (bacmp(&addr->bdaddr, &conn->dst) != 0) {
err = cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_CANCEL_PAIR_DEVICE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
goto unlock; goto unlock;
} }
@ -3464,7 +3465,7 @@ static int user_confirm_reply(struct sock *sk, struct hci_dev *hdev, void *data,
BT_DBG(""); BT_DBG("");
if (len != sizeof(*cp)) if (len != sizeof(*cp))
return cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_REPLY, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_USER_CONFIRM_REPLY,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
return user_pairing_resp(sk, hdev, &cp->addr, return user_pairing_resp(sk, hdev, &cp->addr,
@ -3534,7 +3535,7 @@ static void set_name_complete(struct hci_dev *hdev, u8 status, u16 opcode)
cp = cmd->param; cp = cmd->param;
if (status) if (status)
cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME,
mgmt_status(status)); mgmt_status(status));
else else
cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0, cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 0,
@ -3626,19 +3627,19 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev,
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!hdev_is_powered(hdev)) { if (!hdev_is_powered(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA,
MGMT_STATUS_NOT_POWERED); MGMT_STATUS_NOT_POWERED);
goto unlock; goto unlock;
} }
if (!lmp_ssp_capable(hdev)) { if (!lmp_ssp_capable(hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
goto unlock; goto unlock;
} }
if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev)) { if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -3758,7 +3759,7 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
status, &cp->addr, sizeof(cp->addr)); status, &cp->addr, sizeof(cp->addr));
} else { } else {
BT_ERR("add_remote_oob_data: invalid length of %u bytes", len); BT_ERR("add_remote_oob_data: invalid length of %u bytes", len);
err = cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -4352,7 +4353,7 @@ static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
source = __le16_to_cpu(cp->source); source = __le16_to_cpu(cp->source);
if (source > 0x0002) if (source > 0x0002)
return cmd_status(sk, hdev->id, MGMT_OP_SET_DEVICE_ID, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEVICE_ID,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -4418,11 +4419,11 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data,
status = mgmt_le_support(hdev); status = mgmt_le_support(hdev);
if (status) if (status)
return cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
status); status);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -4458,7 +4459,7 @@ static int set_advertising(struct sock *sk, struct hci_dev *hdev, void *data,
if (mgmt_pending_find(MGMT_OP_SET_ADVERTISING, hdev) || if (mgmt_pending_find(MGMT_OP_SET_ADVERTISING, hdev) ||
mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { mgmt_pending_find(MGMT_OP_SET_LE, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -4494,22 +4495,22 @@ static int set_static_address(struct sock *sk, struct hci_dev *hdev,
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (hdev_is_powered(hdev)) if (hdev_is_powered(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (bacmp(&cp->bdaddr, BDADDR_ANY)) { if (bacmp(&cp->bdaddr, BDADDR_ANY)) {
if (!bacmp(&cp->bdaddr, BDADDR_NONE)) if (!bacmp(&cp->bdaddr, BDADDR_NONE))
return cmd_status(sk, hdev->id, return mgmt_cmd_status(sk, hdev->id,
MGMT_OP_SET_STATIC_ADDRESS, MGMT_OP_SET_STATIC_ADDRESS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
/* Two most significant bits shall be set */ /* Two most significant bits shall be set */
if ((cp->bdaddr.b[5] & 0xc0) != 0xc0) if ((cp->bdaddr.b[5] & 0xc0) != 0xc0)
return cmd_status(sk, hdev->id, return mgmt_cmd_status(sk, hdev->id,
MGMT_OP_SET_STATIC_ADDRESS, MGMT_OP_SET_STATIC_ADDRESS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -4539,23 +4540,23 @@ static int set_scan_params(struct sock *sk, struct hci_dev *hdev,
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
interval = __le16_to_cpu(cp->interval); interval = __le16_to_cpu(cp->interval);
if (interval < 0x0004 || interval > 0x4000) if (interval < 0x0004 || interval > 0x4000)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
window = __le16_to_cpu(cp->window); window = __le16_to_cpu(cp->window);
if (window < 0x0004 || window > 0x4000) if (window < 0x0004 || window > 0x4000)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
if (window > interval) if (window > interval)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SCAN_PARAMS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -4599,7 +4600,7 @@ static void fast_connectable_complete(struct hci_dev *hdev, u8 status,
goto unlock; goto unlock;
if (status) { if (status) {
cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
mgmt_status(status)); mgmt_status(status));
} else { } else {
struct mgmt_mode *cp = cmd->param; struct mgmt_mode *cp = cmd->param;
@ -4631,25 +4632,25 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) || if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) ||
hdev->hci_ver < BLUETOOTH_VER_1_2) hdev->hci_ver < BLUETOOTH_VER_1_2)
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
if (!hdev_is_powered(hdev)) if (!hdev_is_powered(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_NOT_POWERED); MGMT_STATUS_NOT_POWERED);
if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (mgmt_pending_find(MGMT_OP_SET_FAST_CONNECTABLE, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_FAST_CONNECTABLE, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -4673,7 +4674,7 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
err = hci_req_run(&req, fast_connectable_complete); err = hci_req_run(&req, fast_connectable_complete);
if (err < 0) { if (err < 0) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
MGMT_STATUS_FAILED); MGMT_STATUS_FAILED);
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
} }
@ -4704,7 +4705,7 @@ static void set_bredr_complete(struct hci_dev *hdev, u8 status, u16 opcode)
*/ */
clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags); clear_bit(HCI_BREDR_ENABLED, &hdev->dev_flags);
cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err); mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_err);
} else { } else {
send_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev); send_settings_rsp(cmd->sk, MGMT_OP_SET_BREDR, hdev);
new_settings(hdev, cmd->sk); new_settings(hdev, cmd->sk);
@ -4726,15 +4727,15 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_bredr_capable(hdev) || !lmp_le_capable(hdev)) if (!lmp_bredr_capable(hdev) || !lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01) if (cp->val != 0x00 && cp->val != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -4765,7 +4766,7 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
/* Reject disabling when powered on */ /* Reject disabling when powered on */
if (!cp->val) { if (!cp->val) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
goto unlock; goto unlock;
} else { } else {
@ -4786,14 +4787,14 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) &&
(bacmp(&hdev->static_addr, BDADDR_ANY) || (bacmp(&hdev->static_addr, BDADDR_ANY) ||
test_bit(HCI_SC_ENABLED, &hdev->dev_flags))) { test_bit(HCI_SC_ENABLED, &hdev->dev_flags))) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
goto unlock; goto unlock;
} }
} }
if (mgmt_pending_find(MGMT_OP_SET_BREDR, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_BREDR, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_BREDR,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto unlock; goto unlock;
} }
@ -4842,7 +4843,7 @@ static void sc_enable_complete(struct hci_dev *hdev, u8 status, u16 opcode)
goto unlock; goto unlock;
if (status) { if (status) {
cmd_status(cmd->sk, cmd->index, cmd->opcode, mgmt_cmd_status(cmd->sk, cmd->index, cmd->opcode,
mgmt_status(status)); mgmt_status(status));
goto remove; goto remove;
} }
@ -4886,17 +4887,17 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
if (!lmp_sc_capable(hdev) && if (!lmp_sc_capable(hdev) &&
!test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) !test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) && if (test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) &&
lmp_sc_capable(hdev) && lmp_sc_capable(hdev) &&
!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) !test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -4929,7 +4930,7 @@ static int set_secure_conn(struct sock *sk, struct hci_dev *hdev,
} }
if (mgmt_pending_find(MGMT_OP_SET_SECURE_CONN, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_SECURE_CONN, hdev)) {
err = cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN, err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_SECURE_CONN,
MGMT_STATUS_BUSY); MGMT_STATUS_BUSY);
goto failed; goto failed;
} }
@ -4971,7 +4972,7 @@ static int set_debug_keys(struct sock *sk, struct hci_dev *hdev,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02) if (cp->val != 0x00 && cp->val != 0x01 && cp->val != 0x02)
return cmd_status(sk, hdev->id, MGMT_OP_SET_DEBUG_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEBUG_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -5019,15 +5020,15 @@ static int set_privacy(struct sock *sk, struct hci_dev *hdev, void *cp_data,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
if (cp->privacy != 0x00 && cp->privacy != 0x01) if (cp->privacy != 0x00 && cp->privacy != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
if (hdev_is_powered(hdev)) if (hdev_is_powered(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PRIVACY,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -5087,13 +5088,13 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
irk_count = __le16_to_cpu(cp->irk_count); irk_count = __le16_to_cpu(cp->irk_count);
if (irk_count > max_irk_count) { if (irk_count > max_irk_count) {
BT_ERR("load_irks: too big irk_count value %u", irk_count); BT_ERR("load_irks: too big irk_count value %u", irk_count);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5101,7 +5102,7 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_irks: expected %u bytes, got %u bytes", BT_ERR("load_irks: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_IRKS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5111,7 +5112,7 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
struct mgmt_irk_info *key = &cp->irks[i]; struct mgmt_irk_info *key = &cp->irks[i];
if (!irk_is_valid(key)) if (!irk_is_valid(key))
return cmd_status(sk, hdev->id, return mgmt_cmd_status(sk, hdev->id,
MGMT_OP_LOAD_IRKS, MGMT_OP_LOAD_IRKS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5173,13 +5174,13 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
BT_DBG("request for %s", hdev->name); BT_DBG("request for %s", hdev->name);
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
key_count = __le16_to_cpu(cp->key_count); key_count = __le16_to_cpu(cp->key_count);
if (key_count > max_key_count) { if (key_count > max_key_count) {
BT_ERR("load_ltks: too big key_count value %u", key_count); BT_ERR("load_ltks: too big key_count value %u", key_count);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5188,7 +5189,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_keys: expected %u bytes, got %u bytes", BT_ERR("load_keys: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5198,7 +5199,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
struct mgmt_ltk_info *key = &cp->keys[i]; struct mgmt_ltk_info *key = &cp->keys[i];
if (!ltk_is_valid(key)) if (!ltk_is_valid(key))
return cmd_status(sk, hdev->id, return mgmt_cmd_status(sk, hdev->id,
MGMT_OP_LOAD_LONG_TERM_KEYS, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5945,14 +5946,14 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
int i; int i;
if (!lmp_le_capable(hdev)) if (!lmp_le_capable(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
param_count = __le16_to_cpu(cp->param_count); param_count = __le16_to_cpu(cp->param_count);
if (param_count > max_param_count) { if (param_count > max_param_count) {
BT_ERR("load_conn_param: too big param_count value %u", BT_ERR("load_conn_param: too big param_count value %u",
param_count); param_count);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -5961,7 +5962,7 @@ static int load_conn_param(struct sock *sk, struct hci_dev *hdev, void *data,
if (expected_len != len) { if (expected_len != len) {
BT_ERR("load_conn_param: expected %u bytes, got %u bytes", BT_ERR("load_conn_param: expected %u bytes, got %u bytes",
expected_len, len); expected_len, len);
return cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_LOAD_CONN_PARAM,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
} }
@ -6030,15 +6031,15 @@ static int set_external_config(struct sock *sk, struct hci_dev *hdev,
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
if (hdev_is_powered(hdev)) if (hdev_is_powered(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (cp->config != 0x00 && cp->config != 0x01) if (cp->config != 0x00 && cp->config != 0x01)
return cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
if (!test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks)) if (!test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks))
return cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_EXTERNAL_CONFIG,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -6088,15 +6089,15 @@ static int set_public_address(struct sock *sk, struct hci_dev *hdev,
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
if (hdev_is_powered(hdev)) if (hdev_is_powered(hdev))
return cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS,
MGMT_STATUS_REJECTED); MGMT_STATUS_REJECTED);
if (!bacmp(&cp->bdaddr, BDADDR_ANY)) if (!bacmp(&cp->bdaddr, BDADDR_ANY))
return cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
if (!hdev->set_bdaddr) if (!hdev->set_bdaddr)
return cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS, return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_PUBLIC_ADDRESS,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
hci_dev_lock(hdev); hci_dev_lock(hdev);
@ -6244,7 +6245,7 @@ int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk,
if (opcode >= chan->handler_count || if (opcode >= chan->handler_count ||
chan->handlers[opcode].func == NULL) { chan->handlers[opcode].func == NULL) {
BT_DBG("Unknown op %u", opcode); BT_DBG("Unknown op %u", opcode);
err = cmd_status(sk, index, opcode, err = mgmt_cmd_status(sk, index, opcode,
MGMT_STATUS_UNKNOWN_COMMAND); MGMT_STATUS_UNKNOWN_COMMAND);
goto done; goto done;
} }
@ -6254,7 +6255,7 @@ int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk,
if (index != MGMT_INDEX_NONE) { if (index != MGMT_INDEX_NONE) {
hdev = hci_dev_get(index); hdev = hci_dev_get(index);
if (!hdev) { if (!hdev) {
err = cmd_status(sk, index, opcode, err = mgmt_cmd_status(sk, index, opcode,
MGMT_STATUS_INVALID_INDEX); MGMT_STATUS_INVALID_INDEX);
goto done; goto done;
} }
@ -6262,14 +6263,14 @@ int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk,
if (test_bit(HCI_SETUP, &hdev->dev_flags) || if (test_bit(HCI_SETUP, &hdev->dev_flags) ||
test_bit(HCI_CONFIG, &hdev->dev_flags) || test_bit(HCI_CONFIG, &hdev->dev_flags) ||
test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) { test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
err = cmd_status(sk, index, opcode, err = mgmt_cmd_status(sk, index, opcode,
MGMT_STATUS_INVALID_INDEX); MGMT_STATUS_INVALID_INDEX);
goto done; goto done;
} }
if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) && if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags) &&
!(handler->flags & HCI_MGMT_UNCONFIGURED)) { !(handler->flags & HCI_MGMT_UNCONFIGURED)) {
err = cmd_status(sk, index, opcode, err = mgmt_cmd_status(sk, index, opcode,
MGMT_STATUS_INVALID_INDEX); MGMT_STATUS_INVALID_INDEX);
goto done; goto done;
} }
@ -6277,7 +6278,7 @@ int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk,
no_hdev = (handler->flags & HCI_MGMT_NO_HDEV); no_hdev = (handler->flags & HCI_MGMT_NO_HDEV);
if (no_hdev != !hdev) { if (no_hdev != !hdev) {
err = cmd_status(sk, index, opcode, err = mgmt_cmd_status(sk, index, opcode,
MGMT_STATUS_INVALID_INDEX); MGMT_STATUS_INVALID_INDEX);
goto done; goto done;
} }
@ -6285,7 +6286,7 @@ int mgmt_control(struct hci_mgmt_chan *chan, struct sock *sk,
var_len = (handler->flags & HCI_MGMT_VAR_LEN); var_len = (handler->flags & HCI_MGMT_VAR_LEN);
if ((var_len && len < handler->data_len) || if ((var_len && len < handler->data_len) ||
(!var_len && len != handler->data_len)) { (!var_len && len != handler->data_len)) {
err = cmd_status(sk, index, opcode, err = mgmt_cmd_status(sk, index, opcode,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
goto done; goto done;
} }
@ -6526,7 +6527,7 @@ void mgmt_set_powered_failed(struct hci_dev *hdev, int err)
else else
status = MGMT_STATUS_FAILED; status = MGMT_STATUS_FAILED;
cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_POWERED, status); mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_POWERED, status);
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
} }
@ -7201,7 +7202,7 @@ void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
return; return;
if (status) { if (status) {
cmd_status(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA, mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_READ_LOCAL_OOB_DATA,
mgmt_status(status)); mgmt_status(status));
} else { } else {
struct mgmt_rp_read_local_oob_data rp; struct mgmt_rp_read_local_oob_data rp;