Commit 04106755 authored by Johan Hedberg's avatar Johan Hedberg Committed by Gustavo Padovan

Bluetooth: Fix returning proper command status for start_discovery

Management commands should whenever possible fail with proper command
status or command complete events. This patch fixes the
mgmt_start_discovery command to do this for the failure cases where an
incorrect parameter value was passed to it ("not supported" if the
parameter value was valid but the controller doesn't support it and
"invalid params" if it isn't valid at all).
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent a7e80f25
...@@ -2382,31 +2382,45 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, ...@@ -2382,31 +2382,45 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
switch (hdev->discovery.type) { switch (hdev->discovery.type) {
case DISCOV_TYPE_BREDR: case DISCOV_TYPE_BREDR:
if (lmp_bredr_capable(hdev)) if (!lmp_bredr_capable(hdev)) {
err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
else MGMT_STATUS_NOT_SUPPORTED);
err = -ENOTSUPP; mgmt_pending_remove(cmd);
goto failed;
}
err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
break; break;
case DISCOV_TYPE_LE: case DISCOV_TYPE_LE:
if (lmp_host_le_capable(hdev)) if (!lmp_host_le_capable(hdev)) {
err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY); MGMT_STATUS_NOT_SUPPORTED);
else mgmt_pending_remove(cmd);
err = -ENOTSUPP; goto failed;
}
err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
break; break;
case DISCOV_TYPE_INTERLEAVED: case DISCOV_TYPE_INTERLEAVED:
if (lmp_host_le_capable(hdev) && lmp_bredr_capable(hdev)) if (!lmp_host_le_capable(hdev) || !lmp_bredr_capable(hdev)) {
err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
LE_SCAN_WIN, MGMT_STATUS_NOT_SUPPORTED);
LE_SCAN_TIMEOUT_BREDR_LE); mgmt_pending_remove(cmd);
else goto failed;
err = -ENOTSUPP; }
err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT, LE_SCAN_WIN,
LE_SCAN_TIMEOUT_BREDR_LE);
break; break;
default: default:
err = -EINVAL; err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_INVALID_PARAMS);
mgmt_pending_remove(cmd);
goto failed;
} }
if (err < 0) if (err < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment