summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-12-05 06:36:06 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-12-05 06:46:10 -0500
commit2922a94fcc04f26aee1b279d38e93d4a5c295f25 (patch)
tree95150dd2b1ccc0720af11cd13da7c3be4f9beba4 /net/bluetooth/mgmt.c
parentd8b7b1e49abe98d67f589d6326658a48d810f875 (diff)
Bluetooth: Convert discovery commands to use cmd_complete callback
This patch converts the Start/Stop Discovery mgmt commands to use the cmd_complete callback of struct pending_cmd. Since both of these commands return the same parameters as they take as input we can use the existing generic_cmd_complete() helper for this. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 1accbb9d1a36..ddaeebbccfba 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3835,10 +3835,7 @@ static void start_discovery_complete(struct hci_dev *hdev, u8 status)
3835 cmd = mgmt_pending_find(MGMT_OP_START_SERVICE_DISCOVERY, hdev); 3835 cmd = mgmt_pending_find(MGMT_OP_START_SERVICE_DISCOVERY, hdev);
3836 3836
3837 if (cmd) { 3837 if (cmd) {
3838 u8 type = hdev->discovery.type; 3838 cmd->cmd_complete(cmd, mgmt_status(status));
3839
3840 cmd_complete(cmd->sk, hdev->id, cmd->opcode,
3841 mgmt_status(status), &type, sizeof(type));
3842 mgmt_pending_remove(cmd); 3839 mgmt_pending_remove(cmd);
3843 } 3840 }
3844 3841
@@ -3901,12 +3898,14 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
3901 goto failed; 3898 goto failed;
3902 } 3899 }
3903 3900
3904 cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, hdev, NULL, 0); 3901 cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, hdev, data, len);
3905 if (!cmd) { 3902 if (!cmd) {
3906 err = -ENOMEM; 3903 err = -ENOMEM;
3907 goto failed; 3904 goto failed;
3908 } 3905 }
3909 3906
3907 cmd->cmd_complete = generic_cmd_complete;
3908
3910 /* Clear the discovery filter first to free any previously 3909 /* Clear the discovery filter first to free any previously
3911 * allocated memory for the UUID list. 3910 * allocated memory for the UUID list.
3912 */ 3911 */
@@ -3936,6 +3935,11 @@ failed:
3936 return err; 3935 return err;
3937} 3936}
3938 3937
3938static void service_discovery_cmd_complete(struct pending_cmd *cmd, u8 status)
3939{
3940 cmd_complete(cmd->sk, cmd->index, cmd->opcode, status, cmd->param, 1);
3941}
3942
3939static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, 3943static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
3940 void *data, u16 len) 3944 void *data, u16 len)
3941{ 3945{
@@ -3991,12 +3995,14 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev,
3991 } 3995 }
3992 3996
3993 cmd = mgmt_pending_add(sk, MGMT_OP_START_SERVICE_DISCOVERY, 3997 cmd = mgmt_pending_add(sk, MGMT_OP_START_SERVICE_DISCOVERY,
3994 hdev, NULL, 0); 3998 hdev, data, len);
3995 if (!cmd) { 3999 if (!cmd) {
3996 err = -ENOMEM; 4000 err = -ENOMEM;
3997 goto failed; 4001 goto failed;
3998 } 4002 }
3999 4003
4004 cmd->cmd_complete = service_discovery_cmd_complete;
4005
4000 /* Clear the discovery filter first to free any previously 4006 /* Clear the discovery filter first to free any previously
4001 * allocated memory for the UUID list. 4007 * allocated memory for the UUID list.
4002 */ 4008 */
@@ -4052,10 +4058,7 @@ static void stop_discovery_complete(struct hci_dev *hdev, u8 status)
4052 4058
4053 cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev); 4059 cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev);
4054 if (cmd) { 4060 if (cmd) {
4055 u8 type = hdev->discovery.type; 4061 cmd->cmd_complete(cmd, mgmt_status(status));
4056
4057 cmd_complete(cmd->sk, hdev->id, cmd->opcode,
4058 mgmt_status(status), &type, sizeof(type));
4059 mgmt_pending_remove(cmd); 4062 mgmt_pending_remove(cmd);
4060 } 4063 }
4061 4064
@@ -4091,12 +4094,14 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
4091 goto unlock; 4094 goto unlock;
4092 } 4095 }
4093 4096
4094 cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, hdev, NULL, 0); 4097 cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, hdev, data, len);
4095 if (!cmd) { 4098 if (!cmd) {
4096 err = -ENOMEM; 4099 err = -ENOMEM;
4097 goto unlock; 4100 goto unlock;
4098 } 4101 }
4099 4102
4103 cmd->cmd_complete = generic_cmd_complete;
4104
4100 hci_req_init(&req, hdev); 4105 hci_req_init(&req, hdev);
4101 4106
4102 hci_stop_discovery(&req); 4107 hci_stop_discovery(&req);