Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: expose quirks through debugfs
@ 2015-03-18  5:49 Jakub Pawlowski
  2015-03-18  7:36 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Pawlowski @ 2015-03-18  5:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Pawlowski

This patch expose controller quirks through debugfs. It would be
useful for BlueZ tests using vhci. Currently there is no way to
test quirk dependent behaviour. It might be also useful for manual
testing.

Signed-off-by: Jakub Pawlowski <jpawlowski@google.com>
---
 include/net/bluetooth/hci.h |  2 ++
 net/bluetooth/hci_debugfs.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 06e7eee..e9cec98 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -168,6 +168,8 @@ enum {
 	 * during the hdev->setup vendor callback.
 	 */
 	HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
+
+	__HCI_NUM_QUIRKS
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
index 0818fab..0011d1e 100644
--- a/net/bluetooth/hci_debugfs.c
+++ b/net/bluetooth/hci_debugfs.c
@@ -277,6 +277,33 @@ static const struct file_operations sc_only_mode_fops = {
 	.llseek		= default_llseek,
 };
 
+static int quirks_set(void *data, u64 val)
+{
+	struct hci_dev *hdev = data;
+
+	if (val >= (1 << __HCI_NUM_QUIRKS))
+		return -EINVAL;
+
+	hci_dev_lock(hdev);
+	hdev->quirks = val;
+	hci_dev_unlock(hdev);
+
+	return 0;
+}
+
+static int quirks_get(void *data, u64 *val)
+{
+	struct hci_dev *hdev = data;
+
+	hci_dev_lock(hdev);
+	*val = hdev->quirks;
+	hci_dev_unlock(hdev);
+
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(quirks_fops, quirks_get, quirks_set, "%llu\n");
+
 void hci_debugfs_create_common(struct hci_dev *hdev)
 {
 	debugfs_create_file("features", 0444, hdev->debugfs, hdev,
@@ -308,6 +335,8 @@ void hci_debugfs_create_common(struct hci_dev *hdev)
 	if (lmp_sc_capable(hdev) || lmp_le_capable(hdev))
 		debugfs_create_file("sc_only_mode", 0444, hdev->debugfs,
 				    hdev, &sc_only_mode_fops);
+
+	debugfs_create_file("quirks", 0644, hdev->debugfs, hdev, &quirks_fops);
 }
 
 static int inquiry_cache_show(struct seq_file *f, void *p)
-- 
2.2.0.rc0.207.ga3a616c


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

end of thread, other threads:[~2015-03-18  7:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-18  5:49 [PATCH] Bluetooth: expose quirks through debugfs Jakub Pawlowski
2015-03-18  7:36 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox