Bluetooth: Remove magic numbers from le scan cmd
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Mon, 19 Dec 2011 14:14:18 +0000 (16:14 +0200)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 22 Dec 2011 16:03:24 +0000 (14:03 -0200)
Make code readable by removing magic numbers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
include/net/bluetooth/hci.h
net/bluetooth/hci_event.c

index 6127ca8bd1d12c6d6d5ef6a7a5224ae72c6f0ff0..5b2fed5eebf2e32063d59be921b2a830b9eaa8ea 100644 (file)
@@ -804,6 +804,9 @@ struct hci_cp_le_set_scan_param {
        __u8    filter_policy;
 } __packed;
 
+#define LE_SCANNING_DISABLED           0x00
+#define LE_SCANNING_ENABLED            0x01
+
 #define HCI_OP_LE_SET_SCAN_ENABLE      0x200c
 struct hci_cp_le_set_scan_enable {
        __u8     enable;
index b9d77be92d3b1dc548d00009c1262cc7dde6ea53..919e3c0e74aa4c61ff3e920bad6c7c0ae5f5b11f 100644 (file)
@@ -1033,7 +1033,8 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
        if (!cp)
                return;
 
-       if (cp->enable == 0x01) {
+       switch (cp->enable) {
+       case LE_SCANNING_ENABLED:
                set_bit(HCI_LE_SCAN, &hdev->dev_flags);
 
                cancel_delayed_work_sync(&hdev->adv_work);
@@ -1041,12 +1042,19 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
                hci_dev_lock(hdev);
                hci_adv_entries_clear(hdev);
                hci_dev_unlock(hdev);
-       } else if (cp->enable == 0x00) {
+               break;
+
+       case LE_SCANNING_DISABLED:
                clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
 
                cancel_delayed_work_sync(&hdev->adv_work);
                queue_delayed_work(hdev->workqueue, &hdev->adv_work,
                                                 jiffies + ADV_CLEAR_TIMEOUT);
+               break;
+
+       default:
+               BT_ERR("Used reserved LE_Scan_Enable param %d", cp->enable);
+               break;
        }
 }