提交 bd99abdd 编写于 作者: J Johan Hedberg 提交者: Gustavo Padovan

Bluetooth: Move mgmt response convenience functions to a better location

The settings_rsp and cmd_status_rsp functions can be useful for all mgmt
command handlers when asynchronous request callbacks are used. They will
e.g. be used by subsequent patches to change set_le to use an async
request as well as a new set_advertising command. Therefore, move them
higher up in the mgmt.c file to avoid unnecessary forward declarations
or mixing this trivial change with other patches.
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
Acked-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
上级 87b95ba6
...@@ -886,6 +886,36 @@ static int new_settings(struct hci_dev *hdev, struct sock *skip) ...@@ -886,6 +886,36 @@ static int new_settings(struct hci_dev *hdev, struct sock *skip)
return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip); return mgmt_event(MGMT_EV_NEW_SETTINGS, hdev, &ev, sizeof(ev), skip);
} }
struct cmd_lookup {
struct sock *sk;
struct hci_dev *hdev;
u8 mgmt_status;
};
static void settings_rsp(struct pending_cmd *cmd, void *data)
{
struct cmd_lookup *match = data;
send_settings_rsp(cmd->sk, cmd->opcode, match->hdev);
list_del(&cmd->list);
if (match->sk == NULL) {
match->sk = cmd->sk;
sock_hold(match->sk);
}
mgmt_pending_free(cmd);
}
static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
{
u8 *status = data;
cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
mgmt_pending_remove(cmd);
}
static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data,
u16 len) u16 len)
{ {
...@@ -3374,14 +3404,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) ...@@ -3374,14 +3404,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
return err; return err;
} }
static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
{
u8 *status = data;
cmd_status(cmd->sk, cmd->index, cmd->opcode, *status);
mgmt_pending_remove(cmd);
}
int mgmt_index_added(struct hci_dev *hdev) int mgmt_index_added(struct hci_dev *hdev)
{ {
if (!mgmt_valid_hdev(hdev)) if (!mgmt_valid_hdev(hdev))
...@@ -3402,28 +3424,6 @@ int mgmt_index_removed(struct hci_dev *hdev) ...@@ -3402,28 +3424,6 @@ int mgmt_index_removed(struct hci_dev *hdev)
return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
} }
struct cmd_lookup {
struct sock *sk;
struct hci_dev *hdev;
u8 mgmt_status;
};
static void settings_rsp(struct pending_cmd *cmd, void *data)
{
struct cmd_lookup *match = data;
send_settings_rsp(cmd->sk, cmd->opcode, match->hdev);
list_del(&cmd->list);
if (match->sk == NULL) {
match->sk = cmd->sk;
sock_hold(match->sk);
}
mgmt_pending_free(cmd);
}
static void set_bredr_scan(struct hci_request *req) static void set_bredr_scan(struct hci_request *req)
{ {
struct hci_dev *hdev = req->hdev; struct hci_dev *hdev = req->hdev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册