summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-12-04 05:36:34 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2014-12-04 05:50:21 -0500
commitf5a969f23bc32945b0ec4bdb8084f514a5311142 (patch)
treedb1dd05d98adec348e7f479a00a35d4e77421099 /net/bluetooth/mgmt.c
parent854bda1982bf126d0a951adfcac76ba6d000cd2b (diff)
Bluetooth: Simplify the error handling of Start Discovery command
The Start Discovery command has some complicated code when it comes to error handling. With the future introduction of Start Service Discovery simplifying this makes it easier to read. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 77cf0ef0d8a3..f3296371a310 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3771,14 +3771,8 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
3771 goto failed; 3771 goto failed;
3772 } 3772 }
3773 3773
3774 if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) { 3774 if (hdev->discovery.state != DISCOVERY_STOPPED ||
3775 err = cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY, 3775 test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) {
3776 MGMT_STATUS_BUSY, &cp->type,
3777 sizeof(cp->type));
3778 goto failed;
3779 }
3780
3781 if (hdev->discovery.state != DISCOVERY_STOPPED) {
3782 err = cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY, 3776 err = cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY,
3783 MGMT_STATUS_BUSY, &cp->type, 3777 MGMT_STATUS_BUSY, &cp->type,
3784 sizeof(cp->type)); 3778 sizeof(cp->type));
@@ -3909,10 +3903,12 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
3909 } 3903 }
3910 3904
3911 err = hci_req_run(&req, start_discovery_complete); 3905 err = hci_req_run(&req, start_discovery_complete);
3912 if (err < 0) 3906 if (err < 0) {
3913 mgmt_pending_remove(cmd); 3907 mgmt_pending_remove(cmd);
3914 else 3908 goto failed;
3915 hci_discovery_set_state(hdev, DISCOVERY_STARTING); 3909 }
3910
3911 hci_discovery_set_state(hdev, DISCOVERY_STARTING);
3916 3912
3917failed: 3913failed:
3918 hci_dev_unlock(hdev); 3914 hci_dev_unlock(hdev);