* [PATCH 0/4] Periodic Inquiry Handling
@ 2012-03-21 3:03 Andre Guedes
2012-03-21 3:03 ` [PATCH 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Andre Guedes @ 2012-03-21 3:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
Hi all,
This patch series implements some Marcel's considerations about Periodic
Inquiry handling.
The main points are:
* Track if periodic inquiry enabled or not;
* Fail start discovery if periodic inquiry is enabled;
* Ignore inquiry result events from periodic inquiry.
These considerations were given in "[PATCH v4 01/14] Bluetooth: Periodic
Inquiry and mgmt discovering event" email.
BR,
Andre
Andre Guedes (4):
Bluetooth: Add Periodic Inquiry command complete handler
Bluetooth: Add HCI_PERIODIC_INQ to dev_flags
Bluetooth: Check HCI_PERIODIC_INQ in start_discovery
Bluetooth: Ignore inquiry results from periodic inquiry
include/net/bluetooth/hci.h | 3 +++
net/bluetooth/hci_event.c | 30 +++++++++++++++++++++++++++++-
net/bluetooth/mgmt.c | 6 ++++++
3 files changed, 38 insertions(+), 1 deletion(-)
--
1.7.9.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] Bluetooth: Add Periodic Inquiry command complete handler
2012-03-21 3:03 [PATCH 0/4] Periodic Inquiry Handling Andre Guedes
@ 2012-03-21 3:03 ` Andre Guedes
2012-03-21 3:03 ` [PATCH 2/4] Bluetooth: Add HCI_PERIODIC_INQ to dev_flags Andre Guedes
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2012-03-21 3:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch adds a handler function to Periodic Inquiry command
complete event.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_event.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index dbbb593..d74645e 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -324,6 +324,8 @@ struct hci_cp_inquiry {
#define HCI_OP_INQUIRY_CANCEL 0x0402
+#define HCI_OP_PERIODIC_INQ 0x0403
+
#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
#define HCI_OP_CREATE_CONN 0x0405
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 04d39f4..af0c5a2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -70,6 +70,13 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
hci_conn_check_pending(hdev);
}
+static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ __u8 status = *((__u8 *) skb->data);
+
+ BT_DBG("%s status 0x%x", hdev->name, status);
+}
+
static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
{
__u8 status = *((__u8 *) skb->data);
@@ -2154,6 +2161,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
hci_cc_inquiry_cancel(hdev, skb);
break;
+ case HCI_OP_PERIODIC_INQ:
+ hci_cc_periodic_inq(hdev, skb);
+ break;
+
case HCI_OP_EXIT_PERIODIC_INQ:
hci_cc_exit_periodic_inq(hdev, skb);
break;
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] Bluetooth: Add HCI_PERIODIC_INQ to dev_flags
2012-03-21 3:03 [PATCH 0/4] Periodic Inquiry Handling Andre Guedes
2012-03-21 3:03 ` [PATCH 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
@ 2012-03-21 3:03 ` Andre Guedes
2012-03-21 3:03 ` [PATCH 3/4] Bluetooth: Check HCI_PERIODIC_INQ in start_discovery Andre Guedes
2012-03-21 3:03 ` [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
3 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2012-03-21 3:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch adds the HCI_PERIODIC_INQ flag to dev_flags. This flag
tracks if periodic inquiry is enabled or not.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 1 +
net/bluetooth/hci_event.c | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index d74645e..38ac0e6 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -102,6 +102,7 @@ enum {
HCI_DISCOVERABLE,
HCI_LINK_SECURITY,
HCI_PENDING_CLASS,
+ HCI_PERIODIC_INQ,
};
/* HCI ioctl defines */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index af0c5a2..bffb0c3 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -75,6 +75,11 @@ static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
__u8 status = *((__u8 *) skb->data);
BT_DBG("%s status 0x%x", hdev->name, status);
+
+ if (status)
+ return;
+
+ set_bit(HCI_PERIODIC_INQ, &hdev->dev_flags);
}
static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
@@ -86,6 +91,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
if (status)
return;
+ clear_bit(HCI_PERIODIC_INQ, &hdev->dev_flags);
+
hci_conn_check_pending(hdev);
}
@@ -200,7 +207,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
hci_req_complete(hdev, HCI_OP_RESET, status);
/* Reset all non-persistent flags */
- hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS));
+ hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS) |
+ BIT(HCI_PERIODIC_INQ));
hdev->discovery.state = DISCOVERY_STOPPED;
}
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] Bluetooth: Check HCI_PERIODIC_INQ in start_discovery
2012-03-21 3:03 [PATCH 0/4] Periodic Inquiry Handling Andre Guedes
2012-03-21 3:03 ` [PATCH 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
2012-03-21 3:03 ` [PATCH 2/4] Bluetooth: Add HCI_PERIODIC_INQ to dev_flags Andre Guedes
@ 2012-03-21 3:03 ` Andre Guedes
2012-03-21 3:03 ` [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
3 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2012-03-21 3:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch adds a HCI_PERIODIC_INQ check to start_discovery.
If periodic inquiry is enabled, we fail MGMT Start Discovery
command with MGMT_STATUS_BUSY code.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d93f2bf..e399581 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2315,6 +2315,12 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
goto failed;
}
+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+ MGMT_STATUS_BUSY);
+ goto failed;
+ }
+
if (hdev->discovery.state != DISCOVERY_STOPPED) {
err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_BUSY);
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry
2012-03-21 3:03 [PATCH 0/4] Periodic Inquiry Handling Andre Guedes
` (2 preceding siblings ...)
2012-03-21 3:03 ` [PATCH 3/4] Bluetooth: Check HCI_PERIODIC_INQ in start_discovery Andre Guedes
@ 2012-03-21 3:03 ` Andre Guedes
2012-03-22 13:49 ` Gustavo Padovan
3 siblings, 1 reply; 6+ messages in thread
From: Andre Guedes @ 2012-03-21 3:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch changes inquiry result function handlers so they ignore
inquiry result events if periodic inquiry is enabled.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_event.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index bffb0c3..7325300 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1723,6 +1723,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
if (!num_rsp)
return;
+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
+ return;
+
hci_dev_lock(hdev);
for (; num_rsp; num_rsp--, info++) {
@@ -2824,6 +2827,9 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
if (!num_rsp)
return;
+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
+ return;
+
hci_dev_lock(hdev);
if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
@@ -2995,6 +3001,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
if (!num_rsp)
return;
+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
+ return;
+
hci_dev_lock(hdev);
for (; num_rsp; num_rsp--, info++) {
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry
2012-03-21 3:03 ` [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
@ 2012-03-22 13:49 ` Gustavo Padovan
0 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2012-03-22 13:49 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth, andre.guedes
Hi Andre,
* Andre Guedes <aguedespe@gmail.com> [2012-03-21 00:03:38 -0300]:
> This patch changes inquiry result function handlers so they ignore
> inquiry result events if periodic inquiry is enabled.
>
> Signed-off-by: Andre Guedes <aguedespe@gmail.com>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_event.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
All four patches applied. Thanks.
Gustavo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-22 13:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-21 3:03 [PATCH 0/4] Periodic Inquiry Handling Andre Guedes
2012-03-21 3:03 ` [PATCH 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
2012-03-21 3:03 ` [PATCH 2/4] Bluetooth: Add HCI_PERIODIC_INQ to dev_flags Andre Guedes
2012-03-21 3:03 ` [PATCH 3/4] Bluetooth: Check HCI_PERIODIC_INQ in start_discovery Andre Guedes
2012-03-21 3:03 ` [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
2012-03-22 13:49 ` Gustavo Padovan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).