Re: [PATCH v2 1/1] Bluetooth: Remove unneeded commands for suspend

From: Marcel Holtmann
Date: Wed Mar 03 2021 - 13:25:13 EST


Hi Abhishek,

> During suspend, there are a few scan enable and set event filter
> commands that don't need to be sent unless there are actual BR/EDR
> devices capable of waking the system. Check the HCI_PSCAN bit before
> writing scan enable and use a new dev flag, HCI_EVENT_FILTER_CONFIGURED
> to control whether to clear the event filter.
>
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@xxxxxxxxxxxx>
> Reviewed-by: Archie Pusaka <apusaka@xxxxxxxxxxxx>
> Reviewed-by: Alain Michaud <alainm@xxxxxxxxxxxx>
> ---
>
> Changes in v2:
> * Removed hci_dev_lock from hci_cc_set_event_filter since flags are
> set/cleared atomically
>
> include/net/bluetooth/hci.h | 1 +
> net/bluetooth/hci_event.c | 24 ++++++++++++++++++++
> net/bluetooth/hci_request.c | 44 +++++++++++++++++++++++--------------
> 3 files changed, 52 insertions(+), 17 deletions(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index ba2f439bc04d34..ea4ae551c42687 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -320,6 +320,7 @@ enum {
> HCI_BREDR_ENABLED,
> HCI_LE_SCAN_INTERRUPTED,
> HCI_WIDEBAND_SPEECH_ENABLED,
> + HCI_EVENT_FILTER_CONFIGURED,
>
> HCI_DUT_MODE,
> HCI_VENDOR_DIAG,
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 67668be3461e93..6eadc999ea1474 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -395,6 +395,26 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
> hci_dev_unlock(hdev);
> }
>
> +static void hci_cc_set_event_filter(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + __u8 status = *((__u8 *)skb->data);
> + struct hci_cp_set_event_filter *cp;
> + void *sent;
> +
> + BT_DBG("%s status 0x%2.2x", hdev->name, status);
> +
> + sent = hci_sent_cmd_data(hdev, HCI_OP_SET_EVENT_FLT);
> + if (!sent || status)
> + return;

can we do this:

if (status)
return;

sent = hci_..
if (!sent)
return;

Regards

Marcel