Bluetooth: Clean up logic in hci_cc_write_scan_enable
This patch adds a new label to hci_cc_write_scan_enable to avoid unnecessary indentation. This will be convenient especially when new code for the discoverable timeout gets added. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
committed by
Gustavo F. Padovan
parent
abc545b8ef
commit
36f7fc7e9a
@@ -274,7 +274,8 @@ static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
|
|
||||||
static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
|
static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
__u8 status = *((__u8 *) skb->data);
|
__u8 param, status = *((__u8 *) skb->data);
|
||||||
|
int old_pscan, old_iscan;
|
||||||
void *sent;
|
void *sent;
|
||||||
|
|
||||||
BT_DBG("%s status 0x%x", hdev->name, status);
|
BT_DBG("%s status 0x%x", hdev->name, status);
|
||||||
@@ -283,28 +284,29 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
if (!sent)
|
if (!sent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!status) {
|
if (status != 0)
|
||||||
__u8 param = *((__u8 *) sent);
|
goto done;
|
||||||
int old_pscan, old_iscan;
|
|
||||||
|
|
||||||
old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
|
param = *((__u8 *) sent);
|
||||||
old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
|
|
||||||
|
|
||||||
if (param & SCAN_INQUIRY) {
|
old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
|
||||||
set_bit(HCI_ISCAN, &hdev->flags);
|
old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
|
||||||
if (!old_iscan)
|
|
||||||
mgmt_discoverable(hdev->id, 1);
|
|
||||||
} else if (old_iscan)
|
|
||||||
mgmt_discoverable(hdev->id, 0);
|
|
||||||
|
|
||||||
if (param & SCAN_PAGE) {
|
if (param & SCAN_INQUIRY) {
|
||||||
set_bit(HCI_PSCAN, &hdev->flags);
|
set_bit(HCI_ISCAN, &hdev->flags);
|
||||||
if (!old_pscan)
|
if (!old_iscan)
|
||||||
mgmt_connectable(hdev->id, 1);
|
mgmt_discoverable(hdev->id, 1);
|
||||||
} else if (old_pscan)
|
} else if (old_iscan)
|
||||||
mgmt_connectable(hdev->id, 0);
|
mgmt_discoverable(hdev->id, 0);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (param & SCAN_PAGE) {
|
||||||
|
set_bit(HCI_PSCAN, &hdev->flags);
|
||||||
|
if (!old_pscan)
|
||||||
|
mgmt_connectable(hdev->id, 1);
|
||||||
|
} else if (old_pscan)
|
||||||
|
mgmt_connectable(hdev->id, 0);
|
||||||
|
|
||||||
|
done:
|
||||||
hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status);
|
hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user