Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5a969f2 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg
Browse files

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: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 854bda19
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -3771,14 +3771,8 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
		goto failed;
	}

	if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) {
		err = cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY,
				   MGMT_STATUS_BUSY, &cp->type,
				   sizeof(cp->type));
		goto failed;
	}

	if (hdev->discovery.state != DISCOVERY_STOPPED) {
	if (hdev->discovery.state != DISCOVERY_STOPPED ||
	    test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) {
		err = cmd_complete(sk, hdev->id, MGMT_OP_START_DISCOVERY,
				   MGMT_STATUS_BUSY, &cp->type,
				   sizeof(cp->type));
@@ -3909,9 +3903,11 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
	}

	err = hci_req_run(&req, start_discovery_complete);
	if (err < 0)
	if (err < 0) {
		mgmt_pending_remove(cmd);
	else
		goto failed;
	}

	hci_discovery_set_state(hdev, DISCOVERY_STARTING);

failed: