linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs
@ 2013-08-23 20:01 Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 2/5] Bluetooth: Discovery parameters per hci_dev Andre Guedes
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andre Guedes @ 2013-08-23 20:01 UTC (permalink / raw)
  To: linux-bluetooth

The inquiry_cache and auto_accept_delay files should be added to
debugfs only if controller is BR/EDR capable.

Since in hci_register_dev() hdev has not been initialized yet,
we are not able to check if the controller is BR/EDR capable.
Thus, we postpone exporting those two files to just after
controller's initialization.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_core.c         | 17 ++++++++++++-----
 net/bluetooth/hci_sysfs.c        | 16 +++++++++++-----
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3ede820..879bf45 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -775,6 +775,7 @@ int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
 void hci_init_sysfs(struct hci_dev *hdev);
 int hci_add_sysfs(struct hci_dev *hdev);
 void hci_del_sysfs(struct hci_dev *hdev);
+void hci_sysfs_export_info(struct hci_dev *hdev);
 void hci_conn_init_sysfs(struct hci_conn *conn);
 void hci_conn_add_sysfs(struct hci_conn *conn);
 void hci_conn_del_sysfs(struct hci_conn *conn);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d9b87d..e8be6ec 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1184,11 +1184,18 @@ int hci_dev_open(__u16 dev)
 		hci_dev_hold(hdev);
 		set_bit(HCI_UP, &hdev->flags);
 		hci_notify(hdev, HCI_DEV_UP);
-		if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
-		    mgmt_valid_hdev(hdev)) {
-			hci_dev_lock(hdev);
-			mgmt_powered(hdev, 1);
-			hci_dev_unlock(hdev);
+		if (mgmt_valid_hdev(hdev)) {
+			/* If we are in HCI_SETUP phase, meaning the device
+			 * has just been registered, we should export the
+			 * remaining infos to debugfs.
+			 */
+			if (test_bit(HCI_SETUP, &hdev->dev_flags)) {
+				hci_sysfs_export_info(hdev);
+			} else {
+				hci_dev_lock(hdev);
+				mgmt_powered(hdev, 1);
+				hci_dev_unlock(hdev);
+			}
 		}
 	} else {
 		/* Init failed, cleanup */
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 7ad6ecf..c89032c 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -542,6 +542,17 @@ void hci_init_sysfs(struct hci_dev *hdev)
 	device_initialize(dev);
 }
 
+/* This function expects hdev has been already intialized */
+void hci_sysfs_export_info(struct hci_dev *hdev)
+{
+	if (lmp_bredr_capable(hdev)) {
+		debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
+				    hdev, &inquiry_cache_fops);
+		debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs,
+				    hdev, &auto_accept_delay_fops);
+	}
+}
+
 int hci_add_sysfs(struct hci_dev *hdev)
 {
 	struct device *dev = &hdev->dev;
@@ -562,16 +573,11 @@ int hci_add_sysfs(struct hci_dev *hdev)
 	if (!hdev->debugfs)
 		return 0;
 
-	debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
-			    hdev, &inquiry_cache_fops);
-
 	debugfs_create_file("blacklist", 0444, hdev->debugfs,
 			    hdev, &blacklist_fops);
 
 	debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
 
-	debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs, hdev,
-			    &auto_accept_delay_fops);
 	return 0;
 }
 
-- 
1.8.3.4


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

* [PATCH v2 2/5] Bluetooth: Discovery parameters per hci_dev
  2013-08-23 20:01 [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Andre Guedes
@ 2013-08-23 20:01 ` Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 3/5] Bluetooth: Export discovery parameters to debugfs Andre Guedes
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2013-08-23 20:01 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds discovery parameters to struct hci_dev. This way, we
will be able to configure the discovery parameters per hci device.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h | 13 +++++++++++++
 net/bluetooth/hci_core.c         | 13 ++++++++++++-
 net/bluetooth/mgmt.c             | 15 +++++++++------
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 879bf45..20dae6d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -127,6 +127,17 @@ struct amp_assoc {
 	__u8	data[HCI_MAX_AMP_ASSOC_SIZE];
 };
 
+struct discovery_param {
+	u8		scan_type;
+	u16		scan_interval;
+	u16		scan_window;
+	u16		le_scan_timeout;
+	u16		interleaved_scan_timeout;
+
+	u8		interleaved_inquiry_length;
+	u8		bredr_inquiry_length;
+};
+
 #define HCI_MAX_PAGES	3
 
 #define NUM_REASSEMBLY 4
@@ -280,6 +291,8 @@ struct hci_dev {
 	__u8			adv_data[HCI_MAX_AD_LENGTH];
 	__u8			adv_data_len;
 
+	struct discovery_param	discovery_param;
+
 	int (*open)(struct hci_dev *hdev);
 	int (*close)(struct hci_dev *hdev);
 	int (*flush)(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e8be6ec..e6d1350 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2032,6 +2032,7 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status)
 {
 	/* General inquiry access code (GIAC) */
 	u8 lap[3] = { 0x33, 0x8b, 0x9e };
+	struct discovery_param *discov = &hdev->discovery_param;
 	struct hci_request req;
 	struct hci_cp_inquiry cp;
 	int err;
@@ -2053,7 +2054,7 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status)
 
 		memset(&cp, 0, sizeof(cp));
 		memcpy(&cp.lap, lap, sizeof(cp.lap));
-		cp.length = DISCOV_INTERLEAVED_INQUIRY_LEN;
+		cp.length = discov->interleaved_inquiry_length;
 		hci_req_add(&req, HCI_OP_INQUIRY, sizeof(cp), &cp);
 
 		hci_dev_lock(hdev);
@@ -2096,6 +2097,7 @@ static void le_scan_disable_work(struct work_struct *work)
 struct hci_dev *hci_alloc_dev(void)
 {
 	struct hci_dev *hdev;
+	struct discovery_param *discov;
 
 	hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL);
 	if (!hdev)
@@ -2142,6 +2144,15 @@ struct hci_dev *hci_alloc_dev(void)
 	hci_init_sysfs(hdev);
 	discovery_init(hdev);
 
+	discov = &hdev->discovery_param;
+	discov->scan_type = LE_SCAN_ACTIVE;
+	discov->scan_interval = DISCOV_LE_SCAN_INT;
+	discov->scan_window = DISCOV_LE_SCAN_WIN;
+	discov->le_scan_timeout = DISCOV_LE_TIMEOUT;
+	discov->interleaved_scan_timeout = DISCOV_INTERLEAVED_TIMEOUT;
+	discov->interleaved_inquiry_length = DISCOV_INTERLEAVED_INQUIRY_LEN;
+	discov->bredr_inquiry_length = DISCOV_BREDR_INQUIRY_LEN;
+
 	return hdev;
 }
 EXPORT_SYMBOL(hci_alloc_dev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fedc539..b9b14c6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2642,6 +2642,8 @@ static int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)
 
 static void start_discovery_complete(struct hci_dev *hdev, u8 status)
 {
+	struct discovery_param *discov = &hdev->discovery_param;
+
 	BT_DBG("status %d", status);
 
 	if (status) {
@@ -2658,12 +2660,12 @@ static void start_discovery_complete(struct hci_dev *hdev, u8 status)
 	switch (hdev->discovery.type) {
 	case DISCOV_TYPE_LE:
 		queue_delayed_work(hdev->workqueue, &hdev->le_scan_disable,
-				   DISCOV_LE_TIMEOUT);
+				   discov->le_scan_timeout);
 		break;
 
 	case DISCOV_TYPE_INTERLEAVED:
 		queue_delayed_work(hdev->workqueue, &hdev->le_scan_disable,
-				   DISCOV_INTERLEAVED_TIMEOUT);
+				   discov->interleaved_scan_timeout);
 		break;
 
 	case DISCOV_TYPE_BREDR:
@@ -2678,6 +2680,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
 			   void *data, u16 len)
 {
 	struct mgmt_cp_start_discovery *cp = data;
+	struct discovery_param *discov = &hdev->discovery_param;
 	struct pending_cmd *cmd;
 	struct hci_cp_le_set_scan_param param_cp;
 	struct hci_cp_le_set_scan_enable enable_cp;
@@ -2739,7 +2742,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
 
 		memset(&inq_cp, 0, sizeof(inq_cp));
 		memcpy(&inq_cp.lap, lap, sizeof(inq_cp.lap));
-		inq_cp.length = DISCOV_BREDR_INQUIRY_LEN;
+		inq_cp.length = discov->bredr_inquiry_length;
 		hci_req_add(&req, HCI_OP_INQUIRY, sizeof(inq_cp), &inq_cp);
 		break;
 
@@ -2775,9 +2778,9 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
 		}
 
 		memset(&param_cp, 0, sizeof(param_cp));
-		param_cp.type = LE_SCAN_ACTIVE;
-		param_cp.interval = cpu_to_le16(DISCOV_LE_SCAN_INT);
-		param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN);
+		param_cp.type = discov->scan_type;
+		param_cp.interval = cpu_to_le16(discov->scan_interval);
+		param_cp.window = cpu_to_le16(discov->scan_window);
 		hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
 			    &param_cp);
 
-- 
1.8.3.4


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

* [PATCH v2 3/5] Bluetooth: Export discovery parameters to debugfs
  2013-08-23 20:01 [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 2/5] Bluetooth: Discovery parameters per hci_dev Andre Guedes
@ 2013-08-23 20:01 ` Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 4/5] Bluetooth: Keep the LE connection parameters in its own structure Andre Guedes
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2013-08-23 20:01 UTC (permalink / raw)
  To: linux-bluetooth

This patch exports discovery parameters under hciX directory. All
parameter files have read and write permissions. This means, we
are able to change discovery parameters by writing new values into
the files. For instance, to change the default value for the scanning
interval we can run:
$ echo 0x0016 > /sys/kernel/debug/bluetooth/hci0/discov_scan_interval

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 net/bluetooth/hci_sysfs.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index c89032c..78ef738 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -545,11 +545,36 @@ void hci_init_sysfs(struct hci_dev *hdev)
 /* This function expects hdev has been already intialized */
 void hci_sysfs_export_info(struct hci_dev *hdev)
 {
+	struct discovery_param *discov = &hdev->discovery_param;
+
 	if (lmp_bredr_capable(hdev)) {
 		debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
 				    hdev, &inquiry_cache_fops);
 		debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs,
 				    hdev, &auto_accept_delay_fops);
+		debugfs_create_x8("discov_bredr_inq_len", S_IRUSR|S_IWUSR,
+				  hdev->debugfs,
+				  &discov->bredr_inquiry_length);
+	}
+
+	if (lmp_le_capable(hdev)) {
+		debugfs_create_x8("discov_scan_type", S_IRUSR|S_IWUSR,
+				  hdev->debugfs, &discov->scan_type);
+		debugfs_create_x16("discov_scan_interval", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &discov->scan_interval);
+		debugfs_create_x16("discov_scan_window", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &discov->scan_window);
+		debugfs_create_u16("discov_le_scan_timeout", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &discov->le_scan_timeout);
+	}
+
+	if (lmp_le_capable(hdev) && lmp_bredr_capable(hdev)) {
+		debugfs_create_x8("discov_interleaved_inq_len",
+				  S_IRUSR|S_IWUSR, hdev->debugfs,
+				   &discov->interleaved_inquiry_length);
+		debugfs_create_u16("discov_interleaved_scan_timeout",
+				   S_IRUSR|S_IWUSR, hdev->debugfs,
+				   &discov->interleaved_scan_timeout);
 	}
 }
 
-- 
1.8.3.4


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

* [PATCH v2 4/5] Bluetooth: Keep the LE connection parameters in its own structure
  2013-08-23 20:01 [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 2/5] Bluetooth: Discovery parameters per hci_dev Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 3/5] Bluetooth: Export discovery parameters to debugfs Andre Guedes
@ 2013-08-23 20:01 ` Andre Guedes
  2013-08-23 20:01 ` [PATCH v2 5/5] Bluetooth: Export LE connection parameters to debugfs Andre Guedes
  2013-09-16 15:06 ` [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Gustavo Padovan
  4 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2013-08-23 20:01 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>

This will allow for easier parameterization of these fields. This is
the first step for allowing to change the parameters during runtime.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h | 13 +++++++++++++
 net/bluetooth/hci_conn.c         | 16 +++++++++-------
 net/bluetooth/hci_core.c         | 11 +++++++++++
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 20dae6d..b354211 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -117,6 +117,17 @@ struct oob_data {
 	u8 randomizer[16];
 };
 
+struct le_conn_param {
+	u16 scan_interval;
+	u16 scan_window;
+	u16 conn_interval_min;
+	u16 conn_interval_max;
+	u16 supervision_timeout;
+	u16 min_ce_lentgh;
+	u16 max_ce_lentgh;
+	u16 conn_latency;
+};
+
 #define HCI_MAX_SHORT_NAME_LENGTH	10
 
 struct amp_assoc {
@@ -287,6 +298,8 @@ struct hci_dev {
 
 	struct delayed_work	le_scan_disable;
 
+	struct le_conn_param	le_conn_param;
+
 	__s8			adv_tx_power;
 	__u8			adv_data[HCI_MAX_AD_LENGTH];
 	__u8			adv_data_len;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index f081712..97fc61b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -52,6 +52,7 @@ static const struct sco_param sco_param_wideband[] = {
 static void hci_le_create_connection(struct hci_conn *conn)
 {
 	struct hci_dev *hdev = conn->hdev;
+	struct le_conn_param *param = &hdev->le_conn_param;
 	struct hci_cp_le_create_conn cp;
 
 	conn->state = BT_CONNECT;
@@ -60,15 +61,16 @@ static void hci_le_create_connection(struct hci_conn *conn)
 	conn->sec_level = BT_SECURITY_LOW;
 
 	memset(&cp, 0, sizeof(cp));
-	cp.scan_interval = __constant_cpu_to_le16(0x0060);
-	cp.scan_window = __constant_cpu_to_le16(0x0030);
+	cp.scan_interval = __cpu_to_le16(param->scan_interval);
+	cp.scan_window = __cpu_to_le16(param->scan_window);
 	bacpy(&cp.peer_addr, &conn->dst);
 	cp.peer_addr_type = conn->dst_type;
-	cp.conn_interval_min = __constant_cpu_to_le16(0x0028);
-	cp.conn_interval_max = __constant_cpu_to_le16(0x0038);
-	cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
-	cp.min_ce_len = __constant_cpu_to_le16(0x0000);
-	cp.max_ce_len = __constant_cpu_to_le16(0x0000);
+	cp.conn_interval_min = __cpu_to_le16(param->conn_interval_min);
+	cp.conn_interval_max = __cpu_to_le16(param->conn_interval_max);
+	cp.supervision_timeout = __cpu_to_le16(param->supervision_timeout);
+	cp.min_ce_len = __constant_cpu_to_le16(param->min_ce_lentgh);
+	cp.max_ce_len = __constant_cpu_to_le16(param->max_ce_lentgh);
+	cp.conn_latency = __constant_cpu_to_le16(param->conn_latency);
 
 	hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
 }
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e6d1350..eac6709 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2098,6 +2098,7 @@ struct hci_dev *hci_alloc_dev(void)
 {
 	struct hci_dev *hdev;
 	struct discovery_param *discov;
+	struct le_conn_param *conn_param;
 
 	hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL);
 	if (!hdev)
@@ -2153,6 +2154,16 @@ struct hci_dev *hci_alloc_dev(void)
 	discov->interleaved_inquiry_length = DISCOV_INTERLEAVED_INQUIRY_LEN;
 	discov->bredr_inquiry_length = DISCOV_BREDR_INQUIRY_LEN;
 
+	conn_param = &hdev->le_conn_param;
+	conn_param->scan_interval = 0x0060;
+	conn_param->scan_window = 0x0030;
+	conn_param->conn_interval_min = 0x0028;
+	conn_param->conn_interval_max = 0x0038;
+	conn_param->supervision_timeout = 0x002a;
+	conn_param->min_ce_lentgh = 0x0000;
+	conn_param->max_ce_lentgh = 0x0000;
+	conn_param->conn_latency = 0x0000;
+
 	return hdev;
 }
 EXPORT_SYMBOL(hci_alloc_dev);
-- 
1.8.3.4


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

* [PATCH v2 5/5] Bluetooth: Export LE connection parameters to debugfs
  2013-08-23 20:01 [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Andre Guedes
                   ` (2 preceding siblings ...)
  2013-08-23 20:01 ` [PATCH v2 4/5] Bluetooth: Keep the LE connection parameters in its own structure Andre Guedes
@ 2013-08-23 20:01 ` Andre Guedes
  2013-09-16 15:06 ` [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Gustavo Padovan
  4 siblings, 0 replies; 6+ messages in thread
From: Andre Guedes @ 2013-08-23 20:01 UTC (permalink / raw)
  To: linux-bluetooth

This patch exports LE connection parameters under hciX directory if
controller is LE capable. All parameter files have read and write
permissions. This means, we are able to change LE connection parameters
by writing new values into the files. For instance, to change the
default value for supervision_timeout we can run:
$ echo 0x0040 > /sys/kernel/debug/bluetooth/hci0/le_conn_supervision_timeout

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 net/bluetooth/hci_sysfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 78ef738..ba4f7c7 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -546,6 +546,7 @@ void hci_init_sysfs(struct hci_dev *hdev)
 void hci_sysfs_export_info(struct hci_dev *hdev)
 {
 	struct discovery_param *discov = &hdev->discovery_param;
+	struct le_conn_param *conn = &hdev->le_conn_param;
 
 	if (lmp_bredr_capable(hdev)) {
 		debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
@@ -558,6 +559,7 @@ void hci_sysfs_export_info(struct hci_dev *hdev)
 	}
 
 	if (lmp_le_capable(hdev)) {
+		/* Discovery parameters */
 		debugfs_create_x8("discov_scan_type", S_IRUSR|S_IWUSR,
 				  hdev->debugfs, &discov->scan_type);
 		debugfs_create_x16("discov_scan_interval", S_IRUSR|S_IWUSR,
@@ -566,6 +568,25 @@ void hci_sysfs_export_info(struct hci_dev *hdev)
 				   hdev->debugfs, &discov->scan_window);
 		debugfs_create_u16("discov_le_scan_timeout", S_IRUSR|S_IWUSR,
 				   hdev->debugfs, &discov->le_scan_timeout);
+
+		/* Connection parameters */
+		debugfs_create_x16("le_conn_scan_interval", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->scan_interval);
+		debugfs_create_x16("le_conn_scan_window", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->scan_window);
+		debugfs_create_x16("le_conn_interval_min", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->conn_interval_min);
+		debugfs_create_x16("le_conn_interval_max", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->conn_interval_max);
+		debugfs_create_x16("le_conn_supervision_timeout",
+				   S_IRUSR|S_IWUSR, hdev->debugfs,
+				   &conn->supervision_timeout);
+		debugfs_create_x16("le_conn_min_ce_lentgh", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->min_ce_lentgh);
+		debugfs_create_x16("le_conn_max_ce_lentgh", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->max_ce_lentgh);
+		debugfs_create_x16("le_conn_latency", S_IRUSR|S_IWUSR,
+				   hdev->debugfs, &conn->conn_latency);
 	}
 
 	if (lmp_le_capable(hdev) && lmp_bredr_capable(hdev)) {
-- 
1.8.3.4


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

* Re: [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs
  2013-08-23 20:01 [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Andre Guedes
                   ` (3 preceding siblings ...)
  2013-08-23 20:01 ` [PATCH v2 5/5] Bluetooth: Export LE connection parameters to debugfs Andre Guedes
@ 2013-09-16 15:06 ` Gustavo Padovan
  4 siblings, 0 replies; 6+ messages in thread
From: Gustavo Padovan @ 2013-09-16 15:06 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

Hi Andre,

2013-08-23 Andre Guedes <andre.guedes@openbossa.org>:

> The inquiry_cache and auto_accept_delay files should be added to
> debugfs only if controller is BR/EDR capable.
> 
> Since in hci_register_dev() hdev has not been initialized yet,
> we are not able to check if the controller is BR/EDR capable.
> Thus, we postpone exporting those two files to just after
> controller's initialization.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
>  include/net/bluetooth/hci_core.h |  1 +
>  net/bluetooth/hci_core.c         | 17 ++++++++++++-----
>  net/bluetooth/hci_sysfs.c        | 16 +++++++++++-----
>  3 files changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 3ede820..879bf45 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -775,6 +775,7 @@ int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
>  void hci_init_sysfs(struct hci_dev *hdev);
>  int hci_add_sysfs(struct hci_dev *hdev);
>  void hci_del_sysfs(struct hci_dev *hdev);
> +void hci_sysfs_export_info(struct hci_dev *hdev);
>  void hci_conn_init_sysfs(struct hci_conn *conn);
>  void hci_conn_add_sysfs(struct hci_conn *conn);
>  void hci_conn_del_sysfs(struct hci_conn *conn);
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d9b87d..e8be6ec 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1184,11 +1184,18 @@ int hci_dev_open(__u16 dev)
>  		hci_dev_hold(hdev);
>  		set_bit(HCI_UP, &hdev->flags);
>  		hci_notify(hdev, HCI_DEV_UP);
> -		if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
> -		    mgmt_valid_hdev(hdev)) {
> -			hci_dev_lock(hdev);
> -			mgmt_powered(hdev, 1);
> -			hci_dev_unlock(hdev);
> +		if (mgmt_valid_hdev(hdev)) {
> +			/* If we are in HCI_SETUP phase, meaning the device
> +			 * has just been registered, we should export the
> +			 * remaining infos to debugfs.
> +			 */
> +			if (test_bit(HCI_SETUP, &hdev->dev_flags)) {
> +				hci_sysfs_export_info(hdev);
> +			} else {
> +				hci_dev_lock(hdev);
> +				mgmt_powered(hdev, 1);
> +				hci_dev_unlock(hdev);
> +			}

These patches doesn't apply cleanly on bluetooth-next anymore. Please rebase
the set and resend. Thanks. 

	Gustavo

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

end of thread, other threads:[~2013-09-16 15:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-23 20:01 [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Andre Guedes
2013-08-23 20:01 ` [PATCH v2 2/5] Bluetooth: Discovery parameters per hci_dev Andre Guedes
2013-08-23 20:01 ` [PATCH v2 3/5] Bluetooth: Export discovery parameters to debugfs Andre Guedes
2013-08-23 20:01 ` [PATCH v2 4/5] Bluetooth: Keep the LE connection parameters in its own structure Andre Guedes
2013-08-23 20:01 ` [PATCH v2 5/5] Bluetooth: Export LE connection parameters to debugfs Andre Guedes
2013-09-16 15:06 ` [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs Gustavo Padovan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).