Skip to contentSkip to conversation

Bluetooth: Fix clearing of HCI_PENDING_CLASS flag

PATCH In review [email protected] 2 participants 6 messages Mar 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Bluetooth: Fix clearing of HCI_PENDING_CLASS flag

From: Johan Hedberg <[email protected]>

When doing reset HCI_PENDING_CLASS is one of the flags that should be cleared (since it's used for a pending HCI command and a reset clear all pending commands).

---
 net/bluetooth/hci_event.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/bluetooth/hci_event.c +1 -1
index aee9556..d6c41bb 100644
@@ -193,7 +193,7 @@ 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));
+	hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS));
 
 	hdev->discovery.state = DISCOVERY_STOPPED;
 }
Signature · 1 line
1.7.9.1
#1 lore raw

PATCH 2/3 Bluetooth: mgmt: Fix command status error code values

From: Johan Hedberg <[email protected]>

Error codes in the command status should always be from the set of values defined for mgmt and never e.g. POSIX error codes.

---
 net/bluetooth/mgmt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/mgmt.c +2 -2
index 40b3da3..bd01e4a 100644
@@ -2745,7 +2745,7 @@ int mgmt_index_added(struct hci_dev *hdev)
 
 int mgmt_index_removed(struct hci_dev *hdev)
 {
-	u8 status = ENODEV;
+	u8 status = MGMT_STATUS_INVALID_PARAMS;
 
 	mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
 
@@ -2798,7 +2798,7 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
 		update_class(hdev);
 		update_eir(hdev);
 	} else {
-		u8 status = ENETDOWN;
+		u8 status = MGMT_STATUS_NOT_POWERED;
 		mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
 	}
 
Signature · 1 line
1.7.9.1
maintainer Acked-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] Bluetooth: mgmt: Fix command status error code values

Hi Johan,

Quoted 7 lines

Error codes in the command status should always be from the set of values defined for mgmt and never e.g. POSIX error codes.

---
 net/bluetooth/mgmt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Regards

Marcel

#3 lore raw

PATCH 3/3 Bluetooth: mgmt: Add new error code for invalid index

In reply to [email protected]

From: Johan Hedberg <[email protected]>

The index is part of the command header and not its parameters so it makes sense to distinguish this from the invalid parameters error.

---
 include/net/bluetooth/mgmt.h |    1 +
 net/bluetooth/mgmt.c         |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
include/net/bluetooth/mgmt.h +1 -0
index d33457d..0ca3519 100644
@@ -41,6 +41,7 @@
 #define MGMT_STATUS_DISCONNECTED	0x0e
 #define MGMT_STATUS_NOT_POWERED		0x0f
 #define MGMT_STATUS_CANCELLED		0x10
+#define MGMT_STATUS_INVALID_INDEX	0x11
 
 struct mgmt_hdr {
 	__le16 opcode;
net/bluetooth/mgmt.c +3 -3
index bd01e4a..fa9a589 100644
@@ -2682,7 +2682,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
 		hdev = hci_dev_get(index);
 		if (!hdev) {
 			err = cmd_status(sk, index, opcode,
-					MGMT_STATUS_INVALID_PARAMS);
+					MGMT_STATUS_INVALID_INDEX);
 			goto done;
 		}
 	}
@@ -2698,7 +2698,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
 	if ((hdev && opcode < MGMT_OP_READ_INFO) ||
 			(!hdev && opcode >= MGMT_OP_READ_INFO)) {
 		err = cmd_status(sk, index, opcode,
-						MGMT_STATUS_INVALID_PARAMS);
+						MGMT_STATUS_INVALID_INDEX);
 		goto done;
 	}
 
@@ -2745,7 +2745,7 @@ int mgmt_index_added(struct hci_dev *hdev)
 
 int mgmt_index_removed(struct hci_dev *hdev)
 {
-	u8 status = MGMT_STATUS_INVALID_PARAMS;
+	u8 status = MGMT_STATUS_INVALID_INDEX;
 
 	mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
 
Signature · 1 line
1.7.9.1
maintainer Acked-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] Bluetooth: mgmt: Add new error code for invalid index

Hi Johan,

Quoted 8 lines

The index is part of the command header and not its parameters so it makes sense to distinguish this from the invalid parameters error.

---
 include/net/bluetooth/mgmt.h |    1 +
 net/bluetooth/mgmt.c         |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

Regards

Marcel