From: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: Remove magic numbers from le scan cmd
Date: Wed, 21 Dec 2011 14:53:45 +0200 [thread overview]
Message-ID: <20111221125343.GD21295@aemeltch-MOBL1> (raw)
In-Reply-To: <1324304058-18944-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
On Mon, Dec 19, 2011 at 04:14:18PM +0200, Emeltchenko Andrei wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Make code readable by removing magic numbers.
Gustavo what do you think about this one?
Best regards
Andrei Emeltchenko
>
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci.h | 3 +++
> net/bluetooth/hci_event.c | 12 ++++++++++--
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 2e48d32..c019b27 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -800,6 +800,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;
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index fc5338f..4275816 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1030,7 +1030,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);
> @@ -1038,12 +1039,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;
> }
> }
next prev parent reply other threads:[~2011-12-21 12:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-19 14:14 [PATCH] Bluetooth: Remove magic numbers from le scan cmd Emeltchenko Andrei
2011-12-21 12:53 ` Emeltchenko Andrei [this message]
2011-12-22 16:03 ` Gustavo Padovan
-- strict thread matches above, loose matches on Subject: below --
2011-12-05 9:26 Emeltchenko Andrei
2011-11-30 14:17 Emeltchenko Andrei
2011-11-30 14:27 ` Marcel Holtmann
2011-12-02 11:59 ` Gustavo Padovan
2011-12-02 23:33 ` Gustavo Padovan
2011-12-05 9:27 ` Emeltchenko Andrei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111221125343.GD21295@aemeltch-MOBL1 \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox