linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP
@ 2012-02-22 14:02 johan.hedberg
  2012-02-22 14:02 ` [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir johan.hedberg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: johan.hedberg @ 2012-02-22 14:02 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

This patch fixes setting the EIR properly when the SSP flag has been set
when powered off (in such a case there is no pending Set_SSP command).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/mgmt.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9fb4490..bdaadb2 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3437,14 +3437,13 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
 	if (changed)
 		err = new_settings(hdev, match.sk);
 
-	if (match.sk) {
+	if (match.sk)
 		sock_put(match.sk);
 
-		if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
-			update_eir(hdev);
-		else
-			clear_eir(hdev);
-	}
+	if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags))
+		update_eir(hdev);
+	else
+		clear_eir(hdev);
 
 	return err;
 }
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir
  2012-02-22 14:02 [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP johan.hedberg
@ 2012-02-22 14:02 ` johan.hedberg
  2012-02-22 14:04   ` Marcel Holtmann
  2012-02-22 14:02 ` [PATCH 3/3] Bluetooth: Explicitly clear EIR data upon hci_dev setup johan.hedberg
  2012-02-22 14:03 ` [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP Marcel Holtmann
  2 siblings, 1 reply; 6+ messages in thread
From: johan.hedberg @ 2012-02-22 14:02 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

The hdev->eir buffer needs to be cleared when clearing the EIR data.
Otherwise subsequent attempts at setting the EIR to something valid
again may fail because the code thinks that the EIR hasn't changed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/mgmt.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index bdaadb2..08c657d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3400,6 +3400,8 @@ static int clear_eir(struct hci_dev *hdev)
 	if (!(hdev->features[6] & LMP_EXT_INQ))
 		return 0;
 
+	memset(hdev->eir, 0, sizeof(hdev->eir));
+
 	memset(&cp, 0, sizeof(cp));
 
 	return hci_send_cmd(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp);
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] Bluetooth: Explicitly clear EIR data upon hci_dev setup
  2012-02-22 14:02 [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP johan.hedberg
  2012-02-22 14:02 ` [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir johan.hedberg
@ 2012-02-22 14:02 ` johan.hedberg
  2012-02-22 14:05   ` Marcel Holtmann
  2012-02-22 14:03 ` [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP Marcel Holtmann
  2 siblings, 1 reply; 6+ messages in thread
From: johan.hedberg @ 2012-02-22 14:02 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

Some controllers preserve their EIR data even after a reset so we need
to explicitly clear this during the device setup procedure.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/hci_event.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 240dc16..3476d5c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -557,10 +557,19 @@ static void hci_setup(struct hci_dev *hdev)
 	if (hdev->hci_ver > BLUETOOTH_VER_1_1)
 		hci_send_cmd(hdev, HCI_OP_READ_LOCAL_COMMANDS, 0, NULL);
 
-	if (hdev->features[6] & LMP_SIMPLE_PAIR &&
-				test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) {
-		u8 mode = 0x01;
-		hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, sizeof(mode), &mode);
+	if (hdev->features[6] & LMP_SIMPLE_PAIR) {
+		if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) {
+			u8 mode = 0x01;
+			hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE,
+							sizeof(mode), &mode);
+		} else {
+			struct hci_cp_write_eir cp;
+
+			memset(hdev->eir, 0, sizeof(hdev->eir));
+			memset(&cp, 0, sizeof(cp));
+
+			hci_send_cmd(hdev, HCI_OP_WRITE_EIR, sizeof(cp), &cp);
+		}
 	}
 
 	if (hdev->features[3] & LMP_RSSI_INQ)
-- 
1.7.9


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP
  2012-02-22 14:02 [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP johan.hedberg
  2012-02-22 14:02 ` [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir johan.hedberg
  2012-02-22 14:02 ` [PATCH 3/3] Bluetooth: Explicitly clear EIR data upon hci_dev setup johan.hedberg
@ 2012-02-22 14:03 ` Marcel Holtmann
  2 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2012-02-22 14:03 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> This patch fixes setting the EIR properly when the SSP flag has been set
> when powered off (in such a case there is no pending Set_SSP command).
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
>  net/bluetooth/mgmt.c |   11 +++++------
>  1 files changed, 5 insertions(+), 6 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir
  2012-02-22 14:02 ` [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir johan.hedberg
@ 2012-02-22 14:04   ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2012-02-22 14:04 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> The hdev->eir buffer needs to be cleared when clearing the EIR data.
> Otherwise subsequent attempts at setting the EIR to something valid
> again may fail because the code thinks that the EIR hasn't changed.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
>  net/bluetooth/mgmt.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] Bluetooth: Explicitly clear EIR data upon hci_dev setup
  2012-02-22 14:02 ` [PATCH 3/3] Bluetooth: Explicitly clear EIR data upon hci_dev setup johan.hedberg
@ 2012-02-22 14:05   ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2012-02-22 14:05 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth

Hi Johan,

> Some controllers preserve their EIR data even after a reset so we need
> to explicitly clear this during the device setup procedure.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
>  net/bluetooth/hci_event.c |   17 +++++++++++++----
>  1 files changed, 13 insertions(+), 4 deletions(-)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-02-22 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-22 14:02 [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP johan.hedberg
2012-02-22 14:02 ` [PATCH 2/3] Bluetooth: mgmt: Fix clearing of hdev->eir johan.hedberg
2012-02-22 14:04   ` Marcel Holtmann
2012-02-22 14:02 ` [PATCH 3/3] Bluetooth: Explicitly clear EIR data upon hci_dev setup johan.hedberg
2012-02-22 14:05   ` Marcel Holtmann
2012-02-22 14:03 ` [PATCH 1/3] Bluetooth: mgmt: Fix EIR toggling with SSP Marcel Holtmann

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).