aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-02-28 03:57:28 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-28 03:57:28 -0500
commit46976c042ba1ff59253f2f7a513099175c24794e (patch)
treea7af3f1c3ef2a2d430c49fb774ab744c296a2285
parent024c378f0b719d43b01b875caefa19f2612e103a (diff)
parentf6e623a65cb301088bd04794043e82bfc996c512 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/holtmann/bluetooth-next-2.6
-rw-r--r--drivers/bluetooth/ath3k.c2
-rw-r--r--drivers/bluetooth/bcm203x.c2
-rw-r--r--drivers/bluetooth/bfusb.c2
-rw-r--r--drivers/bluetooth/bluecard_cs.c2
-rw-r--r--drivers/bluetooth/bpa10x.c2
-rw-r--r--drivers/bluetooth/bt3c_cs.c2
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c14
-rw-r--r--drivers/bluetooth/btmrvl_main.c2
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c4
-rw-r--r--drivers/bluetooth/btsdio.c2
-rw-r--r--drivers/bluetooth/btuart_cs.c2
-rw-r--r--drivers/bluetooth/btusb.c2
-rw-r--r--drivers/bluetooth/dtl1_cs.c2
-rw-r--r--drivers/bluetooth/hci_ldisc.c2
-rw-r--r--drivers/bluetooth/hci_vhci.c2
-rw-r--r--include/net/bluetooth/hci.h6
-rw-r--r--include/net/bluetooth/hci_core.h5
-rw-r--r--net/bluetooth/hci_core.c12
-rw-r--r--net/bluetooth/hci_event.c1
-rw-r--r--net/bluetooth/hci_sock.c4
-rw-r--r--net/bluetooth/hci_sysfs.c122
21 files changed, 131 insertions, 63 deletions
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index add9485ca5b6..128cae4e8629 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -143,6 +143,8 @@ static int ath3k_probe(struct usb_interface *intf,
143 usb_set_intfdata(intf, data); 143 usb_set_intfdata(intf, data);
144 if (ath3k_load_firmware(data, data->fw_data, data->fw_size)) { 144 if (ath3k_load_firmware(data, data->fw_data, data->fw_size)) {
145 usb_set_intfdata(intf, NULL); 145 usb_set_intfdata(intf, NULL);
146 kfree(data->fw_data);
147 kfree(data);
146 return -EIO; 148 return -EIO;
147 } 149 }
148 150
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index eafd4af0746e..b0c84c19f442 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -39,7 +39,7 @@
39 39
40#define VERSION "1.2" 40#define VERSION "1.2"
41 41
42static struct usb_device_id bcm203x_table[] = { 42static const struct usb_device_id bcm203x_table[] = {
43 /* Broadcom Blutonium (BCM2033) */ 43 /* Broadcom Blutonium (BCM2033) */
44 { USB_DEVICE(0x0a5c, 0x2033) }, 44 { USB_DEVICE(0x0a5c, 0x2033) },
45 45
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 2a00707aba3b..005919ab043c 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -703,7 +703,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
703 703
704 data->hdev = hdev; 704 data->hdev = hdev;
705 705
706 hdev->type = HCI_USB; 706 hdev->bus = HCI_USB;
707 hdev->driver_data = data; 707 hdev->driver_data = data;
708 SET_HCIDEV_DEV(hdev, &intf->dev); 708 SET_HCIDEV_DEV(hdev, &intf->dev);
709 709
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index c2cf81144715..d9bf87ca9e83 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -736,7 +736,7 @@ static int bluecard_open(bluecard_info_t *info)
736 736
737 info->hdev = hdev; 737 info->hdev = hdev;
738 738
739 hdev->type = HCI_PCCARD; 739 hdev->bus = HCI_PCCARD;
740 hdev->driver_data = info; 740 hdev->driver_data = info;
741 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 741 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
742 742
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index c115285867c3..d945cd12433a 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -469,7 +469,7 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
469 return -ENOMEM; 469 return -ENOMEM;
470 } 470 }
471 471
472 hdev->type = HCI_USB; 472 hdev->bus = HCI_USB;
473 hdev->driver_data = data; 473 hdev->driver_data = data;
474 474
475 data->hdev = hdev; 475 data->hdev = hdev;
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 9f5926aaf57f..027cb8bf650f 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -582,7 +582,7 @@ static int bt3c_open(bt3c_info_t *info)
582 582
583 info->hdev = hdev; 583 info->hdev = hdev;
584 584
585 hdev->type = HCI_PCCARD; 585 hdev->bus = HCI_PCCARD;
586 hdev->driver_data = info; 586 hdev->driver_data = info;
587 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 587 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
588 588
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index d43b5cb864ef..3126a3d0c45c 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -26,7 +26,8 @@
26#include "btmrvl_drv.h" 26#include "btmrvl_drv.h"
27 27
28struct btmrvl_debugfs_data { 28struct btmrvl_debugfs_data {
29 struct dentry *root_dir, *config_dir, *status_dir; 29 struct dentry *config_dir;
30 struct dentry *status_dir;
30 31
31 /* config */ 32 /* config */
32 struct dentry *psmode; 33 struct dentry *psmode;
@@ -363,6 +364,9 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
363 struct btmrvl_private *priv = hdev->driver_data; 364 struct btmrvl_private *priv = hdev->driver_data;
364 struct btmrvl_debugfs_data *dbg; 365 struct btmrvl_debugfs_data *dbg;
365 366
367 if (!hdev->debugfs)
368 return;
369
366 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL); 370 dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
367 priv->debugfs_data = dbg; 371 priv->debugfs_data = dbg;
368 372
@@ -371,9 +375,7 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
371 return; 375 return;
372 } 376 }
373 377
374 dbg->root_dir = debugfs_create_dir("btmrvl", NULL); 378 dbg->config_dir = debugfs_create_dir("config", hdev->debugfs);
375
376 dbg->config_dir = debugfs_create_dir("config", dbg->root_dir);
377 379
378 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir, 380 dbg->psmode = debugfs_create_file("psmode", 0644, dbg->config_dir,
379 hdev->driver_data, &btmrvl_psmode_fops); 381 hdev->driver_data, &btmrvl_psmode_fops);
@@ -388,7 +390,7 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
388 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir, 390 dbg->hscfgcmd = debugfs_create_file("hscfgcmd", 0644, dbg->config_dir,
389 hdev->driver_data, &btmrvl_hscfgcmd_fops); 391 hdev->driver_data, &btmrvl_hscfgcmd_fops);
390 392
391 dbg->status_dir = debugfs_create_dir("status", dbg->root_dir); 393 dbg->status_dir = debugfs_create_dir("status", hdev->debugfs);
392 dbg->curpsmode = debugfs_create_file("curpsmode", 0444, 394 dbg->curpsmode = debugfs_create_file("curpsmode", 0444,
393 dbg->status_dir, 395 dbg->status_dir,
394 hdev->driver_data, 396 hdev->driver_data,
@@ -425,7 +427,5 @@ void btmrvl_debugfs_remove(struct hci_dev *hdev)
425 debugfs_remove(dbg->txdnldready); 427 debugfs_remove(dbg->txdnldready);
426 debugfs_remove(dbg->status_dir); 428 debugfs_remove(dbg->status_dir);
427 429
428 debugfs_remove(dbg->root_dir);
429
430 kfree(dbg); 430 kfree(dbg);
431} 431}
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index f97771ce432c..53a43adf2e21 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -563,7 +563,7 @@ struct btmrvl_private *btmrvl_add_card(void *card)
563 563
564 priv->btmrvl_dev.tx_dnld_rdy = true; 564 priv->btmrvl_dev.tx_dnld_rdy = true;
565 565
566 hdev->type = HCI_SDIO; 566 hdev->bus = HCI_SDIO;
567 hdev->open = btmrvl_open; 567 hdev->open = btmrvl_open;
568 hdev->close = btmrvl_close; 568 hdev->close = btmrvl_close;
569 hdev->flush = btmrvl_flush; 569 hdev->flush = btmrvl_flush;
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 57d965b7f521..94f1f55f81f0 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -976,7 +976,7 @@ static struct sdio_driver bt_mrvl_sdio = {
976 .remove = btmrvl_sdio_remove, 976 .remove = btmrvl_sdio_remove,
977}; 977};
978 978
979static int btmrvl_sdio_init_module(void) 979static int __init btmrvl_sdio_init_module(void)
980{ 980{
981 if (sdio_register_driver(&bt_mrvl_sdio) != 0) { 981 if (sdio_register_driver(&bt_mrvl_sdio) != 0) {
982 BT_ERR("SDIO Driver Registration Failed"); 982 BT_ERR("SDIO Driver Registration Failed");
@@ -989,7 +989,7 @@ static int btmrvl_sdio_init_module(void)
989 return 0; 989 return 0;
990} 990}
991 991
992static void btmrvl_sdio_exit_module(void) 992static void __exit btmrvl_sdio_exit_module(void)
993{ 993{
994 /* Set the flag as user is removing this module. */ 994 /* Set the flag as user is removing this module. */
995 user_rmmod = 1; 995 user_rmmod = 1;
diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
index 7e298275c8f6..76e5127884f0 100644
--- a/drivers/bluetooth/btsdio.c
+++ b/drivers/bluetooth/btsdio.c
@@ -326,7 +326,7 @@ static int btsdio_probe(struct sdio_func *func,
326 return -ENOMEM; 326 return -ENOMEM;
327 } 327 }
328 328
329 hdev->type = HCI_SDIO; 329 hdev->bus = HCI_SDIO;
330 hdev->driver_data = data; 330 hdev->driver_data = data;
331 331
332 data->hdev = hdev; 332 data->hdev = hdev;
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 91c523099804..60c0953d7d00 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -500,7 +500,7 @@ static int btuart_open(btuart_info_t *info)
500 500
501 info->hdev = hdev; 501 info->hdev = hdev;
502 502
503 hdev->type = HCI_PCCARD; 503 hdev->bus = HCI_PCCARD;
504 hdev->driver_data = info; 504 hdev->driver_data = info;
505 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 505 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
506 506
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a699f09ddf7c..5d9cc53bd643 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -939,7 +939,7 @@ static int btusb_probe(struct usb_interface *intf,
939 return -ENOMEM; 939 return -ENOMEM;
940 } 940 }
941 941
942 hdev->type = HCI_USB; 942 hdev->bus = HCI_USB;
943 hdev->driver_data = data; 943 hdev->driver_data = data;
944 944
945 data->hdev = hdev; 945 data->hdev = hdev;
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 697591941e17..17788317c51a 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -485,7 +485,7 @@ static int dtl1_open(dtl1_info_t *info)
485 485
486 info->hdev = hdev; 486 info->hdev = hdev;
487 487
488 hdev->type = HCI_PCCARD; 488 hdev->bus = HCI_PCCARD;
489 hdev->driver_data = info; 489 hdev->driver_data = info;
490 SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 490 SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
491 491
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index aa0919386b8c..76a1abb8f214 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -383,7 +383,7 @@ static int hci_uart_register_dev(struct hci_uart *hu)
383 383
384 hu->hdev = hdev; 384 hu->hdev = hdev;
385 385
386 hdev->type = HCI_UART; 386 hdev->bus = HCI_UART;
387 hdev->driver_data = hu; 387 hdev->driver_data = hu;
388 388
389 hdev->open = hci_uart_open; 389 hdev->open = hci_uart_open;
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 7595274103fd..bb0aefdb4267 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -236,7 +236,7 @@ static int vhci_open(struct inode *inode, struct file *file)
236 236
237 data->hdev = hdev; 237 data->hdev = hdev;
238 238
239 hdev->type = HCI_VIRTUAL; 239 hdev->bus = HCI_VIRTUAL;
240 hdev->driver_data = data; 240 hdev->driver_data = data;
241 241
242 hdev->open = vhci_open_dev; 242 hdev->open = vhci_open_dev;
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ed3aea1605e8..fc0c502d9fd1 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -43,7 +43,7 @@
43#define HCI_NOTIFY_CONN_DEL 2 43#define HCI_NOTIFY_CONN_DEL 2
44#define HCI_NOTIFY_VOICE_SETTING 3 44#define HCI_NOTIFY_VOICE_SETTING 3
45 45
46/* HCI device types */ 46/* HCI bus types */
47#define HCI_VIRTUAL 0 47#define HCI_VIRTUAL 0
48#define HCI_USB 1 48#define HCI_USB 1
49#define HCI_PCCARD 2 49#define HCI_PCCARD 2
@@ -52,6 +52,10 @@
52#define HCI_PCI 5 52#define HCI_PCI 5
53#define HCI_SDIO 6 53#define HCI_SDIO 6
54 54
55/* HCI controller types */
56#define HCI_BREDR 0x00
57#define HCI_80211 0x01
58
55/* HCI device quirks */ 59/* HCI device quirks */
56enum { 60enum {
57 HCI_QUIRK_NO_RESET, 61 HCI_QUIRK_NO_RESET,
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7b86094a894b..ce3c99e5fa25 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -70,7 +70,8 @@ struct hci_dev {
70 char name[8]; 70 char name[8];
71 unsigned long flags; 71 unsigned long flags;
72 __u16 id; 72 __u16 id;
73 __u8 type; 73 __u8 bus;
74 __u8 dev_type;
74 bdaddr_t bdaddr; 75 bdaddr_t bdaddr;
75 __u8 dev_name[248]; 76 __u8 dev_name[248];
76 __u8 dev_class[3]; 77 __u8 dev_class[3];
@@ -134,6 +135,8 @@ struct hci_dev {
134 135
135 atomic_t promisc; 136 atomic_t promisc;
136 137
138 struct dentry *debugfs;
139
137 struct device *parent; 140 struct device *parent;
138 struct device dev; 141 struct device dev;
139 142
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 94ba34982021..4ad23192c7a5 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -491,6 +491,10 @@ int hci_dev_open(__u16 dev)
491 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks)) 491 if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
492 set_bit(HCI_RAW, &hdev->flags); 492 set_bit(HCI_RAW, &hdev->flags);
493 493
494 /* Treat all non BR/EDR controllers as raw devices for now */
495 if (hdev->dev_type != HCI_BREDR)
496 set_bit(HCI_RAW, &hdev->flags);
497
494 if (hdev->open(hdev)) { 498 if (hdev->open(hdev)) {
495 ret = -EIO; 499 ret = -EIO;
496 goto done; 500 goto done;
@@ -797,7 +801,7 @@ int hci_get_dev_info(void __user *arg)
797 801
798 strcpy(di.name, hdev->name); 802 strcpy(di.name, hdev->name);
799 di.bdaddr = hdev->bdaddr; 803 di.bdaddr = hdev->bdaddr;
800 di.type = hdev->type; 804 di.type = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
801 di.flags = hdev->flags; 805 di.flags = hdev->flags;
802 di.pkt_type = hdev->pkt_type; 806 di.pkt_type = hdev->pkt_type;
803 di.acl_mtu = hdev->acl_mtu; 807 di.acl_mtu = hdev->acl_mtu;
@@ -869,8 +873,8 @@ int hci_register_dev(struct hci_dev *hdev)
869 struct list_head *head = &hci_dev_list, *p; 873 struct list_head *head = &hci_dev_list, *p;
870 int i, id = 0; 874 int i, id = 0;
871 875
872 BT_DBG("%p name %s type %d owner %p", hdev, hdev->name, 876 BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name,
873 hdev->type, hdev->owner); 877 hdev->bus, hdev->owner);
874 878
875 if (!hdev->open || !hdev->close || !hdev->destruct) 879 if (!hdev->open || !hdev->close || !hdev->destruct)
876 return -EINVAL; 880 return -EINVAL;
@@ -946,7 +950,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
946{ 950{
947 int i; 951 int i;
948 952
949 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); 953 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
950 954
951 write_lock_bh(&hci_dev_list_lock); 955 write_lock_bh(&hci_dev_list_lock);
952 list_del(&hdev->list); 956 list_del(&hdev->list);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 592da5c909c1..6c57fc71c7e2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1698,6 +1698,7 @@ static inline void hci_sync_conn_complete_evt(struct hci_dev *hdev, struct sk_bu
1698 hci_conn_add_sysfs(conn); 1698 hci_conn_add_sysfs(conn);
1699 break; 1699 break;
1700 1700
1701 case 0x11: /* Unsupported Feature or Parameter Value */
1701 case 0x1c: /* SCO interval rejected */ 1702 case 0x1c: /* SCO interval rejected */
1702 case 0x1a: /* Unsupported Remote Feature */ 1703 case 0x1a: /* Unsupported Remote Feature */
1703 case 0x1f: /* Unspecified error */ 1704 case 0x1f: /* Unspecified error */
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 688cfebfbee0..38f08f6b86f6 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -329,6 +329,9 @@ static inline void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_
329 } 329 }
330 330
331 if (mask & HCI_CMSG_TSTAMP) { 331 if (mask & HCI_CMSG_TSTAMP) {
332#ifdef CONFIG_COMPAT
333 struct compat_timeval ctv;
334#endif
332 struct timeval tv; 335 struct timeval tv;
333 void *data; 336 void *data;
334 int len; 337 int len;
@@ -339,7 +342,6 @@ static inline void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_
339 len = sizeof(tv); 342 len = sizeof(tv);
340#ifdef CONFIG_COMPAT 343#ifdef CONFIG_COMPAT
341 if (msg->msg_flags & MSG_CMSG_COMPAT) { 344 if (msg->msg_flags & MSG_CMSG_COMPAT) {
342 struct compat_timeval ctv;
343 ctv.tv_sec = tv.tv_sec; 345 ctv.tv_sec = tv.tv_sec;
344 ctv.tv_usec = tv.tv_usec; 346 ctv.tv_usec = tv.tv_usec;
345 data = &ctv; 347 data = &ctv;
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 2bc6f6a8de68..1a79a6c7e30e 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -2,6 +2,7 @@
2 2
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/init.h> 4#include <linux/init.h>
5#include <linux/debugfs.h>
5 6
6#include <net/bluetooth/bluetooth.h> 7#include <net/bluetooth/bluetooth.h>
7#include <net/bluetooth/hci_core.h> 8#include <net/bluetooth/hci_core.h>
@@ -9,6 +10,9 @@
9struct class *bt_class = NULL; 10struct class *bt_class = NULL;
10EXPORT_SYMBOL_GPL(bt_class); 11EXPORT_SYMBOL_GPL(bt_class);
11 12
13struct dentry *bt_debugfs = NULL;
14EXPORT_SYMBOL_GPL(bt_debugfs);
15
12static struct workqueue_struct *bt_workq; 16static struct workqueue_struct *bt_workq;
13 17
14static inline char *link_typetostr(int type) 18static inline char *link_typetostr(int type)
@@ -166,9 +170,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn)
166 queue_work(bt_workq, &conn->work_del); 170 queue_work(bt_workq, &conn->work_del);
167} 171}
168 172
169static inline char *host_typetostr(int type) 173static inline char *host_bustostr(int bus)
170{ 174{
171 switch (type) { 175 switch (bus) {
172 case HCI_VIRTUAL: 176 case HCI_VIRTUAL:
173 return "VIRTUAL"; 177 return "VIRTUAL";
174 case HCI_USB: 178 case HCI_USB:
@@ -188,10 +192,28 @@ static inline char *host_typetostr(int type)
188 } 192 }
189} 193}
190 194
195static inline char *host_typetostr(int type)
196{
197 switch (type) {
198 case HCI_BREDR:
199 return "BR/EDR";
200 case HCI_80211:
201 return "802.11";
202 default:
203 return "UNKNOWN";
204 }
205}
206
207static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf)
208{
209 struct hci_dev *hdev = dev_get_drvdata(dev);
210 return sprintf(buf, "%s\n", host_bustostr(hdev->bus));
211}
212
191static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) 213static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf)
192{ 214{
193 struct hci_dev *hdev = dev_get_drvdata(dev); 215 struct hci_dev *hdev = dev_get_drvdata(dev);
194 return sprintf(buf, "%s\n", host_typetostr(hdev->type)); 216 return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type));
195} 217}
196 218
197static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) 219static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
@@ -251,32 +273,6 @@ static ssize_t show_hci_revision(struct device *dev, struct device_attribute *at
251 return sprintf(buf, "%d\n", hdev->hci_rev); 273 return sprintf(buf, "%d\n", hdev->hci_rev);
252} 274}
253 275
254static ssize_t show_inquiry_cache(struct device *dev, struct device_attribute *attr, char *buf)
255{
256 struct hci_dev *hdev = dev_get_drvdata(dev);
257 struct inquiry_cache *cache = &hdev->inq_cache;
258 struct inquiry_entry *e;
259 int n = 0;
260
261 hci_dev_lock_bh(hdev);
262
263 for (e = cache->list; e; e = e->next) {
264 struct inquiry_data *data = &e->data;
265 bdaddr_t bdaddr;
266 baswap(&bdaddr, &data->bdaddr);
267 n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
268 batostr(&bdaddr),
269 data->pscan_rep_mode, data->pscan_period_mode,
270 data->pscan_mode, data->dev_class[2],
271 data->dev_class[1], data->dev_class[0],
272 __le16_to_cpu(data->clock_offset),
273 data->rssi, data->ssp_mode, e->timestamp);
274 }
275
276 hci_dev_unlock_bh(hdev);
277 return n;
278}
279
280static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf) 276static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf)
281{ 277{
282 struct hci_dev *hdev = dev_get_drvdata(dev); 278 struct hci_dev *hdev = dev_get_drvdata(dev);
@@ -355,6 +351,7 @@ static ssize_t store_sniff_min_interval(struct device *dev, struct device_attrib
355 return count; 351 return count;
356} 352}
357 353
354static DEVICE_ATTR(bus, S_IRUGO, show_bus, NULL);
358static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); 355static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
359static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 356static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
360static DEVICE_ATTR(class, S_IRUGO, show_class, NULL); 357static DEVICE_ATTR(class, S_IRUGO, show_class, NULL);
@@ -363,7 +360,6 @@ static DEVICE_ATTR(features, S_IRUGO, show_features, NULL);
363static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL); 360static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL);
364static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL); 361static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL);
365static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL); 362static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL);
366static DEVICE_ATTR(inquiry_cache, S_IRUGO, show_inquiry_cache, NULL);
367 363
368static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR, 364static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR,
369 show_idle_timeout, store_idle_timeout); 365 show_idle_timeout, store_idle_timeout);
@@ -373,6 +369,7 @@ static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR,
373 show_sniff_min_interval, store_sniff_min_interval); 369 show_sniff_min_interval, store_sniff_min_interval);
374 370
375static struct attribute *bt_host_attrs[] = { 371static struct attribute *bt_host_attrs[] = {
372 &dev_attr_bus.attr,
376 &dev_attr_type.attr, 373 &dev_attr_type.attr,
377 &dev_attr_name.attr, 374 &dev_attr_name.attr,
378 &dev_attr_class.attr, 375 &dev_attr_class.attr,
@@ -381,7 +378,6 @@ static struct attribute *bt_host_attrs[] = {
381 &dev_attr_manufacturer.attr, 378 &dev_attr_manufacturer.attr,
382 &dev_attr_hci_version.attr, 379 &dev_attr_hci_version.attr,
383 &dev_attr_hci_revision.attr, 380 &dev_attr_hci_revision.attr,
384 &dev_attr_inquiry_cache.attr,
385 &dev_attr_idle_timeout.attr, 381 &dev_attr_idle_timeout.attr,
386 &dev_attr_sniff_max_interval.attr, 382 &dev_attr_sniff_max_interval.attr,
387 &dev_attr_sniff_min_interval.attr, 383 &dev_attr_sniff_min_interval.attr,
@@ -409,12 +405,52 @@ static struct device_type bt_host = {
409 .release = bt_host_release, 405 .release = bt_host_release,
410}; 406};
411 407
408static int inquiry_cache_open(struct inode *inode, struct file *file)
409{
410 file->private_data = inode->i_private;
411 return 0;
412}
413
414static ssize_t inquiry_cache_read(struct file *file, char __user *userbuf,
415 size_t count, loff_t *ppos)
416{
417 struct hci_dev *hdev = file->private_data;
418 struct inquiry_cache *cache = &hdev->inq_cache;
419 struct inquiry_entry *e;
420 char buf[4096];
421 int n = 0;
422
423 hci_dev_lock_bh(hdev);
424
425 for (e = cache->list; e; e = e->next) {
426 struct inquiry_data *data = &e->data;
427 bdaddr_t bdaddr;
428 baswap(&bdaddr, &data->bdaddr);
429 n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n",
430 batostr(&bdaddr),
431 data->pscan_rep_mode, data->pscan_period_mode,
432 data->pscan_mode, data->dev_class[2],
433 data->dev_class[1], data->dev_class[0],
434 __le16_to_cpu(data->clock_offset),
435 data->rssi, data->ssp_mode, e->timestamp);
436 }
437
438 hci_dev_unlock_bh(hdev);
439
440 return simple_read_from_buffer(userbuf, count, ppos, buf, n);
441}
442
443static const struct file_operations inquiry_cache_fops = {
444 .open = inquiry_cache_open,
445 .read = inquiry_cache_read,
446};
447
412int hci_register_sysfs(struct hci_dev *hdev) 448int hci_register_sysfs(struct hci_dev *hdev)
413{ 449{
414 struct device *dev = &hdev->dev; 450 struct device *dev = &hdev->dev;
415 int err; 451 int err;
416 452
417 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); 453 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
418 454
419 dev->type = &bt_host; 455 dev->type = &bt_host;
420 dev->class = bt_class; 456 dev->class = bt_class;
@@ -428,12 +464,24 @@ int hci_register_sysfs(struct hci_dev *hdev)
428 if (err < 0) 464 if (err < 0)
429 return err; 465 return err;
430 466
467 if (!bt_debugfs)
468 return 0;
469
470 hdev->debugfs = debugfs_create_dir(hdev->name, bt_debugfs);
471 if (!hdev->debugfs)
472 return 0;
473
474 debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
475 hdev, &inquiry_cache_fops);
476
431 return 0; 477 return 0;
432} 478}
433 479
434void hci_unregister_sysfs(struct hci_dev *hdev) 480void hci_unregister_sysfs(struct hci_dev *hdev)
435{ 481{
436 BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); 482 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
483
484 debugfs_remove_recursive(hdev->debugfs);
437 485
438 device_del(&hdev->dev); 486 device_del(&hdev->dev);
439} 487}
@@ -444,6 +492,8 @@ int __init bt_sysfs_init(void)
444 if (!bt_workq) 492 if (!bt_workq)
445 return -ENOMEM; 493 return -ENOMEM;
446 494
495 bt_debugfs = debugfs_create_dir("bluetooth", NULL);
496
447 bt_class = class_create(THIS_MODULE, "bluetooth"); 497 bt_class = class_create(THIS_MODULE, "bluetooth");
448 if (IS_ERR(bt_class)) { 498 if (IS_ERR(bt_class)) {
449 destroy_workqueue(bt_workq); 499 destroy_workqueue(bt_workq);
@@ -455,7 +505,9 @@ int __init bt_sysfs_init(void)
455 505
456void bt_sysfs_cleanup(void) 506void bt_sysfs_cleanup(void)
457{ 507{
458 destroy_workqueue(bt_workq);
459
460 class_destroy(bt_class); 508 class_destroy(bt_class);
509
510 debugfs_remove_recursive(bt_debugfs);
511
512 destroy_workqueue(bt_workq);
461} 513}