* [PATCH 01/15] Bluetooth: Fix clearing persistent flags
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:02 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 02/15] Bluetooth: Rename mgmt connected events to match user space Johan Hedberg
` (13 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
There are several other dev_flags besided HCI_MGMT that should not be
cleared upon reset.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/hci_event.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c2fe964..4eef43c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -195,8 +195,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
hci_req_complete(hdev, HCI_OP_RESET, status);
- /* Reset all flags, except persistent ones like HCI_MGMT */
- hdev->dev_flags &= BIT(HCI_MGMT);
+ /* Reset all flags, except persistent ones */
+ hdev->dev_flags &= BIT(HCI_MGMT) | BIT(HCI_SETUP) | BIT(HCI_AUTO_OFF);
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 02/15] Bluetooth: Rename mgmt connected events to match user space
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
2012-01-18 18:51 ` [PATCH 01/15] Bluetooth: Fix clearing persistent flags Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:03 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 03/15] Bluetooth: Add eir_len parameter to mgmt_ev_device_found Johan Hedberg
` (12 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
User space uses device_(dis)connected instead of just (dis)connected so
rename the defines and functions to match this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 6 +++---
include/net/bluetooth/mgmt.h | 4 ++--
net/bluetooth/hci_event.c | 6 +++---
net/bluetooth/mgmt.c | 12 +++++++-----
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 393acd0..f3fbfd6 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -896,10 +896,10 @@ int mgmt_connectable(struct hci_dev *hdev, u8 connectable);
int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status);
int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
u8 persistent);
-int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
- u8 addr_type);
-int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
+int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type);
+int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
+ u8 link_type, u8 addr_type);
int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status);
int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 status);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index be65d34..d1d13dc 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -328,9 +328,9 @@ struct mgmt_ev_new_link_key {
struct mgmt_link_key_info key;
} __packed;
-#define MGMT_EV_CONNECTED 0x000A
+#define MGMT_EV_DEVICE_CONNECTED 0x000A
-#define MGMT_EV_DISCONNECTED 0x000B
+#define MGMT_EV_DEVICE_DISCONNECTED 0x000B
#define MGMT_EV_CONNECT_FAILED 0x000C
struct mgmt_ev_connect_failed {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4eef43c..8d7505a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1643,7 +1643,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
conn->state = BT_CONFIG;
hci_conn_hold(conn);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
- mgmt_connected(hdev, &ev->bdaddr, conn->type,
+ mgmt_device_connected(hdev, &ev->bdaddr, conn->type,
conn->dst_type);
} else
conn->state = BT_CONNECTED;
@@ -1789,7 +1789,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
if (ev->status != 0)
mgmt_disconnect_failed(hdev, &conn->dst, ev->status);
else
- mgmt_disconnected(hdev, &conn->dst, conn->type,
+ mgmt_device_disconnected(hdev, &conn->dst, conn->type,
conn->dst_type);
}
@@ -3188,7 +3188,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff
goto unlock;
}
- mgmt_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type);
+ mgmt_device_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type);
conn->sec_level = BT_SECURITY_LOW;
conn->handle = __le16_to_cpu(ev->handle);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e7bbad8..c8042c6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2464,7 +2464,7 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL);
}
-int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
+int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type)
{
struct mgmt_addr_info ev;
@@ -2472,7 +2472,8 @@ int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
bacpy(&ev.bdaddr, bdaddr);
ev.type = link_to_mgmt(link_type, addr_type);
- return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL);
+ return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, &ev, sizeof(ev),
+ NULL);
}
static void disconnect_rsp(struct pending_cmd *cmd, void *data)
@@ -2509,8 +2510,8 @@ static void remove_keys_rsp(struct pending_cmd *cmd, void *data)
mgmt_pending_remove(cmd);
}
-int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
- u8 addr_type)
+int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
+ u8 link_type, u8 addr_type)
{
struct mgmt_addr_info ev;
struct sock *sk = NULL;
@@ -2521,7 +2522,8 @@ int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
bacpy(&ev.bdaddr, bdaddr);
ev.type = link_to_mgmt(link_type, addr_type);
- err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk);
+ err = mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev),
+ sk);
if (sk)
sock_put(sk);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 03/15] Bluetooth: Add eir_len parameter to mgmt_ev_device_found
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
2012-01-18 18:51 ` [PATCH 01/15] Bluetooth: Fix clearing persistent flags Johan Hedberg
2012-01-18 18:51 ` [PATCH 02/15] Bluetooth: Rename mgmt connected events to match user space Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:04 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 04/15] Bluetooth: Rename eir_has_complete_name to eir_has_data_type Johan Hedberg
` (11 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch add a two byte eir_len parameter mgmt_ev_device_found. Since
it's unlikely that the data will in the short term be much bigger than
conventional EIR lengths just use a small stack based buffer for now to
avoid dynamic memory allocation & freeing.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 2 +-
include/net/bluetooth/mgmt.h | 3 ++-
net/bluetooth/mgmt.c | 28 +++++++++++++++-------------
3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f3fbfd6..33dff8e 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -925,7 +925,7 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
u8 *randomizer, u8 status);
int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 *dev_class, s8 rssi,
- u8 cfm_name, u8 *eir, u8 eir_len);
+ u8 cfm_name, u8 *eir, u16 eir_len);
int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name);
int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status);
int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index d1d13dc..4f166c8 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -368,7 +368,8 @@ struct mgmt_ev_device_found {
__u8 dev_class[3];
__s8 rssi;
__u8 confirm_name;
- __u8 eir[HCI_MAX_EIR_LENGTH];
+ __le16 eir_len;
+ __u8 eir[0];
} __packed;
#define MGMT_EV_REMOTE_NAME 0x0012
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c8042c6..b7e7fdf 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2782,27 +2782,29 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 *dev_class, s8 rssi,
- u8 cfm_name, u8 *eir, u8 eir_len)
+ u8 cfm_name, u8 *eir, u16 eir_len)
{
- struct mgmt_ev_device_found ev;
+ char buf[512];
+ struct mgmt_ev_device_found *ev = (void *) buf;
+ size_t ev_size = sizeof(*ev) + eir_len;
- if (eir_len > sizeof(ev.eir))
+ if (ev_size > sizeof(buf))
return -EINVAL;
- memset(&ev, 0, sizeof(ev));
+ bacpy(&ev->addr.bdaddr, bdaddr);
+ ev->addr.type = link_to_mgmt(link_type, addr_type);
+ ev->rssi = rssi;
+ ev->confirm_name = cfm_name;
- bacpy(&ev.addr.bdaddr, bdaddr);
- ev.addr.type = link_to_mgmt(link_type, addr_type);
- ev.rssi = rssi;
- ev.confirm_name = cfm_name;
-
- if (eir)
- memcpy(ev.eir, eir, eir_len);
+ if (eir_len > 0) {
+ put_unaligned_le16(eir_len, &ev->eir_len);
+ memcpy(ev->eir, eir, eir_len);
+ }
if (dev_class)
- memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class));
+ memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class));
- return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL);
+ return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
}
int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name)
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 03/15] Bluetooth: Add eir_len parameter to mgmt_ev_device_found
2012-01-18 18:51 ` [PATCH 03/15] Bluetooth: Add eir_len parameter to mgmt_ev_device_found Johan Hedberg
@ 2012-01-18 19:04 ` Marcel Holtmann
0 siblings, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:04 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch add a two byte eir_len parameter mgmt_ev_device_found. Since
> it's unlikely that the data will in the short term be much bigger than
> conventional EIR lengths just use a small stack based buffer for now to
> avoid dynamic memory allocation & freeing.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 2 +-
> include/net/bluetooth/mgmt.h | 3 ++-
> net/bluetooth/mgmt.c | 28 +++++++++++++++-------------
> 3 files changed, 18 insertions(+), 15 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 04/15] Bluetooth: Rename eir_has_complete_name to eir_has_data_type
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (2 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 03/15] Bluetooth: Add eir_len parameter to mgmt_ev_device_found Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:05 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 05/15] Bluetooth: Add missing EIR defines to hci.h Johan Hedberg
` (10 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This allows for other uses such as checking for an embedded class of
device value in order to decide whether to append the class or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/hci_event.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 8d7505a..ea2ec61 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2842,7 +2842,7 @@ static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *s
BT_DBG("%s status %d", hdev->name, ev->status);
}
-static inline bool eir_has_complete_name(u8 *data, size_t data_len)
+static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
{
u8 field_len;
size_t parsed;
@@ -2858,7 +2858,7 @@ static inline bool eir_has_complete_name(u8 *data, size_t data_len)
if (parsed > data_len)
break;
- if (data[1] == EIR_NAME_COMPLETE)
+ if (data[1] == type)
return true;
data += field_len + 1;
@@ -2893,8 +2893,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
data.ssp_mode = 0x01;
if (test_bit(HCI_MGMT, &hdev->dev_flags))
- name_known = eir_has_complete_name(info->data,
- sizeof(info->data));
+ name_known = eir_has_data_type(info->data,
+ sizeof(info->data),
+ EIR_NAME_COMPLETE);
else
name_known = true;
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 05/15] Bluetooth: Add missing EIR defines to hci.h
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (3 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 04/15] Bluetooth: Rename eir_has_complete_name to eir_has_data_type Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:05 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 06/15] Bluetooth: Move eir_has_data_field to hci_core.h Johan Hedberg
` (9 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds missing EIR defines (as specified in the Bluetooth
Assigned Numbers document) to hci.h.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 8499307..dd2cc6c 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -296,6 +296,9 @@ enum {
#define EIR_NAME_SHORT 0x08 /* shortened local name */
#define EIR_NAME_COMPLETE 0x09 /* complete local name */
#define EIR_TX_POWER 0x0A /* transmit power level */
+#define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
+#define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */
+#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
#define EIR_DEVICE_ID 0x10 /* device ID */
/* ----- HCI Commands ---- */
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 06/15] Bluetooth: Move eir_has_data_field to hci_core.h
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (4 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 05/15] Bluetooth: Add missing EIR defines to hci.h Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:06 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found Johan Hedberg
` (8 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This makes the function accessible from all places it's needed (e.g.
mgmt.c and hci_event.c).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 25 +++++++++++++++++++++++++
net/bluetooth/hci_event.c | 25 -------------------------
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 33dff8e..393bb73 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -868,6 +868,31 @@ static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
read_unlock(&hci_cb_list_lock);
}
+static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
+{
+ u8 field_len;
+ size_t parsed;
+
+ for (parsed = 0; parsed < data_len - 1; parsed += field_len) {
+ field_len = data[0];
+
+ if (field_len == 0)
+ break;
+
+ parsed += field_len + 1;
+
+ if (parsed > data_len)
+ break;
+
+ if (data[1] == type)
+ return true;
+
+ data += field_len + 1;
+ }
+
+ return false;
+}
+
int hci_register_cb(struct hci_cb *hcb);
int hci_unregister_cb(struct hci_cb *hcb);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ea2ec61..a50e857 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2842,31 +2842,6 @@ static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *s
BT_DBG("%s status %d", hdev->name, ev->status);
}
-static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
-{
- u8 field_len;
- size_t parsed;
-
- for (parsed = 0; parsed < data_len - 1; parsed += field_len) {
- field_len = data[0];
-
- if (field_len == 0)
- break;
-
- parsed += field_len + 1;
-
- if (parsed > data_len)
- break;
-
- if (data[1] == type)
- return true;
-
- data += field_len + 1;
- }
-
- return false;
-}
-
static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct inquiry_data data;
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (5 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 06/15] Bluetooth: Move eir_has_data_field to hci_core.h Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:08 ` Marcel Holtmann
` (2 more replies)
2012-01-18 18:51 ` [PATCH 08/15] Bluetooth: Rename conn->pend to conn->flags Johan Hedberg
` (7 subsequent siblings)
14 siblings, 3 replies; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
There's no need to have a separate device class field since the same
information can be encoded into the EIR data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 11 +++++++++++
include/net/bluetooth/mgmt.h | 1 -
net/bluetooth/mgmt.c | 20 +++++++++++++-------
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 393bb73..02aa0f9 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -893,6 +893,17 @@ static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
return false;
}
+static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
+ u16 data_len)
+{
+ eir[eir_len++] = sizeof(type) + data_len;
+ eir[eir_len++] = type;
+ memcpy(&eir[eir_len], data, data_len);
+ eir_len += data_len;
+
+ return eir_len;
+}
+
int hci_register_cb(struct hci_cb *hcb);
int hci_unregister_cb(struct hci_cb *hcb);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 4f166c8..bdace52 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -365,7 +365,6 @@ struct mgmt_ev_auth_failed {
#define MGMT_EV_DEVICE_FOUND 0x0011
struct mgmt_ev_device_found {
struct mgmt_addr_info addr;
- __u8 dev_class[3];
__s8 rssi;
__u8 confirm_name;
__le16 eir_len;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b7e7fdf..bec64c9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2786,23 +2786,29 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
{
char buf[512];
struct mgmt_ev_device_found *ev = (void *) buf;
- size_t ev_size = sizeof(*ev) + eir_len;
+ size_t ev_size;
- if (ev_size > sizeof(buf))
+ /* Leave 5 bytes for a potential CoD field */
+ if (sizeof(*ev) + eir_len + 5 > sizeof(buf))
return -EINVAL;
+ memset(buf, 0, sizeof(buf));
+
bacpy(&ev->addr.bdaddr, bdaddr);
ev->addr.type = link_to_mgmt(link_type, addr_type);
ev->rssi = rssi;
ev->confirm_name = cfm_name;
- if (eir_len > 0) {
- put_unaligned_le16(eir_len, &ev->eir_len);
+ if (eir_len > 0)
memcpy(ev->eir, eir, eir_len);
- }
- if (dev_class)
- memcpy(ev->dev_class, dev_class, sizeof(ev->dev_class));
+ if (dev_class && !eir_has_data_type(ev->eir, eir_len, EIR_CLASS_OF_DEV))
+ eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
+ dev_class, 3);
+
+ put_unaligned_le16(eir_len, &ev->eir_len);
+
+ ev_size = sizeof(*ev) + eir_len;
return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
}
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 18:51 ` [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found Johan Hedberg
@ 2012-01-18 19:08 ` Marcel Holtmann
2012-01-18 19:18 ` Anderson Lizardo
2012-01-19 9:26 ` Andrei Emeltchenko
2 siblings, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:08 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> There's no need to have a separate device class field since the same
> information can be encoded into the EIR data.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 11 +++++++++++
> include/net/bluetooth/mgmt.h | 1 -
> net/bluetooth/mgmt.c | 20 +++++++++++++-------
> 3 files changed, 24 insertions(+), 8 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 18:51 ` [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found Johan Hedberg
2012-01-18 19:08 ` Marcel Holtmann
@ 2012-01-18 19:18 ` Anderson Lizardo
2012-01-18 20:29 ` Johan Hedberg
2012-01-19 9:26 ` Andrei Emeltchenko
2 siblings, 1 reply; 39+ messages in thread
From: Anderson Lizardo @ 2012-01-18 19:18 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
On Wed, Jan 18, 2012 at 2:51 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
> + u16 data_len)
> +{
> + eir[eir_len++] = sizeof(type) + data_len;
Isn't it better to have data_len as u8? It is impossible for a EIR or
AD entry to have more than 255 octets (given the length field is one
octet).
> + eir[eir_len++] = type;
> + memcpy(&eir[eir_len], data, data_len);
> + eir_len += data_len;
> +
> + return eir_len;
> +}
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 19:18 ` Anderson Lizardo
@ 2012-01-18 20:29 ` Johan Hedberg
2012-01-18 20:40 ` Anderson Lizardo
0 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 20:29 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Lizardo,
On Wed, Jan 18, 2012, Anderson Lizardo wrote:
> Hi Johan,
>
> On Wed, Jan 18, 2012 at 2:51 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> > +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
> > + u16 data_len)
> > +{
> > + eir[eir_len++] = sizeof(type) + data_len;
>
> Isn't it better to have data_len as u8? It is impossible for a EIR or
> AD entry to have more than 255 octets (given the length field is one
> octet).
Since we've taken up the habit of appending items to the data (such as
the device class) before passing it on to user space we thought it'd be
more future proof to use two octets. The mgmt messages use two octets as
well. I was also initially of the opinion that one should be enough but
Marcel convinced me that two is better since we're living very close to
the limit and would have to break the API if at any point in the future
we suddenly need more space.
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 20:29 ` Johan Hedberg
@ 2012-01-18 20:40 ` Anderson Lizardo
2012-01-18 20:58 ` Johan Hedberg
0 siblings, 1 reply; 39+ messages in thread
From: Anderson Lizardo @ 2012-01-18 20:40 UTC (permalink / raw)
To: Anderson Lizardo, linux-bluetooth
Hi Johan,
On Wed, Jan 18, 2012 at 4:29 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Lizardo,
>
> On Wed, Jan 18, 2012, Anderson Lizardo wrote:
>> Hi Johan,
>>
>> On Wed, Jan 18, 2012 at 2:51 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
>> > +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
>> > + u16 data_len)
>> > +{
>> > + eir[eir_len++] = sizeof(type) + data_len;
>>
>> Isn't it better to have data_len as u8? It is impossible for a EIR or
>> AD entry to have more than 255 octets (given the length field is one
>> octet).
>
> Since we've taken up the habit of appending items to the data (such as
> the device class) before passing it on to user space we thought it'd be
> more future proof to use two octets. The mgmt messages use two octets as
> well. I was also initially of the opinion that one should be enough but
> Marcel convinced me that two is better since we're living very close to
> the limit and would have to break the API if at any point in the future
> we suddenly need more space.
While for mgmt it is ok to use two octets (I was aware of this
rationale), I was referring more specifically to the snippet above,
where you copy a u16 value to a u8 eir[] entry.
While you can append many EIR fields (and thus have a local EIR blob
with total size greater than you would normally send over the air),
each EIR field you append is still limited to 255 bytes as per spec.
This means it is okay on the function above to "eir_len" be u16, but I
think "data_len" is not.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 20:40 ` Anderson Lizardo
@ 2012-01-18 20:58 ` Johan Hedberg
0 siblings, 0 replies; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 20:58 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Lizardo,
On Wed, Jan 18, 2012, Anderson Lizardo wrote:
> >> On Wed, Jan 18, 2012 at 2:51 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> >> > +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
> >> > + u16 data_len)
> >> > +{
> >> > + eir[eir_len++] = sizeof(type) + data_len;
> >>
> >> Isn't it better to have data_len as u8? It is impossible for a EIR or
> >> AD entry to have more than 255 octets (given the length field is one
> >> octet).
> >
> > Since we've taken up the habit of appending items to the data (such as
> > the device class) before passing it on to user space we thought it'd be
> > more future proof to use two octets. The mgmt messages use two octets as
> > well. I was also initially of the opinion that one should be enough but
> > Marcel convinced me that two is better since we're living very close to
> > the limit and would have to break the API if at any point in the future
> > we suddenly need more space.
>
> While for mgmt it is ok to use two octets (I was aware of this
> rationale), I was referring more specifically to the snippet above,
> where you copy a u16 value to a u8 eir[] entry.
>
> While you can append many EIR fields (and thus have a local EIR blob
> with total size greater than you would normally send over the air),
> each EIR field you append is still limited to 255 bytes as per spec.
> This means it is okay on the function above to "eir_len" be u16, but I
> think "data_len" is not.
Yes, you're completely right (and I should have paid more attention to
what exactly you were referring to). I'll fix it.
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found
2012-01-18 18:51 ` [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found Johan Hedberg
2012-01-18 19:08 ` Marcel Holtmann
2012-01-18 19:18 ` Anderson Lizardo
@ 2012-01-19 9:26 ` Andrei Emeltchenko
2 siblings, 0 replies; 39+ messages in thread
From: Andrei Emeltchenko @ 2012-01-19 9:26 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
On Wed, Jan 18, 2012 at 08:51:49PM +0200, Johan Hedberg wrote:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> There's no need to have a separate device class field since the same
> information can be encoded into the EIR data.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 11 +++++++++++
> include/net/bluetooth/mgmt.h | 1 -
> net/bluetooth/mgmt.c | 20 +++++++++++++-------
> 3 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 393bb73..02aa0f9 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -893,6 +893,17 @@ static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
> return false;
> }
>
> +static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
> + u16 data_len)
> +{
> + eir[eir_len++] = sizeof(type) + data_len;
> + eir[eir_len++] = type;
Would it be better to use struct eir_info/hdr and assign fields len and
type? I saw already several places where this might improve readability
and remove magic formulas (like "+ 2 - 1").
Best regards
Andrei Emeltchenko
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 08/15] Bluetooth: Rename conn->pend to conn->flags
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (6 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 07/15] Bluetooth: Merge device class into the EIR data in mgmt_ev_device_found Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:12 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags Johan Hedberg
` (6 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
These flags can and will be used for more general purpose values than
just pending state transitions so the more common name "flags" makes
more sense than "pend".
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 6 +++---
net/bluetooth/hci_conn.c | 20 ++++++++++----------
net/bluetooth/hci_event.c | 36 ++++++++++++++++++------------------
net/bluetooth/l2cap_core.c | 2 +-
net/bluetooth/smp.c | 19 +++++++++----------
5 files changed, 41 insertions(+), 42 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 02aa0f9..c8ae176 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -300,7 +300,7 @@ struct hci_conn {
__u8 io_capability;
__u8 power_save;
__u16 disc_timeout;
- unsigned long pend;
+ unsigned long flags;
__u8 remote_cap;
__u8 remote_oob;
@@ -764,7 +764,7 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)
if (conn->type != ACL_LINK && conn->type != LE_LINK)
return;
- if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))
+ if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
return;
encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00;
@@ -805,7 +805,7 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
hci_proto_auth_cfm(conn, status);
- if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))
+ if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
return;
encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 3db4324..8a4678a 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -337,7 +337,7 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
hci_send_cmd(hdev, HCI_OP_SNIFF_SUBRATE, sizeof(cp), &cp);
}
- if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
struct hci_cp_sniff_mode cp;
cp.handle = cpu_to_le16(conn->handle);
cp.max_interval = cpu_to_le16(hdev->sniff_max_interval);
@@ -589,9 +589,9 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
acl->power_save = 1;
hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON);
- if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) {
+ if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->flags)) {
/* defer SCO setup until mode change completed */
- set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->pend);
+ set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->flags);
return sco;
}
@@ -633,13 +633,13 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
conn->auth_type = auth_type;
- if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_auth_requested cp;
cp.handle = cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
sizeof(cp), &cp);
if (conn->key_type != 0xff)
- set_bit(HCI_CONN_REAUTH_PEND, &conn->pend);
+ set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
}
return 0;
@@ -650,7 +650,7 @@ static void hci_conn_encrypt(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
- if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = cpu_to_le16(conn->handle);
cp.encrypt = 0x01;
@@ -700,7 +700,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
goto encrypt;
auth:
- if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend))
+ if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
return 0;
if (!hci_conn_auth(conn, sec_level, auth_type))
@@ -735,7 +735,7 @@ int hci_conn_change_link_key(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
- if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_change_conn_link_key cp;
cp.handle = cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, HCI_OP_CHANGE_CONN_LINK_KEY,
@@ -754,7 +754,7 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role)
if (!role && conn->link_mode & HCI_LM_MASTER)
return 1;
- if (!test_and_set_bit(HCI_CONN_RSWITCH_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_RSWITCH_PEND, &conn->flags)) {
struct hci_cp_switch_role cp;
bacpy(&cp.bdaddr, &conn->dst);
cp.role = role;
@@ -781,7 +781,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
if (!conn->power_save && !force_active)
goto timer;
- if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
struct hci_cp_exit_sniff_mode cp;
cp.handle = cpu_to_le16(conn->handle);
hci_send_cmd(hdev, HCI_OP_EXIT_SNIFF_MODE, sizeof(cp), &cp);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index a50e857..373ae73 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1344,7 +1344,7 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
if (!hci_outgoing_auth_needed(hdev, conn))
goto unlock;
- if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_auth_requested cp;
cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
@@ -1461,9 +1461,9 @@ static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status)
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
if (conn) {
- clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend);
+ clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags);
- if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend))
+ if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
hci_sco_setup(conn, status);
}
@@ -1488,9 +1488,9 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
if (conn) {
- clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend);
+ clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags);
- if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend))
+ if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
hci_sco_setup(conn, status);
}
@@ -1817,7 +1817,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (!ev->status) {
if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) &&
- test_bit(HCI_CONN_REAUTH_PEND, &conn->pend)) {
+ test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible.");
} else {
conn->link_mode |= HCI_LM_AUTH;
@@ -1827,8 +1827,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
mgmt_auth_failed(hdev, &conn->dst, ev->status);
}
- clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
- clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend);
+ clear_bit(HCI_CONN_AUTH_PEND, &conn->flags);
+ clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) {
@@ -1850,7 +1850,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
hci_conn_put(conn);
}
- if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
+ if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) {
if (!ev->status) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
@@ -1858,7 +1858,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp),
&cp);
} else {
- clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
+ clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
hci_encrypt_cfm(conn, ev->status, 0x00);
}
}
@@ -1892,7 +1892,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb
if (!hci_outgoing_auth_needed(hdev, conn))
goto unlock;
- if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
+ if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_auth_requested cp;
cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
@@ -1923,7 +1923,7 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *
conn->link_mode &= ~HCI_LM_ENCRYPT;
}
- clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
+ clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
if (!ev->status)
@@ -1952,7 +1952,7 @@ static inline void hci_change_link_key_complete_evt(struct hci_dev *hdev, struct
if (!ev->status)
conn->link_mode |= HCI_LM_SECURE;
- clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
+ clear_bit(HCI_CONN_AUTH_PEND, &conn->flags);
hci_key_change_cfm(conn, ev->status);
}
@@ -2336,7 +2336,7 @@ static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb
conn->link_mode |= HCI_LM_MASTER;
}
- clear_bit(HCI_CONN_RSWITCH_PEND, &conn->pend);
+ clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags);
hci_role_switch_cfm(conn, ev->status, ev->role);
}
@@ -2474,14 +2474,14 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb
conn->mode = ev->mode;
conn->interval = __le16_to_cpu(ev->interval);
- if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) {
+ if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
if (conn->mode == HCI_CM_ACTIVE)
conn->power_save = 1;
else
conn->power_save = 0;
}
- if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->pend))
+ if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
hci_sco_setup(conn, ev->status);
}
@@ -3013,7 +3013,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
/* If we're not the initiators request authorization to
* proceed from user space (mgmt_user_confirm with
* confirm_hint set to 1). */
- if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
+ if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
BT_DBG("Confirming auto-accept as acceptor");
confirm_hint = 1;
goto confirm;
@@ -3074,7 +3074,7 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_
* initiated the authentication. A traditional auth_complete
* event gets always produced as initiator and is also mapped to
* the mgmt_auth_failed event */
- if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend) && ev->status != 0)
+ if (!test_bit(HCI_CONN_AUTH_PEND, &conn->flags) && ev->status != 0)
mgmt_auth_failed(hdev, &conn->dst, ev->status);
hci_conn_put(conn);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0087db8..e42999c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1020,7 +1020,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)
__cancel_delayed_work(&conn->info_timer);
- if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) {
+ if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) {
__cancel_delayed_work(&conn->security_timer);
smp_chan_destroy(conn);
}
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 65a9024..e08fe6c 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -261,7 +261,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason),
&reason);
- clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->pend);
+ clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags);
mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason);
cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);
@@ -449,7 +449,7 @@ static void random_work(struct work_struct *work)
memset(stk + smp->smp_key_size, 0,
SMP_MAX_ENC_KEY_SIZE - smp->smp_key_size);
- if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend)) {
+ if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) {
reason = SMP_UNSPECIFIED;
goto error;
}
@@ -506,7 +506,7 @@ void smp_chan_destroy(struct l2cap_conn *conn)
{
struct smp_chan *smp = conn->smp_chan;
- clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend);
+ clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags);
if (smp->tfm)
crypto_free_blkcipher(smp->tfm);
@@ -571,7 +571,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
if (conn->hcon->link_mode & HCI_LM_MASTER)
return SMP_CMD_NOTSUPP;
- if (!test_and_set_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend))
+ if (!test_and_set_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags))
smp = smp_chan_create(conn);
smp = conn->smp_chan;
@@ -707,8 +707,7 @@ static u8 smp_ltk_encrypt(struct l2cap_conn *conn)
if (!key)
return 0;
- if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND,
- &hcon->pend))
+ if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags))
return 1;
master = (void *) key->data;
@@ -733,7 +732,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
if (smp_ltk_encrypt(conn))
return 0;
- if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend))
+ if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags))
return 0;
smp = smp_chan_create(conn);
@@ -772,7 +771,7 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
if (smp_ltk_encrypt(conn))
goto done;
- if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend))
+ if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags))
return 0;
smp = smp_chan_create(conn);
@@ -908,7 +907,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
BT_DBG("conn %p force %d", conn, force);
- if (!test_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend))
+ if (!test_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags))
return 0;
rsp = (void *) &smp->prsp[1];
@@ -982,7 +981,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
}
if (conn->hcon->out || force) {
- clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend);
+ clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags);
cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);
}
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 08/15] Bluetooth: Rename conn->pend to conn->flags
2012-01-18 18:51 ` [PATCH 08/15] Bluetooth: Rename conn->pend to conn->flags Johan Hedberg
@ 2012-01-18 19:12 ` Marcel Holtmann
0 siblings, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:12 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> These flags can and will be used for more general purpose values than
> just pending state transitions so the more common name "flags" makes
> more sense than "pend".
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 6 +++---
> net/bluetooth/hci_conn.c | 20 ++++++++++----------
> net/bluetooth/hci_event.c | 36 ++++++++++++++++++------------------
> net/bluetooth/l2cap_core.c | 2 +-
> net/bluetooth/smp.c | 19 +++++++++----------
> 5 files changed, 41 insertions(+), 42 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (7 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 08/15] Bluetooth: Rename conn->pend to conn->flags Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:12 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled Johan Hedberg
` (5 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
Now that the flags member of struct hci_conn is supposed to accommodate
any boolean type values we can easily merge all boolean members into it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 6 +++---
net/bluetooth/hci_conn.c | 15 +++++++++------
net/bluetooth/hci_event.c | 21 +++++++++++++--------
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c8ae176..5f6cb35 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -286,7 +286,6 @@ struct hci_conn {
__u8 attempt;
__u8 dev_class[3];
__u8 features[8];
- __u8 ssp_mode;
__u16 interval;
__u16 pkt_type;
__u16 link_policy;
@@ -298,12 +297,10 @@ struct hci_conn {
__u8 pin_length;
__u8 enc_key_size;
__u8 io_capability;
- __u8 power_save;
__u16 disc_timeout;
unsigned long flags;
__u8 remote_cap;
- __u8 remote_oob;
__u8 remote_auth;
unsigned int sent;
@@ -409,6 +406,9 @@ enum {
HCI_CONN_MODE_CHANGE_PEND,
HCI_CONN_SCO_SETUP_PEND,
HCI_CONN_LE_SMP_PEND,
+ HCI_CONN_SSP_SUPPORT,
+ HCI_CONN_POWER_SAVE,
+ HCI_CONN_REMOTE_OOB,
};
static inline void hci_conn_hash_init(struct hci_dev *hdev)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 8a4678a..566254f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -105,7 +105,8 @@ void hci_acl_connect(struct hci_conn *conn)
}
memcpy(conn->dev_class, ie->data.dev_class, 3);
- conn->ssp_mode = ie->data.ssp_mode;
+ if (ie->data.ssp_mode > 0)
+ set_bit(HCI_CONN_SSP_SUPPORT, &conn->flags);
}
cp.pkt_type = cpu_to_le16(conn->pkt_type);
@@ -386,7 +387,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
conn->remote_auth = 0xff;
conn->key_type = 0xff;
- conn->power_save = 1;
+ set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
switch (type) {
@@ -586,7 +587,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
if (acl->state == BT_CONNECTED &&
(sco->state == BT_OPEN || sco->state == BT_CLOSED)) {
- acl->power_save = 1;
+ set_bit(HCI_CONN_POWER_SAVE, &acl->flags);
hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON);
if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->flags)) {
@@ -607,7 +608,8 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
- if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0 &&
+ if (test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags) &&
+ conn->hdev->ssp_mode > 0 &&
!(conn->link_mode & HCI_LM_ENCRYPT))
return 0;
@@ -671,7 +673,8 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
/* For non 2.1 devices and low security level we don't need the link
key. */
if (sec_level == BT_SECURITY_LOW &&
- (!conn->ssp_mode || !conn->hdev->ssp_mode))
+ (!test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags) ||
+ !conn->hdev->ssp_mode))
return 1;
/* For other security levels we need the link key. */
@@ -778,7 +781,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
if (conn->mode != HCI_CM_SNIFF)
goto timer;
- if (!conn->power_save && !force_active)
+ if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active)
goto timer;
if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 373ae73..e592ddc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1264,7 +1264,8 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev,
/* Only request authentication for SSP connections or non-SSP
* devices with sec_level HIGH or if MITM protection is requested */
- if (!(hdev->ssp_mode > 0 && conn->ssp_mode > 0) &&
+ if (!(hdev->ssp_mode > 0 &&
+ test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags)) &&
conn->pending_sec_level != BT_SECURITY_HIGH &&
!(conn->auth_type & 0x01))
return 0;
@@ -1816,7 +1817,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
goto unlock;
if (!ev->status) {
- if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) &&
+ if (!(test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags) &&
+ hdev->ssp_mode > 0) &&
test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible.");
} else {
@@ -1831,7 +1833,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
- if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) {
+ if (!ev->status && hdev->ssp_mode > 0 &&
+ test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags)) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
cp.encrypt = 0x01;
@@ -2476,9 +2479,9 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb
if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {
if (conn->mode == HCI_CM_ACTIVE)
- conn->power_save = 1;
+ set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
else
- conn->power_save = 0;
+ clear_bit(HCI_CONN_POWER_SAVE, &conn->flags);
}
if (test_and_clear_bit(HCI_CONN_SCO_SETUP_PEND, &conn->flags))
@@ -2751,7 +2754,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
if (ie)
ie->data.ssp_mode = (ev->features[0] & 0x01);
- conn->ssp_mode = (ev->features[0] & 0x01);
+ if (ev->features[0] & 0x01)
+ set_bit(HCI_CONN_SSP_SUPPORT, &conn->flags);
}
if (conn->state != BT_CONFIG)
@@ -2930,7 +2934,7 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
conn->auth_type = hci_get_auth_req(conn);
cp.authentication = conn->auth_type;
- if ((conn->out == 0x01 || conn->remote_oob == 0x01) &&
+ if ((conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)) &&
hci_find_remote_oob_data(hdev, &conn->dst))
cp.oob_data = 0x01;
else
@@ -2966,8 +2970,9 @@ static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *s
goto unlock;
conn->remote_cap = ev->capability;
- conn->remote_oob = ev->oob_data;
conn->remote_auth = ev->authentication;
+ if (ev->oob_data)
+ set_bit(HCI_CONN_REMOTE_OOB, &conn->flags);
unlock:
hci_dev_unlock(hdev);
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-18 18:51 ` [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags Johan Hedberg
@ 2012-01-18 19:12 ` Marcel Holtmann
2012-01-18 19:25 ` Johan Hedberg
0 siblings, 1 reply; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:12 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> Now that the flags member of struct hci_conn is supposed to accommodate
> any boolean type values we can easily merge all boolean members into it.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 6 +++---
> net/bluetooth/hci_conn.c | 15 +++++++++------
> net/bluetooth/hci_event.c | 21 +++++++++++++--------
> 3 files changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index c8ae176..5f6cb35 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -286,7 +286,6 @@ struct hci_conn {
> __u8 attempt;
> __u8 dev_class[3];
> __u8 features[8];
> - __u8 ssp_mode;
> __u16 interval;
> __u16 pkt_type;
> __u16 link_policy;
> @@ -298,12 +297,10 @@ struct hci_conn {
> __u8 pin_length;
> __u8 enc_key_size;
> __u8 io_capability;
> - __u8 power_save;
> __u16 disc_timeout;
> unsigned long flags;
>
> __u8 remote_cap;
> - __u8 remote_oob;
> __u8 remote_auth;
>
> unsigned int sent;
> @@ -409,6 +406,9 @@ enum {
> HCI_CONN_MODE_CHANGE_PEND,
> HCI_CONN_SCO_SETUP_PEND,
> HCI_CONN_LE_SMP_PEND,
> + HCI_CONN_SSP_SUPPORT,
didn't we agree on naming this SSP_ENABLED?
> + HCI_CONN_POWER_SAVE,
> + HCI_CONN_REMOTE_OOB,
> };
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-18 19:12 ` Marcel Holtmann
@ 2012-01-18 19:25 ` Johan Hedberg
2012-01-18 19:31 ` Marcel Holtmann
0 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 19:25 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
Hi Marcel,
On Wed, Jan 18, 2012, Marcel Holtmann wrote:
> > unsigned int sent;
> > @@ -409,6 +406,9 @@ enum {
> > HCI_CONN_MODE_CHANGE_PEND,
> > HCI_CONN_SCO_SETUP_PEND,
> > HCI_CONN_LE_SMP_PEND,
> > + HCI_CONN_SSP_SUPPORT,
>
> didn't we agree on naming this SSP_ENABLED?
We agreed about that for hci_dev but not for hci_conn (or then I
misunderstood you). I used "support" here since it means that the remote
device can support it if we have it enabled (and hence "enabled" for the
hci_dev flag). But I can change it anyway you like.
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags
2012-01-18 19:25 ` Johan Hedberg
@ 2012-01-18 19:31 ` Marcel Holtmann
0 siblings, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:31 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> > > unsigned int sent;
> > > @@ -409,6 +406,9 @@ enum {
> > > HCI_CONN_MODE_CHANGE_PEND,
> > > HCI_CONN_SCO_SETUP_PEND,
> > > HCI_CONN_LE_SMP_PEND,
> > > + HCI_CONN_SSP_SUPPORT,
> >
> > didn't we agree on naming this SSP_ENABLED?
>
> We agreed about that for hci_dev but not for hci_conn (or then I
> misunderstood you). I used "support" here since it means that the remote
> device can support it if we have it enabled (and hence "enabled" for the
> hci_dev flag). But I can change it anyway you like.
since this is the host features of the remote side, it does actually
mean it is enabled. So using SSP_ENABLED is actually better.
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (8 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 09/15] Bluetooth: Merge boolean members of struct hci_conn into flags Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:14 ` Marcel Holtmann
2012-01-19 9:30 ` Andrei Emeltchenko
2012-01-18 18:51 ` [PATCH 11/15] Bluetooth: Convert hdev->ssp_mode to a flag Johan Hedberg
` (4 subsequent siblings)
14 siblings, 2 replies; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
It's a very common test to see if both the local and the remote device
have SSP enabled. By creating a simple function to test this we can
shorten many if-statements in the code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 7 +++++++
net/bluetooth/hci_conn.c | 8 ++------
net/bluetooth/hci_event.c | 9 +++------
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 5f6cb35..f2ccdae 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -411,6 +411,13 @@ enum {
HCI_CONN_REMOTE_OOB,
};
+static inline bool hci_conn_ssp_support(struct hci_conn *conn)
+{
+ struct hci_dev *hdev = conn->hdev;
+ return (hdev->ssp_mode > 0 &&
+ test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags));
+}
+
static inline void hci_conn_hash_init(struct hci_dev *hdev)
{
struct hci_conn_hash *h = &hdev->conn_hash;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 566254f..c1fc6a9 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -608,9 +608,7 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
- if (test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags) &&
- conn->hdev->ssp_mode > 0 &&
- !(conn->link_mode & HCI_LM_ENCRYPT))
+ if (hci_conn_ssp_support(conn) && !(conn->link_mode & HCI_LM_ENCRYPT))
return 0;
return 1;
@@ -672,9 +670,7 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
/* For non 2.1 devices and low security level we don't need the link
key. */
- if (sec_level == BT_SECURITY_LOW &&
- (!test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags) ||
- !conn->hdev->ssp_mode))
+ if (sec_level == BT_SECURITY_LOW && !hci_conn_ssp_support(conn))
return 1;
/* For other security levels we need the link key. */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index e592ddc..aee417c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1264,8 +1264,7 @@ static int hci_outgoing_auth_needed(struct hci_dev *hdev,
/* Only request authentication for SSP connections or non-SSP
* devices with sec_level HIGH or if MITM protection is requested */
- if (!(hdev->ssp_mode > 0 &&
- test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags)) &&
+ if (!hci_conn_ssp_support(conn) &&
conn->pending_sec_level != BT_SECURITY_HIGH &&
!(conn->auth_type & 0x01))
return 0;
@@ -1817,8 +1816,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
goto unlock;
if (!ev->status) {
- if (!(test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags) &&
- hdev->ssp_mode > 0) &&
+ if (!hci_conn_ssp_support(conn) &&
test_bit(HCI_CONN_REAUTH_PEND, &conn->flags)) {
BT_INFO("re-auth of legacy device is not possible.");
} else {
@@ -1833,8 +1831,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
clear_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
if (conn->state == BT_CONFIG) {
- if (!ev->status && hdev->ssp_mode > 0 &&
- test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags)) {
+ if (!ev->status && hci_conn_ssp_support(conn)) {
struct hci_cp_set_conn_encrypt cp;
cp.handle = ev->handle;
cp.encrypt = 0x01;
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled
2012-01-18 18:51 ` [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled Johan Hedberg
@ 2012-01-18 19:14 ` Marcel Holtmann
2012-01-19 9:30 ` Andrei Emeltchenko
1 sibling, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:14 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> It's a very common test to see if both the local and the remote device
> have SSP enabled. By creating a simple function to test this we can
> shorten many if-statements in the code.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 7 +++++++
> net/bluetooth/hci_conn.c | 8 ++------
> net/bluetooth/hci_event.c | 9 +++------
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 5f6cb35..f2ccdae 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -411,6 +411,13 @@ enum {
> HCI_CONN_REMOTE_OOB,
> };
>
> +static inline bool hci_conn_ssp_support(struct hci_conn *conn)
> +{
> + struct hci_dev *hdev = conn->hdev;
> + return (hdev->ssp_mode > 0 &&
> + test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags));
> +}
why is hdev->ssp_mode not converted into a flag first?
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled
2012-01-18 18:51 ` [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled Johan Hedberg
2012-01-18 19:14 ` Marcel Holtmann
@ 2012-01-19 9:30 ` Andrei Emeltchenko
2012-01-19 9:39 ` Johan Hedberg
1 sibling, 1 reply; 39+ messages in thread
From: Andrei Emeltchenko @ 2012-01-19 9:30 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
On Wed, Jan 18, 2012 at 08:51:52PM +0200, Johan Hedberg wrote:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> It's a very common test to see if both the local and the remote device
> have SSP enabled. By creating a simple function to test this we can
> shorten many if-statements in the code.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 7 +++++++
> net/bluetooth/hci_conn.c | 8 ++------
> net/bluetooth/hci_event.c | 9 +++------
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 5f6cb35..f2ccdae 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -411,6 +411,13 @@ enum {
> HCI_CONN_REMOTE_OOB,
> };
>
> +static inline bool hci_conn_ssp_support(struct hci_conn *conn)
Maybe matter of taste but cold this be named hci_conn_ssp_supported ?
Then in if condition below it would be seen more natural and similar to
other "-ed" functions.
Best regards
Andrei Emeltchenko
> + if (hci_conn_ssp_support(conn) && !(conn->link_mode & HCI_LM_ENCRYPT))
> return 0;
^ permalink raw reply [flat|nested] 39+ messages in thread* Re: [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled
2012-01-19 9:30 ` Andrei Emeltchenko
@ 2012-01-19 9:39 ` Johan Hedberg
0 siblings, 0 replies; 39+ messages in thread
From: Johan Hedberg @ 2012-01-19 9:39 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth
Hi Andrei,
On Thu, Jan 19, 2012, Andrei Emeltchenko wrote:
> > +static inline bool hci_conn_ssp_support(struct hci_conn *conn)
>
> Maybe matter of taste but cold this be named hci_conn_ssp_supported ?
> Then in if condition below it would be seen more natural and similar to
> other "-ed" functions.
Based on Marcel's preference for the define names it will be called
hci_conn_ssp_enabled.
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 11/15] Bluetooth: Convert hdev->ssp_mode to a flag
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (9 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 10/15] Bluetooth: Add a convenience function to check for SSP enabled Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:14 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 12/15] Bluetooth: Convert hdev->out to a bool type Johan Hedberg
` (3 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The ssp_mode is essentially just a boolean so it's more appropriate to
have it simply as a flag in hdev->dev_flags.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 1 +
include/net/bluetooth/hci_core.h | 3 +--
net/bluetooth/hci_event.c | 10 ++++++++--
net/bluetooth/mgmt.c | 4 ++--
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index dd2cc6c..cb9097a 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -94,6 +94,7 @@ enum {
HCI_DEBUG_KEYS,
HCI_LE_SCAN,
+ HCI_SSP_ENABLED,
};
/* HCI ioctl defines */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f2ccdae..4440e49 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -144,7 +144,6 @@ struct hci_dev {
__u8 features[8];
__u8 host_features[8];
__u8 commands[64];
- __u8 ssp_mode;
__u8 hci_ver;
__u16 hci_rev;
__u8 lmp_ver;
@@ -414,7 +413,7 @@ enum {
static inline bool hci_conn_ssp_support(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
- return (hdev->ssp_mode > 0 &&
+ return (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags));
}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index aee417c..21ab6e7 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -429,7 +429,10 @@ static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
if (rp->status)
return;
- hdev->ssp_mode = rp->mode;
+ if (rp->mode)
+ set_bit(HCI_SSP_ENABLED, &hdev->flags);
+ else
+ clear_bit(HCI_SSP_ENABLED, &hdev->flags);
}
static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -446,7 +449,10 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
if (!sent)
return;
- hdev->ssp_mode = *((__u8 *) sent);
+ if (*(u8 *) sent)
+ set_bit(HCI_SSP_ENABLED, &hdev->flags);
+ else
+ clear_bit(HCI_SSP_ENABLED, &hdev->flags);
}
static u8 hci_get_inquiry_mode(struct hci_dev *hdev)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index bec64c9..c851579 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -297,7 +297,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_AUTH, &hdev->flags))
settings |= MGMT_SETTING_LINK_SECURITY;
- if (hdev->ssp_mode > 0)
+ if (test_bit(HCI_SSP_ENABLED, &hdev->flags))
settings |= MGMT_SETTING_SSP;
return settings;
@@ -416,7 +416,7 @@ static int update_eir(struct hci_dev *hdev)
if (!(hdev->features[6] & LMP_EXT_INQ))
return 0;
- if (hdev->ssp_mode == 0)
+ if (!test_bit(HCI_SSP_ENABLED, &hdev->flags))
return 0;
if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 12/15] Bluetooth: Convert hdev->out to a bool type
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (10 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 11/15] Bluetooth: Convert hdev->ssp_mode to a flag Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:15 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 13/15] Bluetooth: Update device_connected and device_found events to latest API Johan Hedberg
` (2 subsequent siblings)
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The hdev->out variable is essentially a boolean so the type 'bool' makes
more sense than u8.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 2 +-
net/bluetooth/hci_conn.c | 8 ++++----
net/bluetooth/hci_event.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 4440e49..40efe33 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -281,7 +281,7 @@ struct hci_conn {
__u16 state;
__u8 mode;
__u8 type;
- __u8 out;
+ bool out;
__u8 attempt;
__u8 dev_class[3];
__u8 features[8];
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index c1fc6a9..4fb7b4f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -51,7 +51,7 @@ static void hci_le_connect(struct hci_conn *conn)
struct hci_cp_le_create_conn cp;
conn->state = BT_CONNECT;
- conn->out = 1;
+ conn->out = true;
conn->link_mode |= HCI_LM_MASTER;
conn->sec_level = BT_SECURITY_LOW;
@@ -83,7 +83,7 @@ void hci_acl_connect(struct hci_conn *conn)
BT_DBG("%p", conn);
conn->state = BT_CONNECT;
- conn->out = 1;
+ conn->out = true;
conn->link_mode = HCI_LM_MASTER;
@@ -152,7 +152,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle)
BT_DBG("%p", conn);
conn->state = BT_CONNECT;
- conn->out = 1;
+ conn->out = true;
conn->attempt++;
@@ -170,7 +170,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
BT_DBG("%p", conn);
conn->state = BT_CONNECT;
- conn->out = 1;
+ conn->out = true;
conn->attempt++;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 21ab6e7..f49f64f 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1160,7 +1160,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
if (!conn) {
conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr);
if (conn) {
- conn->out = 1;
+ conn->out = true;
conn->link_mode |= HCI_LM_MASTER;
} else
BT_ERR("No memory for new connection");
@@ -1532,7 +1532,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr);
if (conn) {
conn->dst_type = cp->peer_addr_type;
- conn->out = 1;
+ conn->out = true;
} else {
BT_ERR("No memory for new connection");
}
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* [PATCH 13/15] Bluetooth: Update device_connected and device_found events to latest API
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (11 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 12/15] Bluetooth: Convert hdev->out to a bool type Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:17 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 14/15] Bluetooth: Rename hdev->flags to hdev->compat_flags Johan Hedberg
2012-01-18 18:51 ` [PATCH 15/15] Bluetooth: Rename hdev->dev_flags to hdev-flags Johan Hedberg
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch updates mgmt_ev_device_connected and mgmt_ev_device found to
include an EIR-encoded remote name and class whenever possible. With
this addition the mgmt_ev_remote_name event becomes unnecessary and can
be removed. Since the connected event doesn't map to hci_conn_complete
anymore a HCI_CONN_MGMT_CONNECTED flag is added to track when mgmt has
been notified about a connection.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 7 ++-
include/net/bluetooth/mgmt.h | 17 ++++----
net/bluetooth/hci_event.c | 78 +++++++++++++++++++++++++++-----------
net/bluetooth/mgmt.c | 56 ++++++++++++++++++++-------
4 files changed, 110 insertions(+), 48 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 40efe33..ab1a626 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -408,6 +408,7 @@ enum {
HCI_CONN_SSP_SUPPORT,
HCI_CONN_POWER_SAVE,
HCI_CONN_REMOTE_OOB,
+ HCI_CONN_MGMT_CONNECTED,
};
static inline bool hci_conn_ssp_support(struct hci_conn *conn)
@@ -939,7 +940,8 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status);
int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
u8 persistent);
int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
- u8 addr_type);
+ u8 addr_type, u8 *name, u8 name_len,
+ u8 *dev_class);
int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 link_type, u8 addr_type);
int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status);
@@ -968,7 +970,8 @@ int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
u8 addr_type, u8 *dev_class, s8 rssi,
u8 cfm_name, u8 *eir, u16 eir_len);
-int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name);
+int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
+ u8 addr_type, s8 rssi, u8 *name, u8 name_len);
int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status);
int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status);
int mgmt_discovering(struct hci_dev *hdev, u8 discovering);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index bdace52..6f37983 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -329,6 +329,11 @@ struct mgmt_ev_new_link_key {
} __packed;
#define MGMT_EV_DEVICE_CONNECTED 0x000A
+struct mgmt_ev_device_connected {
+ struct mgmt_addr_info addr;
+ __le16 eir_len;
+ __u8 eir[0];
+} __packed;
#define MGMT_EV_DEVICE_DISCONNECTED 0x000B
@@ -371,20 +376,14 @@ struct mgmt_ev_device_found {
__u8 eir[0];
} __packed;
-#define MGMT_EV_REMOTE_NAME 0x0012
-struct mgmt_ev_remote_name {
- bdaddr_t bdaddr;
- __u8 name[MGMT_MAX_NAME_LENGTH];
-} __packed;
-
-#define MGMT_EV_DISCOVERING 0x0013
+#define MGMT_EV_DISCOVERING 0x0012
-#define MGMT_EV_DEVICE_BLOCKED 0x0014
+#define MGMT_EV_DEVICE_BLOCKED 0x0013
struct mgmt_ev_device_blocked {
bdaddr_t bdaddr;
} __packed;
-#define MGMT_EV_DEVICE_UNBLOCKED 0x0015
+#define MGMT_EV_DEVICE_UNBLOCKED 0x0014
struct mgmt_ev_device_unblocked {
bdaddr_t bdaddr;
} __packed;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index f49f64f..d469b99 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1292,11 +1292,36 @@ static inline int hci_resolve_name(struct hci_dev *hdev, struct inquiry_entry *e
return hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
}
-static void hci_resolve_next_name(struct hci_dev *hdev, bdaddr_t *bdaddr)
+static bool hci_resolve_next_name(struct hci_dev *hdev)
{
struct discovery_state *discov = &hdev->discovery;
struct inquiry_entry *e;
+ if (list_empty(&discov->resolve))
+ return false;
+
+ e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
+ if (hci_resolve_name(hdev, e) == 0) {
+ e->name_state = NAME_PENDING;
+ return true;
+ }
+
+ return false;
+}
+
+static void hci_check_pending_name(struct hci_dev *hdev, struct hci_conn *conn,
+ bdaddr_t *bdaddr, u8 *name, u8 name_len)
+{
+ struct discovery_state *discov = &hdev->discovery;
+ struct inquiry_entry *e;
+
+ if (conn && !test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
+ mgmt_device_connected(hdev, bdaddr, ACL_LINK, 0x00,
+ name, name_len, conn->dev_class);
+
+ if (discov->state == DISCOVERY_STOPPED)
+ return;
+
if (discov->state == DISCOVERY_STOPPING)
goto discov_complete;
@@ -1307,16 +1332,13 @@ static void hci_resolve_next_name(struct hci_dev *hdev, bdaddr_t *bdaddr)
if (e) {
e->name_state = NAME_KNOWN;
list_del(&e->list);
+ if (name)
+ mgmt_remote_name(hdev, bdaddr, ACL_LINK, 0x00,
+ e->data.rssi, name, name_len);
}
- if (list_empty(&discov->resolve))
- goto discov_complete;
-
- e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_NEEDED);
- if (hci_resolve_name(hdev, e) == 0) {
- e->name_state = NAME_PENDING;
+ if (hci_resolve_next_name(hdev))
return;
- }
discov_complete:
hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
@@ -1340,10 +1362,11 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
hci_dev_lock(hdev);
+ conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
+
if (test_bit(HCI_MGMT, &hdev->dev_flags))
- hci_resolve_next_name(hdev, &cp->bdaddr);
+ hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0);
- conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
if (!conn)
goto unlock;
@@ -1649,8 +1672,6 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
conn->state = BT_CONFIG;
hci_conn_hold(conn);
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
- mgmt_device_connected(hdev, &ev->bdaddr, conn->type,
- conn->dst_type);
} else
conn->state = BT_CONNECTED;
@@ -1791,7 +1812,8 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
if (ev->status == 0)
conn->state = BT_CLOSED;
- if (conn->type == ACL_LINK || conn->type == LE_LINK) {
+ if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) &&
+ (conn->type == ACL_LINK || conn->type == LE_LINK)) {
if (ev->status != 0)
mgmt_disconnect_failed(hdev, &conn->dst, ev->status);
else
@@ -1884,14 +1906,18 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags)) {
- if (ev->status == 0)
- mgmt_remote_name(hdev, &ev->bdaddr, ev->name);
+ conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
- hci_resolve_next_name(hdev, &ev->bdaddr);
- }
+ if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ goto check_auth;
- conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
+ if (ev->status == 0)
+ hci_check_pending_name(hdev, conn, &ev->bdaddr, ev->name,
+ strnlen(ev->name, HCI_MAX_NAME_LENGTH));
+ else
+ hci_check_pending_name(hdev, conn, &ev->bdaddr, NULL, 0);
+
+check_auth:
if (!conn)
goto unlock;
@@ -2000,7 +2026,10 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff
bacpy(&cp.bdaddr, &conn->dst);
cp.pscan_rep_mode = 0x02;
hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
- }
+ } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
+ mgmt_device_connected(hdev, &conn->dst, conn->type,
+ conn->dst_type, NULL, 0,
+ conn->dev_class);
if (!hci_outgoing_auth_needed(hdev, conn)) {
conn->state = BT_CONNECTED;
@@ -2770,7 +2799,10 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
bacpy(&cp.bdaddr, &conn->dst);
cp.pscan_rep_mode = 0x02;
hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ, sizeof(cp), &cp);
- }
+ } else if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
+ mgmt_device_connected(hdev, &conn->dst, conn->type,
+ conn->dst_type, NULL, 0,
+ conn->dev_class);
if (!hci_outgoing_auth_needed(hdev, conn)) {
conn->state = BT_CONNECTED;
@@ -3172,7 +3204,9 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff
goto unlock;
}
- mgmt_device_connected(hdev, &ev->bdaddr, conn->type, conn->dst_type);
+ if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
+ mgmt_device_connected(hdev, &ev->bdaddr, conn->type,
+ conn->dst_type, NULL, 0, 0);
conn->sec_level = BT_SECURITY_LOW;
conn->handle = __le16_to_cpu(ev->handle);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c851579..8d5f8b9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1244,7 +1244,6 @@ static int get_connections(struct sock *sk, u16 index)
struct mgmt_rp_get_connections *rp;
struct hci_dev *hdev;
struct hci_conn *c;
- struct list_head *p;
size_t rp_len;
u16 count;
int i, err;
@@ -1259,8 +1258,9 @@ static int get_connections(struct sock *sk, u16 index)
hci_dev_lock(hdev);
count = 0;
- list_for_each(p, &hdev->conn_hash.list) {
- count++;
+ list_for_each_entry(c, &hdev->conn_hash.list, list) {
+ if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags))
+ count++;
}
rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info));
@@ -1274,6 +1274,8 @@ static int get_connections(struct sock *sk, u16 index)
i = 0;
list_for_each_entry(c, &hdev->conn_hash.list, list) {
+ if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags))
+ continue;
bacpy(&rp->addr[i].bdaddr, &c->dst);
rp->addr[i].type = link_to_mgmt(c->type, c->dst_type);
if (rp->addr[i].type == MGMT_ADDR_INVALID)
@@ -2465,15 +2467,28 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
}
int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
- u8 addr_type)
+ u8 addr_type, u8 *name, u8 name_len,
+ u8 *dev_class)
{
- struct mgmt_addr_info ev;
+ char buf[512];
+ struct mgmt_ev_device_connected *ev = (void *) buf;
+ u16 eir_len = 0;
- bacpy(&ev.bdaddr, bdaddr);
- ev.type = link_to_mgmt(link_type, addr_type);
+ bacpy(&ev->addr.bdaddr, bdaddr);
+ ev->addr.type = link_to_mgmt(link_type, addr_type);
- return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, &ev, sizeof(ev),
- NULL);
+ if (name_len > 0)
+ eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE,
+ name, name_len);
+
+ if (dev_class && memcmp(dev_class, "\0\0\0", 3) != 0)
+ eir_len = eir_append_data(&ev->eir[eir_len], eir_len,
+ EIR_CLASS_OF_DEV, dev_class, 3);
+
+ put_unaligned_le16(eir_len, &ev->eir_len);
+
+ return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, buf,
+ sizeof(*ev) + eir_len, NULL);
}
static void disconnect_rsp(struct pending_cmd *cmd, void *data)
@@ -2813,16 +2828,27 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
}
-int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name)
+int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
+ u8 addr_type, s8 rssi, u8 *name, u8 name_len)
{
- struct mgmt_ev_remote_name ev;
+ struct mgmt_ev_device_found *ev;
+ char buf[sizeof(*ev) + HCI_MAX_NAME_LENGTH + 2];
+ u16 eir_len;
- memset(&ev, 0, sizeof(ev));
+ ev = (struct mgmt_ev_device_found *) buf;
- bacpy(&ev.bdaddr, bdaddr);
- memcpy(ev.name, name, HCI_MAX_NAME_LENGTH);
+ memset(buf, 0, sizeof(buf));
+
+ bacpy(&ev->addr.bdaddr, bdaddr);
+ ev->addr.type = link_to_mgmt(link_type, addr_type);
+ ev->rssi = rssi;
+
+ eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name,
+ name_len);
+
+ put_unaligned_le16(eir_len, &ev->eir_len);
- return mgmt_event(MGMT_EV_REMOTE_NAME, hdev, &ev, sizeof(ev), NULL);
+ return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL);
}
int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 13/15] Bluetooth: Update device_connected and device_found events to latest API
2012-01-18 18:51 ` [PATCH 13/15] Bluetooth: Update device_connected and device_found events to latest API Johan Hedberg
@ 2012-01-18 19:17 ` Marcel Holtmann
0 siblings, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:17 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> This patch updates mgmt_ev_device_connected and mgmt_ev_device found to
> include an EIR-encoded remote name and class whenever possible. With
> this addition the mgmt_ev_remote_name event becomes unnecessary and can
> be removed. Since the connected event doesn't map to hci_conn_complete
> anymore a HCI_CONN_MGMT_CONNECTED flag is added to track when mgmt has
> been notified about a connection.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 7 ++-
> include/net/bluetooth/mgmt.h | 17 ++++----
> net/bluetooth/hci_event.c | 78 +++++++++++++++++++++++++++-----------
> net/bluetooth/mgmt.c | 56 ++++++++++++++++++++-------
> 4 files changed, 110 insertions(+), 48 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 14/15] Bluetooth: Rename hdev->flags to hdev->compat_flags
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (12 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 13/15] Bluetooth: Update device_connected and device_found events to latest API Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
2012-01-18 19:18 ` Marcel Holtmann
2012-01-18 18:51 ` [PATCH 15/15] Bluetooth: Rename hdev->dev_flags to hdev-flags Johan Hedberg
14 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
These flags mostly exist for legacy reasons and no new flags should be
added to this set, so compat_flags is a better name.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
drivers/bluetooth/bfusb.c | 12 +++---
drivers/bluetooth/bpa10x.c | 12 +++---
drivers/bluetooth/btmrvl_main.c | 9 +++--
drivers/bluetooth/btusb.c | 20 +++++-----
drivers/bluetooth/hci_ldisc.c | 6 ++--
drivers/bluetooth/hci_vhci.c | 6 ++--
include/net/bluetooth/hci.h | 7 +---
include/net/bluetooth/hci_core.h | 2 +-
net/bluetooth/hci_conn.c | 7 ++--
net/bluetooth/hci_core.c | 71 +++++++++++++++++++------------------
net/bluetooth/hci_event.c | 43 ++++++++++++-----------
net/bluetooth/hci_sock.c | 8 ++--
net/bluetooth/mgmt.c | 38 ++++++++++----------
13 files changed, 121 insertions(+), 120 deletions(-)
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index e97f42a..8f77290 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -191,7 +191,7 @@ static void bfusb_tx_complete(struct urb *urb)
atomic_dec(&data->pending_tx);
- if (!test_bit(HCI_RUNNING, &data->hdev->flags))
+ if (!test_bit(HCI_RUNNING, &data->hdev->compat_flags))
return;
if (!urb->status)
@@ -352,7 +352,7 @@ static void bfusb_rx_complete(struct urb *urb)
read_lock(&data->lock);
- if (!test_bit(HCI_RUNNING, &data->hdev->flags))
+ if (!test_bit(HCI_RUNNING, &data->hdev->compat_flags))
goto unlock;
if (urb->status || !count)
@@ -417,7 +417,7 @@ static int bfusb_open(struct hci_dev *hdev)
BT_DBG("hdev %p bfusb %p", hdev, data);
- if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
+ if (test_and_set_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
write_lock_irqsave(&data->lock, flags);
@@ -427,7 +427,7 @@ static int bfusb_open(struct hci_dev *hdev)
for (i = 1; i < BFUSB_MAX_BULK_RX; i++)
bfusb_rx_submit(data, NULL);
} else {
- clear_bit(HCI_RUNNING, &hdev->flags);
+ clear_bit(HCI_RUNNING, &hdev->compat_flags);
}
write_unlock_irqrestore(&data->lock, flags);
@@ -453,7 +453,7 @@ static int bfusb_close(struct hci_dev *hdev)
BT_DBG("hdev %p bfusb %p", hdev, data);
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
write_lock_irqsave(&data->lock, flags);
@@ -480,7 +480,7 @@ static int bfusb_send_frame(struct sk_buff *skb)
return -ENODEV;
}
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return -EBUSY;
data = hdev->driver_data;
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 229bdc9..b82b594 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -172,7 +172,7 @@ static void bpa10x_tx_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
goto done;
if (!urb->status)
@@ -195,7 +195,7 @@ static void bpa10x_rx_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return;
if (urb->status == 0) {
@@ -306,7 +306,7 @@ static int bpa10x_open(struct hci_dev *hdev)
BT_DBG("%s", hdev->name);
- if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
+ if (test_and_set_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
err = bpa10x_submit_intr_urb(hdev);
@@ -322,7 +322,7 @@ static int bpa10x_open(struct hci_dev *hdev)
error:
usb_kill_anchored_urbs(&data->rx_anchor);
- clear_bit(HCI_RUNNING, &hdev->flags);
+ clear_bit(HCI_RUNNING, &hdev->compat_flags);
return err;
}
@@ -333,7 +333,7 @@ static int bpa10x_close(struct hci_dev *hdev)
BT_DBG("%s", hdev->name);
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
usb_kill_anchored_urbs(&data->rx_anchor);
@@ -363,7 +363,7 @@ static int bpa10x_send_frame(struct sk_buff *skb)
BT_DBG("%s", hdev->name);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return -EBUSY;
urb = usb_alloc_urb(0, GFP_ATOMIC);
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index d69c095..2292b4d 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -400,8 +400,9 @@ static int btmrvl_send_frame(struct sk_buff *skb)
}
priv = (struct btmrvl_private *) hdev->driver_data;
- if (!test_bit(HCI_RUNNING, &hdev->flags)) {
- BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags)) {
+ BT_ERR("Failed testing HCI_RUNING, flags=%lx",
+ hdev->compat_flags);
print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
skb->data, skb->len);
return -EBUSY;
@@ -441,7 +442,7 @@ static int btmrvl_close(struct hci_dev *hdev)
{
struct btmrvl_private *priv = hdev->driver_data;
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
skb_queue_purge(&priv->adapter->tx_queue);
@@ -451,7 +452,7 @@ static int btmrvl_close(struct hci_dev *hdev)
static int btmrvl_open(struct hci_dev *hdev)
{
- set_bit(HCI_RUNNING, &hdev->flags);
+ set_bit(HCI_RUNNING, &hdev->compat_flags);
return 0;
}
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 559b475..26e7ab9 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -248,7 +248,7 @@ static void btusb_intr_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return;
if (urb->status == 0) {
@@ -336,7 +336,7 @@ static void btusb_bulk_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return;
if (urb->status == 0) {
@@ -422,7 +422,7 @@ static void btusb_isoc_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return;
if (urb->status == 0) {
@@ -541,7 +541,7 @@ static void btusb_tx_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
goto done;
if (!urb->status)
@@ -567,7 +567,7 @@ static void btusb_isoc_tx_complete(struct urb *urb)
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
goto done;
if (!urb->status)
@@ -594,7 +594,7 @@ static int btusb_open(struct hci_dev *hdev)
data->intf->needs_remote_wakeup = 1;
- if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
+ if (test_and_set_bit(HCI_RUNNING, &hdev->compat_flags))
goto done;
if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags))
@@ -619,7 +619,7 @@ done:
failed:
clear_bit(BTUSB_INTR_RUNNING, &data->flags);
- clear_bit(HCI_RUNNING, &hdev->flags);
+ clear_bit(HCI_RUNNING, &hdev->compat_flags);
usb_autopm_put_interface(data->intf);
return err;
}
@@ -638,7 +638,7 @@ static int btusb_close(struct hci_dev *hdev)
BT_DBG("%s", hdev->name);
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
cancel_work_sync(&data->work);
@@ -683,7 +683,7 @@ static int btusb_send_frame(struct sk_buff *skb)
BT_DBG("%s", hdev->name);
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return -EBUSY;
switch (bt_cb(skb)->pkt_type) {
@@ -1153,7 +1153,7 @@ static int btusb_resume(struct usb_interface *intf)
if (--data->suspend_count)
return 0;
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
goto done;
if (test_bit(BTUSB_INTR_RUNNING, &data->flags)) {
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 459ff0b..9087366 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -166,7 +166,7 @@ static int hci_uart_open(struct hci_dev *hdev)
/* Nothing to do for UART driver */
- set_bit(HCI_RUNNING, &hdev->flags);
+ set_bit(HCI_RUNNING, &hdev->compat_flags);
return 0;
}
@@ -198,7 +198,7 @@ static int hci_uart_close(struct hci_dev *hdev)
{
BT_DBG("hdev %p", hdev);
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
hci_uart_flush(hdev);
@@ -217,7 +217,7 @@ static int hci_uart_send_frame(struct sk_buff *skb)
return -ENODEV;
}
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return -EBUSY;
hu = (struct hci_uart *) hdev->driver_data;
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 5f305c1..912716b 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -54,7 +54,7 @@ struct vhci_data {
static int vhci_open_dev(struct hci_dev *hdev)
{
- set_bit(HCI_RUNNING, &hdev->flags);
+ set_bit(HCI_RUNNING, &hdev->compat_flags);
return 0;
}
@@ -63,7 +63,7 @@ static int vhci_close_dev(struct hci_dev *hdev)
{
struct vhci_data *data = hdev->driver_data;
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->compat_flags))
return 0;
skb_queue_purge(&data->readq);
@@ -90,7 +90,7 @@ static int vhci_send_frame(struct sk_buff *skb)
return -ENODEV;
}
- if (!test_bit(HCI_RUNNING, &hdev->flags))
+ if (!test_bit(HCI_RUNNING, &hdev->compat_flags))
return -EBUSY;
data = hdev->driver_data;
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index cb9097a..8797c3f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -63,7 +63,7 @@ enum {
HCI_QUIRK_FIXUP_BUFFER_SIZE
};
-/* HCI device flags */
+/* hdev->compat_flags */
enum {
HCI_UP,
HCI_INIT,
@@ -80,10 +80,7 @@ enum {
HCI_RESET,
};
-/*
- * BR/EDR and/or LE controller flags: the flags defined here should represent
- * states from the controller.
- */
+/* hdev->dev_flags */
enum {
HCI_SETUP,
HCI_AUTO_OFF,
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ab1a626..c972406 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -131,7 +131,7 @@ struct hci_dev {
struct mutex lock;
char name[8];
- unsigned long flags;
+ unsigned long compat_flags;
__u16 id;
__u8 bus;
__u8 dev_type;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 4fb7b4f..450511b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -320,7 +320,7 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
BT_DBG("conn %p mode %d", conn, conn->mode);
- if (test_bit(HCI_RAW, &hdev->flags))
+ if (test_bit(HCI_RAW, &hdev->compat_flags))
return;
if (!lmp_sniff_capable(hdev) || !lmp_sniff_capable(conn))
@@ -491,7 +491,8 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
read_lock(&hci_dev_list_lock);
list_for_each_entry(d, &hci_dev_list, list) {
- if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags))
+ if (!test_bit(HCI_UP, &d->compat_flags) ||
+ test_bit(HCI_RAW, &d->compat_flags))
continue;
/* Simple routing:
@@ -771,7 +772,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
BT_DBG("conn %p mode %d", conn, conn->mode);
- if (test_bit(HCI_RAW, &hdev->flags))
+ if (test_bit(HCI_RAW, &hdev->compat_flags))
return;
if (conn->mode != HCI_CM_SNIFF)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index a7b7200..ff01f0a 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -98,7 +98,8 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result)
/* If this is the init phase check if the completed command matches
* the last init command, and if not just return.
*/
- if (test_bit(HCI_INIT, &hdev->flags) && hdev->init_last_cmd != cmd)
+ if (test_bit(HCI_INIT, &hdev->compat_flags) &&
+ hdev->init_last_cmd != cmd)
return;
if (hdev->req_status == HCI_REQ_PEND) {
@@ -167,7 +168,7 @@ static inline int hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *
{
int ret;
- if (!test_bit(HCI_UP, &hdev->flags))
+ if (!test_bit(HCI_UP, &hdev->compat_flags))
return -ENETDOWN;
/* Serialize all requests */
@@ -183,7 +184,7 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
BT_DBG("%s %ld", hdev->name, opt);
/* Reset device */
- set_bit(HCI_RESET, &hdev->flags);
+ set_bit(HCI_RESET, &hdev->compat_flags);
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
}
@@ -199,7 +200,7 @@ static void bredr_init(struct hci_dev *hdev)
/* Reset */
if (!test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks)) {
- set_bit(HCI_RESET, &hdev->flags);
+ set_bit(HCI_RESET, &hdev->compat_flags);
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
}
@@ -561,7 +562,7 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
BT_DBG("%s", hdev->name);
- if (test_bit(HCI_INQUIRY, &hdev->flags))
+ if (test_bit(HCI_INQUIRY, &hdev->compat_flags))
return;
/* Start Inquiry */
@@ -657,27 +658,27 @@ int hci_dev_open(__u16 dev)
goto done;
}
- if (test_bit(HCI_UP, &hdev->flags)) {
+ if (test_bit(HCI_UP, &hdev->compat_flags)) {
ret = -EALREADY;
goto done;
}
if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
- set_bit(HCI_RAW, &hdev->flags);
+ set_bit(HCI_RAW, &hdev->compat_flags);
/* Treat all non BR/EDR controllers as raw devices if
enable_hs is not set */
if (hdev->dev_type != HCI_BREDR && !enable_hs)
- set_bit(HCI_RAW, &hdev->flags);
+ set_bit(HCI_RAW, &hdev->compat_flags);
if (hdev->open(hdev)) {
ret = -EIO;
goto done;
}
- if (!test_bit(HCI_RAW, &hdev->flags)) {
+ if (!test_bit(HCI_RAW, &hdev->compat_flags)) {
atomic_set(&hdev->cmd_cnt, 1);
- set_bit(HCI_INIT, &hdev->flags);
+ set_bit(HCI_INIT, &hdev->compat_flags);
hdev->init_last_cmd = 0;
ret = __hci_request(hdev, hci_init_req, 0,
@@ -687,12 +688,12 @@ int hci_dev_open(__u16 dev)
ret = __hci_request(hdev, hci_le_init_req, 0,
msecs_to_jiffies(HCI_INIT_TIMEOUT));
- clear_bit(HCI_INIT, &hdev->flags);
+ clear_bit(HCI_INIT, &hdev->compat_flags);
}
if (!ret) {
hci_dev_hold(hdev);
- set_bit(HCI_UP, &hdev->flags);
+ set_bit(HCI_UP, &hdev->compat_flags);
hci_notify(hdev, HCI_DEV_UP);
if (!test_bit(HCI_SETUP, &hdev->dev_flags)) {
hci_dev_lock(hdev);
@@ -717,7 +718,7 @@ int hci_dev_open(__u16 dev)
}
hdev->close(hdev);
- hdev->flags = 0;
+ hdev->compat_flags = 0;
}
done:
@@ -733,7 +734,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hci_req_cancel(hdev, ENODEV);
hci_req_lock(hdev);
- if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
+ if (!test_and_clear_bit(HCI_UP, &hdev->compat_flags)) {
del_timer_sync(&hdev->cmd_timer);
hci_req_unlock(hdev);
return 0;
@@ -767,11 +768,11 @@ static int hci_dev_do_close(struct hci_dev *hdev)
/* Reset device */
skb_queue_purge(&hdev->cmd_q);
atomic_set(&hdev->cmd_cnt, 1);
- if (!test_bit(HCI_RAW, &hdev->flags)) {
- set_bit(HCI_INIT, &hdev->flags);
+ if (!test_bit(HCI_RAW, &hdev->compat_flags)) {
+ set_bit(HCI_INIT, &hdev->compat_flags);
__hci_request(hdev, hci_reset_req, 0,
msecs_to_jiffies(HCI_INIT_TIMEOUT));
- clear_bit(HCI_INIT, &hdev->flags);
+ clear_bit(HCI_INIT, &hdev->compat_flags);
}
/* flush cmd work */
@@ -798,7 +799,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hci_dev_unlock(hdev);
/* Clear flags */
- hdev->flags = 0;
+ hdev->compat_flags = 0;
hci_req_unlock(hdev);
@@ -830,7 +831,7 @@ int hci_dev_reset(__u16 dev)
hci_req_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags))
+ if (!test_bit(HCI_UP, &hdev->compat_flags))
goto done;
/* Drop queues */
@@ -848,7 +849,7 @@ int hci_dev_reset(__u16 dev)
atomic_set(&hdev->cmd_cnt, 1);
hdev->acl_cnt = 0; hdev->sco_cnt = 0; hdev->le_cnt = 0;
- if (!test_bit(HCI_RAW, &hdev->flags))
+ if (!test_bit(HCI_RAW, &hdev->compat_flags))
ret = __hci_request(hdev, hci_reset_req, 0,
msecs_to_jiffies(HCI_INIT_TIMEOUT));
@@ -899,7 +900,7 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
break;
}
- if (!test_bit(HCI_AUTH, &hdev->flags)) {
+ if (!test_bit(HCI_AUTH, &hdev->compat_flags)) {
/* Auth must be enabled first */
err = hci_request(hdev, hci_auth_req, dr.dev_opt,
msecs_to_jiffies(HCI_INIT_TIMEOUT));
@@ -980,7 +981,7 @@ int hci_get_dev_list(void __user *arg)
set_bit(HCI_PAIRABLE, &hdev->dev_flags);
(dr + n)->dev_id = hdev->id;
- (dr + n)->dev_opt = hdev->flags;
+ (dr + n)->dev_opt = hdev->compat_flags;
if (++n >= dev_num)
break;
@@ -1018,7 +1019,7 @@ int hci_get_dev_info(void __user *arg)
strcpy(di.name, hdev->name);
di.bdaddr = hdev->bdaddr;
di.type = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
- di.flags = hdev->flags;
+ di.flags = hdev->compat_flags;
di.pkt_type = hdev->pkt_type;
di.acl_mtu = hdev->acl_mtu;
di.acl_pkts = hdev->acl_pkts;
@@ -1599,7 +1600,7 @@ int hci_register_dev(struct hci_dev *hdev)
mutex_init(&hdev->lock);
- hdev->flags = 0;
+ hdev->compat_flags = 0;
hdev->dev_flags = 0;
hdev->pkt_type = (HCI_DM1 | HCI_DH1 | HCI_HV1);
hdev->esco_type = (ESCO_HV1);
@@ -1711,7 +1712,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
for (i = 0; i < NUM_REASSEMBLY; i++)
kfree_skb(hdev->reassembly[i]);
- if (!test_bit(HCI_INIT, &hdev->flags) &&
+ if (!test_bit(HCI_INIT, &hdev->compat_flags) &&
!test_bit(HCI_SETUP, &hdev->dev_flags)) {
hci_dev_lock(hdev);
mgmt_index_removed(hdev);
@@ -1767,8 +1768,8 @@ EXPORT_SYMBOL(hci_resume_dev);
int hci_recv_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
- if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
- && !test_bit(HCI_INIT, &hdev->flags))) {
+ if (!hdev || (!test_bit(HCI_UP, &hdev->compat_flags)
+ && !test_bit(HCI_INIT, &hdev->compat_flags))) {
kfree_skb(skb);
return -ENXIO;
}
@@ -2027,7 +2028,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
skb->dev = (void *) hdev;
- if (test_bit(HCI_INIT, &hdev->flags))
+ if (test_bit(HCI_INIT, &hdev->compat_flags))
hdev->init_last_cmd = opcode;
skb_queue_tail(&hdev->cmd_q, skb);
@@ -2372,7 +2373,7 @@ static inline void hci_sched_acl(struct hci_dev *hdev)
if (!hci_conn_num(hdev, ACL_LINK))
return;
- if (!test_bit(HCI_RAW, &hdev->flags)) {
+ if (!test_bit(HCI_RAW, &hdev->compat_flags)) {
/* ACL tx timeout must be longer than maximum
* link supervision timeout (40.9 seconds) */
if (!hdev->acl_cnt && time_after(jiffies, hdev->acl_last_tx +
@@ -2469,7 +2470,7 @@ static inline void hci_sched_le(struct hci_dev *hdev)
if (!hci_conn_num(hdev, LE_LINK))
return;
- if (!test_bit(HCI_RAW, &hdev->flags)) {
+ if (!test_bit(HCI_RAW, &hdev->compat_flags)) {
/* LE tx timeout must be longer than maximum
* link supervision timeout (40.9 seconds) */
if (!hdev->le_cnt && hdev->le_pkts &&
@@ -2613,12 +2614,12 @@ static void hci_rx_work(struct work_struct *work)
hci_send_to_sock(hdev, skb, NULL);
}
- if (test_bit(HCI_RAW, &hdev->flags)) {
+ if (test_bit(HCI_RAW, &hdev->compat_flags)) {
kfree_skb(skb);
continue;
}
- if (test_bit(HCI_INIT, &hdev->flags)) {
+ if (test_bit(HCI_INIT, &hdev->compat_flags)) {
/* Don't process data packets in this states. */
switch (bt_cb(skb)->pkt_type) {
case HCI_ACLDATA_PKT:
@@ -2671,7 +2672,7 @@ static void hci_cmd_work(struct work_struct *work)
if (hdev->sent_cmd) {
atomic_dec(&hdev->cmd_cnt);
hci_send_frame(skb);
- if (test_bit(HCI_RESET, &hdev->flags))
+ if (test_bit(HCI_RESET, &hdev->compat_flags))
del_timer(&hdev->cmd_timer);
else
mod_timer(&hdev->cmd_timer,
@@ -2691,7 +2692,7 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length)
BT_DBG("%s", hdev->name);
- if (test_bit(HCI_INQUIRY, &hdev->flags))
+ if (test_bit(HCI_INQUIRY, &hdev->compat_flags))
return -EINPROGRESS;
inquiry_cache_flush(hdev);
@@ -2707,7 +2708,7 @@ int hci_cancel_inquiry(struct hci_dev *hdev)
{
BT_DBG("%s", hdev->name);
- if (!test_bit(HCI_INQUIRY, &hdev->flags))
+ if (!test_bit(HCI_INQUIRY, &hdev->compat_flags))
return -EPERM;
return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index d469b99..6817c52 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -62,7 +62,7 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
return;
}
- clear_bit(HCI_INQUIRY, &hdev->flags);
+ clear_bit(HCI_INQUIRY, &hdev->compat_flags);
hci_dev_lock(hdev);
hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
@@ -191,7 +191,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s status 0x%x", hdev->name, status);
- clear_bit(HCI_RESET, &hdev->flags);
+ clear_bit(HCI_RESET, &hdev->compat_flags);
hci_req_complete(hdev, HCI_OP_RESET, status);
@@ -248,9 +248,9 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
__u8 param = *((__u8 *) sent);
if (param == AUTH_ENABLED)
- set_bit(HCI_AUTH, &hdev->flags);
+ set_bit(HCI_AUTH, &hdev->compat_flags);
else
- clear_bit(HCI_AUTH, &hdev->flags);
+ clear_bit(HCI_AUTH, &hdev->compat_flags);
}
hci_req_complete(hdev, HCI_OP_WRITE_AUTH_ENABLE, status);
@@ -271,9 +271,9 @@ static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
__u8 param = *((__u8 *) sent);
if (param)
- set_bit(HCI_ENCRYPT, &hdev->flags);
+ set_bit(HCI_ENCRYPT, &hdev->compat_flags);
else
- clear_bit(HCI_ENCRYPT, &hdev->flags);
+ clear_bit(HCI_ENCRYPT, &hdev->compat_flags);
}
hci_req_complete(hdev, HCI_OP_WRITE_ENCRYPT_MODE, status);
@@ -301,11 +301,11 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
goto done;
}
- old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags);
- old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags);
+ old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->compat_flags);
+ old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->compat_flags);
if (param & SCAN_INQUIRY) {
- set_bit(HCI_ISCAN, &hdev->flags);
+ set_bit(HCI_ISCAN, &hdev->compat_flags);
if (!old_iscan)
mgmt_discoverable(hdev, 1);
if (hdev->discov_timeout > 0) {
@@ -317,7 +317,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
mgmt_discoverable(hdev, 0);
if (param & SCAN_PAGE) {
- set_bit(HCI_PSCAN, &hdev->flags);
+ set_bit(HCI_PSCAN, &hdev->compat_flags);
if (!old_pscan)
mgmt_connectable(hdev, 1);
} else if (old_pscan)
@@ -430,9 +430,9 @@ static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
return;
if (rp->mode)
- set_bit(HCI_SSP_ENABLED, &hdev->flags);
+ set_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
else
- clear_bit(HCI_SSP_ENABLED, &hdev->flags);
+ clear_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
}
static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -450,9 +450,9 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
return;
if (*(u8 *) sent)
- set_bit(HCI_SSP_ENABLED, &hdev->flags);
+ set_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
else
- clear_bit(HCI_SSP_ENABLED, &hdev->flags);
+ clear_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
}
static u8 hci_get_inquiry_mode(struct hci_dev *hdev)
@@ -613,7 +613,7 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
hdev->manufacturer,
hdev->hci_ver, hdev->hci_rev);
- if (test_bit(HCI_INIT, &hdev->flags))
+ if (test_bit(HCI_INIT, &hdev->compat_flags))
hci_setup(hdev);
}
@@ -646,7 +646,8 @@ static void hci_cc_read_local_commands(struct hci_dev *hdev, struct sk_buff *skb
memcpy(hdev->commands, rp->commands, sizeof(hdev->commands));
- if (test_bit(HCI_INIT, &hdev->flags) && (hdev->commands[5] & 0x10))
+ if (test_bit(HCI_INIT, &hdev->compat_flags) &&
+ (hdev->commands[5] & 0x10))
hci_setup_link_policy(hdev);
done:
@@ -1123,7 +1124,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
return;
}
- set_bit(HCI_INQUIRY, &hdev->flags);
+ set_bit(HCI_INQUIRY, &hdev->compat_flags);
hci_dev_lock(hdev);
hci_discovery_set_state(hdev, DISCOVERY_INQUIRY);
@@ -1582,7 +1583,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
hci_conn_check_pending(hdev);
- if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
+ if (!test_and_clear_bit(HCI_INQUIRY, &hdev->compat_flags))
return;
if (!test_bit(HCI_MGMT, &hdev->dev_flags))
@@ -1678,10 +1679,10 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
hci_conn_hold_device(conn);
hci_conn_add_sysfs(conn);
- if (test_bit(HCI_AUTH, &hdev->flags))
+ if (test_bit(HCI_AUTH, &hdev->compat_flags))
conn->link_mode |= HCI_LM_AUTH;
- if (test_bit(HCI_ENCRYPT, &hdev->flags))
+ if (test_bit(HCI_ENCRYPT, &hdev->compat_flags))
conn->link_mode |= HCI_LM_ENCRYPT;
/* Get remote features */
@@ -2346,7 +2347,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (ev->opcode != HCI_OP_NOP)
del_timer(&hdev->cmd_timer);
- if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
+ if (ev->ncmd && !test_bit(HCI_RESET, &hdev->compat_flags)) {
atomic_set(&hdev->cmd_cnt, 1);
if (!skb_queue_empty(&hdev->cmd_q))
queue_work(hdev->workqueue, &hdev->cmd_work);
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 896a72f..98001e6 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -231,9 +231,9 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign
return -EPERM;
if (arg)
- set_bit(HCI_RAW, &hdev->flags);
+ set_bit(HCI_RAW, &hdev->compat_flags);
else
- clear_bit(HCI_RAW, &hdev->flags);
+ clear_bit(HCI_RAW, &hdev->compat_flags);
return 0;
@@ -506,7 +506,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
goto done;
}
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = -ENETDOWN;
goto done;
}
@@ -536,7 +536,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
goto drop;
}
- if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) {
+ if (test_bit(HCI_RAW, &hdev->compat_flags) || (ogf == 0x3f)) {
skb_queue_tail(&hdev->raw_q, skb);
queue_work(hdev->workqueue, &hdev->tx_work);
} else {
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8d5f8b9..de07f7c 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -274,15 +274,15 @@ static u32 get_current_settings(struct hci_dev *hdev)
{
u32 settings = 0;
- if (test_bit(HCI_UP, &hdev->flags))
+ if (test_bit(HCI_UP, &hdev->compat_flags))
settings |= MGMT_SETTING_POWERED;
else
return settings;
- if (test_bit(HCI_PSCAN, &hdev->flags))
+ if (test_bit(HCI_PSCAN, &hdev->compat_flags))
settings |= MGMT_SETTING_CONNECTABLE;
- if (test_bit(HCI_ISCAN, &hdev->flags))
+ if (test_bit(HCI_ISCAN, &hdev->compat_flags))
settings |= MGMT_SETTING_DISCOVERABLE;
if (test_bit(HCI_PAIRABLE, &hdev->dev_flags))
@@ -294,10 +294,10 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (hdev->host_features[0] & LMP_HOST_LE)
settings |= MGMT_SETTING_LE;
- if (test_bit(HCI_AUTH, &hdev->flags))
+ if (test_bit(HCI_AUTH, &hdev->compat_flags))
settings |= MGMT_SETTING_LINK_SECURITY;
- if (test_bit(HCI_SSP_ENABLED, &hdev->flags))
+ if (test_bit(HCI_SSP_ENABLED, &hdev->compat_flags))
settings |= MGMT_SETTING_SSP;
return settings;
@@ -416,7 +416,7 @@ static int update_eir(struct hci_dev *hdev)
if (!(hdev->features[6] & LMP_EXT_INQ))
return 0;
- if (!test_bit(HCI_SSP_ENABLED, &hdev->flags))
+ if (!test_bit(HCI_SSP_ENABLED, &hdev->compat_flags))
return 0;
if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
@@ -633,7 +633,7 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
hci_dev_lock(hdev);
- up = test_bit(HCI_UP, &hdev->flags);
+ up = test_bit(HCI_UP, &hdev->compat_flags);
if ((cp->val && up) || (!cp->val && !up)) {
err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);
goto failed;
@@ -688,7 +688,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE,
MGMT_STATUS_NOT_POWERED);
goto failed;
@@ -701,8 +701,8 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
goto failed;
}
- if (cp->val == test_bit(HCI_ISCAN, &hdev->flags) &&
- test_bit(HCI_PSCAN, &hdev->flags)) {
+ if (cp->val == test_bit(HCI_ISCAN, &hdev->compat_flags) &&
+ test_bit(HCI_PSCAN, &hdev->compat_flags)) {
err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev);
goto failed;
}
@@ -758,7 +758,7 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE,
MGMT_STATUS_NOT_POWERED);
goto failed;
@@ -771,7 +771,7 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
goto failed;
}
- if (cp->val == test_bit(HCI_PSCAN, &hdev->flags)) {
+ if (cp->val == test_bit(HCI_PSCAN, &hdev->compat_flags)) {
err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev);
goto failed;
}
@@ -1119,7 +1119,7 @@ static int remove_keys(struct sock *sk, u16 index, unsigned char *data,
goto unlock;
}
- if (!test_bit(HCI_UP, &hdev->flags) || !cp->disconnect) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags) || !cp->disconnect) {
err = cmd_complete(sk, index, MGMT_OP_REMOVE_KEYS, &rp,
sizeof(rp));
goto unlock;
@@ -1178,7 +1178,7 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len)
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_DISCONNECT,
MGMT_STATUS_NOT_POWERED);
goto failed;
@@ -1340,7 +1340,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data,
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY,
MGMT_STATUS_NOT_POWERED);
goto failed;
@@ -1409,7 +1409,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data,
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_PIN_CODE_NEG_REPLY,
MGMT_STATUS_NOT_POWERED);
goto failed;
@@ -1609,7 +1609,7 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, mgmt_op, MGMT_STATUS_NOT_POWERED);
goto done;
}
@@ -1789,7 +1789,7 @@ static int read_local_oob_data(struct sock *sk, u16 index)
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA,
MGMT_STATUS_NOT_POWERED);
goto unlock;
@@ -1914,7 +1914,7 @@ static int start_discovery(struct sock *sk, u16 index,
hci_dev_lock(hdev);
- if (!test_bit(HCI_UP, &hdev->flags)) {
+ if (!test_bit(HCI_UP, &hdev->compat_flags)) {
err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_NOT_POWERED);
goto failed;
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread* Re: [PATCH 14/15] Bluetooth: Rename hdev->flags to hdev->compat_flags
2012-01-18 18:51 ` [PATCH 14/15] Bluetooth: Rename hdev->flags to hdev->compat_flags Johan Hedberg
@ 2012-01-18 19:18 ` Marcel Holtmann
0 siblings, 0 replies; 39+ messages in thread
From: Marcel Holtmann @ 2012-01-18 19:18 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
Hi Johan,
> These flags mostly exist for legacy reasons and no new flags should be
> added to this set, so compat_flags is a better name.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> drivers/bluetooth/bfusb.c | 12 +++---
> drivers/bluetooth/bpa10x.c | 12 +++---
> drivers/bluetooth/btmrvl_main.c | 9 +++--
> drivers/bluetooth/btusb.c | 20 +++++-----
> drivers/bluetooth/hci_ldisc.c | 6 ++--
> drivers/bluetooth/hci_vhci.c | 6 ++--
> include/net/bluetooth/hci.h | 7 +---
> include/net/bluetooth/hci_core.h | 2 +-
> net/bluetooth/hci_conn.c | 7 ++--
> net/bluetooth/hci_core.c | 71 +++++++++++++++++++------------------
> net/bluetooth/hci_event.c | 43 ++++++++++++-----------
> net/bluetooth/hci_sock.c | 8 ++--
> net/bluetooth/mgmt.c | 38 ++++++++++----------
> 13 files changed, 121 insertions(+), 120 deletions(-)
>
> diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
> index e97f42a..8f77290 100644
> --- a/drivers/bluetooth/bfusb.c
> +++ b/drivers/bluetooth/bfusb.c
> @@ -191,7 +191,7 @@ static void bfusb_tx_complete(struct urb *urb)
>
> atomic_dec(&data->pending_tx);
>
> - if (!test_bit(HCI_RUNNING, &data->hdev->flags))
> + if (!test_bit(HCI_RUNNING, &data->hdev->compat_flags))
> return;
I do not like this change at all.
Can we just add a BT specific helper for setting/testing HCI_RUNNING and
hiding the fact of hdev->flags.
Regards
Marcel
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH 15/15] Bluetooth: Rename hdev->dev_flags to hdev-flags
2012-01-18 18:51 [PATCH 0/15] Bluetooth: Update to latest mgmt API Johan Hedberg
` (13 preceding siblings ...)
2012-01-18 18:51 ` [PATCH 14/15] Bluetooth: Rename hdev->flags to hdev->compat_flags Johan Hedberg
@ 2012-01-18 18:51 ` Johan Hedberg
14 siblings, 0 replies; 39+ messages in thread
From: Johan Hedberg @ 2012-01-18 18:51 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
This patch renames hdev->dev_flags to simply hdev->flags as these are
now the "default" set of flags and the place where new flags should be
added. To be consistent with struct hci_conn flags naming each flag also
receives a HCI_DEV_* prefix instead of just HCI_*.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 22 +++++++-------
include/net/bluetooth/hci_core.h | 4 +-
net/bluetooth/hci_core.c | 32 ++++++++++----------
net/bluetooth/hci_event.c | 59 +++++++++++++++++++------------------
net/bluetooth/mgmt.c | 34 +++++++++++-----------
net/bluetooth/smp.c | 2 +-
6 files changed, 77 insertions(+), 76 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 8797c3f..28a0087 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -80,18 +80,18 @@ enum {
HCI_RESET,
};
-/* hdev->dev_flags */
+/* hdev->flags */
enum {
- HCI_SETUP,
- HCI_AUTO_OFF,
- HCI_MGMT,
- HCI_PAIRABLE,
- HCI_SERVICE_CACHE,
- HCI_LINK_KEYS,
- HCI_DEBUG_KEYS,
-
- HCI_LE_SCAN,
- HCI_SSP_ENABLED,
+ HCI_DEV_SETUP,
+ HCI_DEV_AUTO_OFF,
+ HCI_DEV_MGMT,
+ HCI_DEV_PAIRABLE,
+ HCI_DEV_SERVICE_CACHE,
+ HCI_DEV_LINK_KEYS,
+ HCI_DEV_DEBUG_KEYS,
+
+ HCI_DEV_LE_SCAN,
+ HCI_DEV_SSP_ENABLED,
};
/* HCI ioctl defines */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c972406..071d359 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -260,7 +260,7 @@ struct hci_dev {
struct rfkill *rfkill;
- unsigned long dev_flags;
+ unsigned long flags;
int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
@@ -414,7 +414,7 @@ enum {
static inline bool hci_conn_ssp_support(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
- return (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
+ return (test_bit(HCI_DEV_SSP_ENABLED, &hdev->flags) &&
test_bit(HCI_CONN_SSP_SUPPORT, &conn->flags));
}
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ff01f0a..2de4c72 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -695,7 +695,7 @@ int hci_dev_open(__u16 dev)
hci_dev_hold(hdev);
set_bit(HCI_UP, &hdev->compat_flags);
hci_notify(hdev, HCI_DEV_UP);
- if (!test_bit(HCI_SETUP, &hdev->dev_flags)) {
+ if (!test_bit(HCI_DEV_SETUP, &hdev->flags)) {
hci_dev_lock(hdev);
mgmt_powered(hdev, 1);
hci_dev_unlock(hdev);
@@ -749,10 +749,10 @@ static int hci_dev_do_close(struct hci_dev *hdev)
hdev->discov_timeout = 0;
}
- if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_AUTO_OFF, &hdev->flags))
cancel_delayed_work(&hdev->power_off);
- if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_SERVICE_CACHE, &hdev->flags))
cancel_delayed_work(&hdev->service_cache);
hci_dev_lock(hdev);
@@ -974,11 +974,11 @@ int hci_get_dev_list(void __user *arg)
read_lock(&hci_dev_list_lock);
list_for_each_entry(hdev, &hci_dev_list, list) {
- if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_AUTO_OFF, &hdev->flags))
cancel_delayed_work(&hdev->power_off);
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
- set_bit(HCI_PAIRABLE, &hdev->dev_flags);
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
+ set_bit(HCI_DEV_PAIRABLE, &hdev->flags);
(dr + n)->dev_id = hdev->id;
(dr + n)->dev_opt = hdev->compat_flags;
@@ -1010,11 +1010,11 @@ int hci_get_dev_info(void __user *arg)
if (!hdev)
return -ENODEV;
- if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_AUTO_OFF, &hdev->flags))
cancel_delayed_work_sync(&hdev->power_off);
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
- set_bit(HCI_PAIRABLE, &hdev->dev_flags);
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
+ set_bit(HCI_DEV_PAIRABLE, &hdev->flags);
strcpy(di.name, hdev->name);
di.bdaddr = hdev->bdaddr;
@@ -1094,11 +1094,11 @@ static void hci_power_on(struct work_struct *work)
if (hci_dev_open(hdev->id) < 0)
return;
- if (test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_AUTO_OFF, &hdev->flags))
schedule_delayed_work(&hdev->power_off,
msecs_to_jiffies(AUTO_OFF_TIMEOUT));
- if (test_and_clear_bit(HCI_SETUP, &hdev->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_SETUP, &hdev->flags))
mgmt_index_added(hdev);
}
@@ -1109,7 +1109,7 @@ static void hci_power_off(struct work_struct *work)
BT_DBG("%s", hdev->name);
- clear_bit(HCI_AUTO_OFF, &hdev->dev_flags);
+ clear_bit(HCI_DEV_AUTO_OFF, &hdev->flags);
hci_dev_close(hdev->id);
}
@@ -1601,7 +1601,7 @@ int hci_register_dev(struct hci_dev *hdev)
mutex_init(&hdev->lock);
hdev->compat_flags = 0;
- hdev->dev_flags = 0;
+ hdev->flags = 0;
hdev->pkt_type = (HCI_DM1 | HCI_DH1 | HCI_HV1);
hdev->esco_type = (ESCO_HV1);
hdev->link_mode = (HCI_LM_ACCEPT);
@@ -1676,8 +1676,8 @@ int hci_register_dev(struct hci_dev *hdev)
}
}
- set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
- set_bit(HCI_SETUP, &hdev->dev_flags);
+ set_bit(HCI_DEV_AUTO_OFF, &hdev->flags);
+ set_bit(HCI_DEV_SETUP, &hdev->flags);
schedule_work(&hdev->power_on);
hci_notify(hdev, HCI_DEV_REG);
@@ -1713,7 +1713,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
kfree_skb(hdev->reassembly[i]);
if (!test_bit(HCI_INIT, &hdev->compat_flags) &&
- !test_bit(HCI_SETUP, &hdev->dev_flags)) {
+ !test_bit(HCI_DEV_SETUP, &hdev->flags)) {
hci_dev_lock(hdev);
mgmt_index_removed(hdev);
hci_dev_unlock(hdev);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6817c52..987cedf 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -196,7 +196,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
hci_req_complete(hdev, HCI_OP_RESET, status);
/* Reset all flags, except persistent ones */
- hdev->dev_flags &= BIT(HCI_MGMT) | BIT(HCI_SETUP) | BIT(HCI_AUTO_OFF);
+ hdev->flags &= BIT(HCI_DEV_MGMT) | BIT(HCI_DEV_SETUP) |
+ BIT(HCI_DEV_AUTO_OFF);
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
@@ -212,7 +213,7 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_set_local_name_complete(hdev, sent, status);
if (status == 0)
@@ -430,9 +431,9 @@ static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
return;
if (rp->mode)
- set_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
+ set_bit(HCI_DEV_SSP_ENABLED, &hdev->compat_flags);
else
- clear_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
+ clear_bit(HCI_DEV_SSP_ENABLED, &hdev->compat_flags);
}
static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -450,9 +451,9 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
return;
if (*(u8 *) sent)
- set_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
+ set_bit(HCI_DEV_SSP_ENABLED, &hdev->compat_flags);
else
- clear_bit(HCI_SSP_ENABLED, &hdev->compat_flags);
+ clear_bit(HCI_DEV_SSP_ENABLED, &hdev->compat_flags);
}
static u8 hci_get_inquiry_mode(struct hci_dev *hdev)
@@ -898,7 +899,7 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status);
if (rp->status != 0)
@@ -924,7 +925,7 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr,
rp->status);
@@ -959,7 +960,7 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr,
rp->status);
@@ -975,7 +976,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr,
rp->status);
@@ -990,7 +991,7 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr,
rp->status);
@@ -1006,7 +1007,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev,
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr,
rp->status);
@@ -1050,7 +1051,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
switch (cp->enable) {
case LE_SCANNING_ENABLED:
- set_bit(HCI_LE_SCAN, &hdev->dev_flags);
+ set_bit(HCI_DEV_LE_SCAN, &hdev->flags);
cancel_delayed_work_sync(&hdev->adv_work);
@@ -1060,7 +1061,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
break;
case LE_SCANNING_DISABLED:
- clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
+ clear_bit(HCI_DEV_LE_SCAN, &hdev->flags);
schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT);
break;
@@ -1118,7 +1119,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
hci_req_complete(hdev, HCI_OP_INQUIRY, status);
hci_conn_check_pending(hdev);
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_start_discovery_failed(hdev, status);
hci_dev_unlock(hdev);
return;
@@ -1365,7 +1366,7 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
hci_check_pending_name(hdev, conn, &cp->bdaddr, NULL, 0);
if (!conn)
@@ -1586,7 +1587,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
if (!test_and_clear_bit(HCI_INQUIRY, &hdev->compat_flags))
return;
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
return;
hci_dev_lock(hdev);
@@ -1909,7 +1910,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
goto check_auth;
if (ev->status == 0)
@@ -2543,10 +2544,10 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff
hci_conn_put(conn);
}
- if (!test_bit(HCI_PAIRABLE, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_PAIRABLE, &hdev->flags))
hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY,
sizeof(ev->bdaddr), &ev->bdaddr);
- else if (test_bit(HCI_MGMT, &hdev->dev_flags)) {
+ else if (test_bit(HCI_DEV_MGMT, &hdev->flags)) {
u8 secure;
if (conn->pending_sec_level == BT_SECURITY_HIGH)
@@ -2570,7 +2571,7 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff
BT_DBG("%s", hdev->name);
- if (!test_bit(HCI_LINK_KEYS, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_LINK_KEYS, &hdev->flags))
return;
hci_dev_lock(hdev);
@@ -2585,7 +2586,7 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff
BT_DBG("%s found key type %u for %s", hdev->name, key->type,
batostr(&ev->bdaddr));
- if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) &&
+ if (!test_bit(HCI_DEV_DEBUG_KEYS, &hdev->flags) &&
key->type == HCI_LK_DEBUG_COMBINATION) {
BT_DBG("%s ignoring debug key", hdev->name);
goto not_found;
@@ -2647,7 +2648,7 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff
hci_conn_put(conn);
}
- if (test_bit(HCI_LINK_KEYS, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_LINK_KEYS, &hdev->flags))
hci_add_link_key(hdev, conn, 1, &ev->bdaddr, ev->link_key,
ev->key_type, pin_len);
@@ -2907,7 +2908,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
data.rssi = info->rssi;
data.ssp_mode = 0x01;
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
name_known = eir_has_data_type(info->data,
sizeof(info->data),
EIR_NAME_COMPLETE);
@@ -2958,10 +2959,10 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
hci_conn_hold(conn);
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
goto unlock;
- if (test_bit(HCI_PAIRABLE, &hdev->dev_flags) ||
+ if (test_bit(HCI_DEV_PAIRABLE, &hdev->flags) ||
(conn->remote_auth & ~0x01) == HCI_AT_NO_BONDING) {
struct hci_cp_io_capability_reply cp;
@@ -3025,7 +3026,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
hci_dev_lock(hdev);
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
goto unlock;
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
@@ -3091,7 +3092,7 @@ static inline void hci_user_passkey_request_evt(struct hci_dev *hdev,
hci_dev_lock(hdev);
- if (test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_MGMT, &hdev->flags))
mgmt_user_passkey_request(hdev, &ev->bdaddr);
hci_dev_unlock(hdev);
@@ -3150,7 +3151,7 @@ static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
hci_dev_lock(hdev);
- if (!test_bit(HCI_MGMT, &hdev->dev_flags))
+ if (!test_bit(HCI_DEV_MGMT, &hdev->flags))
goto unlock;
data = hci_find_remote_oob_data(hdev, &ev->bdaddr);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index de07f7c..2016c1c 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -226,10 +226,10 @@ static int read_index_list(struct sock *sk)
i = 0;
list_for_each_entry(d, &hci_dev_list, list) {
- if (test_and_clear_bit(HCI_AUTO_OFF, &d->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_AUTO_OFF, &d->flags))
cancel_delayed_work(&d->power_off);
- if (test_bit(HCI_SETUP, &d->dev_flags))
+ if (test_bit(HCI_DEV_SETUP, &d->flags))
continue;
put_unaligned_le16(d->id, &rp->index[i++]);
@@ -285,7 +285,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_ISCAN, &hdev->compat_flags))
settings |= MGMT_SETTING_DISCOVERABLE;
- if (test_bit(HCI_PAIRABLE, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_PAIRABLE, &hdev->flags))
settings |= MGMT_SETTING_PAIRABLE;
if (!(hdev->features[4] & LMP_NO_BREDR))
@@ -297,7 +297,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_AUTH, &hdev->compat_flags))
settings |= MGMT_SETTING_LINK_SECURITY;
- if (test_bit(HCI_SSP_ENABLED, &hdev->compat_flags))
+ if (test_bit(HCI_DEV_SSP_ENABLED, &hdev->compat_flags))
settings |= MGMT_SETTING_SSP;
return settings;
@@ -416,10 +416,10 @@ static int update_eir(struct hci_dev *hdev)
if (!(hdev->features[6] & LMP_EXT_INQ))
return 0;
- if (!test_bit(HCI_SSP_ENABLED, &hdev->compat_flags))
+ if (!test_bit(HCI_DEV_SSP_ENABLED, &hdev->compat_flags))
return 0;
- if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_SERVICE_CACHE, &hdev->flags))
return 0;
memset(&cp, 0, sizeof(cp));
@@ -451,7 +451,7 @@ static int update_class(struct hci_dev *hdev)
BT_DBG("%s", hdev->name);
- if (test_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
+ if (test_bit(HCI_DEV_SERVICE_CACHE, &hdev->flags))
return 0;
cod[0] = hdev->minor_class;
@@ -469,7 +469,7 @@ static void service_cache_off(struct work_struct *work)
struct hci_dev *hdev = container_of(work, struct hci_dev,
service_cache.work);
- if (!test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
+ if (!test_and_clear_bit(HCI_DEV_SERVICE_CACHE, &hdev->flags))
return;
hci_dev_lock(hdev);
@@ -482,10 +482,10 @@ static void service_cache_off(struct work_struct *work)
static void mgmt_init_hdev(struct hci_dev *hdev)
{
- if (!test_and_set_bit(HCI_MGMT, &hdev->dev_flags))
+ if (!test_and_set_bit(HCI_DEV_MGMT, &hdev->flags))
INIT_DELAYED_WORK(&hdev->service_cache, service_cache_off);
- if (!test_and_set_bit(HCI_SERVICE_CACHE, &hdev->dev_flags))
+ if (!test_and_set_bit(HCI_DEV_SERVICE_CACHE, &hdev->flags))
schedule_delayed_work(&hdev->service_cache,
msecs_to_jiffies(SERVICE_CACHE_TIMEOUT));
}
@@ -502,7 +502,7 @@ static int read_controller_info(struct sock *sk, u16 index)
return cmd_status(sk, index, MGMT_OP_READ_INFO,
MGMT_STATUS_INVALID_PARAMS);
- if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
+ if (test_and_clear_bit(HCI_DEV_AUTO_OFF, &hdev->flags))
cancel_delayed_work_sync(&hdev->power_off);
hci_dev_lock(hdev);
@@ -851,9 +851,9 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data,
hci_dev_lock(hdev);
if (cp->val)
- set_bit(HCI_PAIRABLE, &hdev->dev_flags);
+ set_bit(HCI_DEV_PAIRABLE, &hdev->flags);
else
- clear_bit(HCI_PAIRABLE, &hdev->dev_flags);
+ clear_bit(HCI_DEV_PAIRABLE, &hdev->flags);
err = send_settings_rsp(sk, MGMT_OP_SET_PAIRABLE, hdev);
if (err < 0)
@@ -1008,7 +1008,7 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
hdev->major_class = cp->major;
hdev->minor_class = cp->minor;
- if (test_and_clear_bit(HCI_SERVICE_CACHE, &hdev->dev_flags)) {
+ if (test_and_clear_bit(HCI_DEV_SERVICE_CACHE, &hdev->flags)) {
hci_dev_unlock(hdev);
cancel_delayed_work_sync(&hdev->service_cache);
hci_dev_lock(hdev);
@@ -1063,12 +1063,12 @@ static int load_link_keys(struct sock *sk, u16 index, unsigned char *data,
hci_link_keys_clear(hdev);
- set_bit(HCI_LINK_KEYS, &hdev->dev_flags);
+ set_bit(HCI_DEV_LINK_KEYS, &hdev->flags);
if (cp->debug_keys)
- set_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ set_bit(HCI_DEV_DEBUG_KEYS, &hdev->flags);
else
- clear_bit(HCI_DEBUG_KEYS, &hdev->dev_flags);
+ clear_bit(HCI_DEV_DEBUG_KEYS, &hdev->flags);
for (i = 0; i < key_count; i++) {
struct mgmt_link_key_info *key = &cp->keys[i];
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index e08fe6c..1c5e103 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -217,7 +217,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn,
{
u8 dist_keys = 0;
- if (test_bit(HCI_PAIRABLE, &conn->hcon->hdev->dev_flags)) {
+ if (test_bit(HCI_DEV_PAIRABLE, &conn->hcon->hdev->flags)) {
dist_keys = SMP_DIST_ENC_KEY;
authreq |= SMP_AUTH_BONDING;
} else {
--
1.7.8.3
^ permalink raw reply related [flat|nested] 39+ messages in thread