diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-11-03 18:17:45 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-07 14:25:06 -0500 |
commit | 36f7fc7e9ac72507ab7bf6caf77ad252c12ab37e (patch) | |
tree | 57bb46c000f6fc65d7eda40da6004336810a2f2e /net | |
parent | abc545b8efe3d50d649590df4b88cc652fd057f1 (diff) |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_event.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index d8fa65709aed..8c81a75381fb 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -274,7 +274,8 @@ static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb) | |||
274 | 274 | ||
275 | static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) | 275 | static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) |
276 | { | 276 | { |
277 | __u8 status = *((__u8 *) skb->data); | 277 | __u8 param, status = *((__u8 *) skb->data); |
278 | int old_pscan, old_iscan; | ||
278 | void *sent; | 279 | void *sent; |
279 | 280 | ||
280 | BT_DBG("%s status 0x%x", hdev->name, status); | 281 | 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) | |||
283 | if (!sent) | 284 | if (!sent) |
284 | return; | 285 | return; |
285 | 286 | ||
286 | if (!status) { | 287 | if (status != 0) |
287 | __u8 param = *((__u8 *) sent); | 288 | goto done; |
288 | int old_pscan, old_iscan; | ||
289 | 289 | ||
290 | old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); | 290 | param = *((__u8 *) sent); |
291 | old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); | ||
292 | 291 | ||
293 | if (param & SCAN_INQUIRY) { | 292 | old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); |
294 | set_bit(HCI_ISCAN, &hdev->flags); | 293 | old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); |
295 | if (!old_iscan) | ||
296 | mgmt_discoverable(hdev->id, 1); | ||
297 | } else if (old_iscan) | ||
298 | mgmt_discoverable(hdev->id, 0); | ||
299 | 294 | ||
300 | if (param & SCAN_PAGE) { | 295 | if (param & SCAN_INQUIRY) { |
301 | set_bit(HCI_PSCAN, &hdev->flags); | 296 | set_bit(HCI_ISCAN, &hdev->flags); |
302 | if (!old_pscan) | 297 | if (!old_iscan) |
303 | mgmt_connectable(hdev->id, 1); | 298 | mgmt_discoverable(hdev->id, 1); |
304 | } else if (old_pscan) | 299 | } else if (old_iscan) |
305 | mgmt_connectable(hdev->id, 0); | 300 | mgmt_discoverable(hdev->id, 0); |
306 | } | 301 | |
302 | if (param & SCAN_PAGE) { | ||
303 | set_bit(HCI_PSCAN, &hdev->flags); | ||
304 | if (!old_pscan) | ||
305 | mgmt_connectable(hdev->id, 1); | ||
306 | } else if (old_pscan) | ||
307 | mgmt_connectable(hdev->id, 0); | ||
307 | 308 | ||
309 | done: | ||
308 | hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status); | 310 | hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status); |
309 | } | 311 | } |
310 | 312 | ||