mac80211: fix peer HT capabilities
[safe/jmp/linux-2.6] / net / bluetooth / hci_sysfs.c
index f4f6615..2bc6f6a 100644 (file)
@@ -6,16 +6,10 @@
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
-#ifndef CONFIG_BT_HCI_CORE_DEBUG
-#undef  BT_DBG
-#define BT_DBG(D...)
-#endif
-
 struct class *bt_class = NULL;
 EXPORT_SYMBOL_GPL(bt_class);
 
-static struct workqueue_struct *btaddconn;
-static struct workqueue_struct *btdelconn;
+static struct workqueue_struct *bt_workq;
 
 static inline char *link_typetostr(int type)
 {
@@ -74,7 +68,7 @@ static struct attribute_group bt_link_group = {
        .attrs = bt_link_attrs,
 };
 
-static struct attribute_group *bt_link_groups[] = {
+static const struct attribute_group *bt_link_groups[] = {
        &bt_link_group,
        NULL
 };
@@ -93,36 +87,19 @@ static struct device_type bt_link = {
 
 static void add_conn(struct work_struct *work)
 {
-       struct hci_conn *conn = container_of(work, struct hci_conn, work);
+       struct hci_conn *conn = container_of(work, struct hci_conn, work_add);
+       struct hci_dev *hdev = conn->hdev;
 
-       flush_workqueue(btdelconn);
+       dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
+
+       dev_set_drvdata(&conn->dev, conn);
 
        if (device_add(&conn->dev) < 0) {
                BT_ERR("Failed to register connection device");
                return;
        }
-}
 
-void hci_conn_add_sysfs(struct hci_conn *conn)
-{
-       struct hci_dev *hdev = conn->hdev;
-
-       BT_DBG("conn %p", conn);
-
-       conn->dev.type = &bt_link;
-       conn->dev.class = bt_class;
-       conn->dev.parent = &hdev->dev;
-
-       snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d",
-                                       hdev->name, conn->handle);
-
-       dev_set_drvdata(&conn->dev, conn);
-
-       device_initialize(&conn->dev);
-
-       INIT_WORK(&conn->work, add_conn);
-
-       queue_work(btaddconn, &conn->work);
+       hci_dev_hold(hdev);
 }
 
 /*
@@ -132,39 +109,61 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
  */
 static int __match_tty(struct device *dev, void *data)
 {
-       return !strncmp(dev->bus_id, "rfcomm", 6);
+       return !strncmp(dev_name(dev), "rfcomm", 6);
 }
 
 static void del_conn(struct work_struct *work)
 {
-       struct hci_conn *conn = container_of(work, struct hci_conn, work);
+       struct hci_conn *conn = container_of(work, struct hci_conn, work_del);
        struct hci_dev *hdev = conn->hdev;
 
+       if (!device_is_registered(&conn->dev))
+               return;
+
        while (1) {
                struct device *dev;
 
                dev = device_find_child(&conn->dev, NULL, __match_tty);
                if (!dev)
                        break;
-               device_move(dev, NULL);
+               device_move(dev, NULL, DPM_ORDER_DEV_LAST);
                put_device(dev);
        }
 
        device_del(&conn->dev);
        put_device(&conn->dev);
+
        hci_dev_put(hdev);
 }
 
-void hci_conn_del_sysfs(struct hci_conn *conn)
+void hci_conn_init_sysfs(struct hci_conn *conn)
 {
+       struct hci_dev *hdev = conn->hdev;
+
        BT_DBG("conn %p", conn);
 
-       if (!device_is_registered(&conn->dev))
-               return;
+       conn->dev.type = &bt_link;
+       conn->dev.class = bt_class;
+       conn->dev.parent = &hdev->dev;
+
+       device_initialize(&conn->dev);
+
+       INIT_WORK(&conn->work_add, add_conn);
+       INIT_WORK(&conn->work_del, del_conn);
+}
 
-       INIT_WORK(&conn->work, del_conn);
+void hci_conn_add_sysfs(struct hci_conn *conn)
+{
+       BT_DBG("conn %p", conn);
+
+       queue_work(bt_workq, &conn->work_add);
+}
+
+void hci_conn_del_sysfs(struct hci_conn *conn)
+{
+       BT_DBG("conn %p", conn);
 
-       queue_work(btdelconn, &conn->work);
+       queue_work(bt_workq, &conn->work_del);
 }
 
 static inline char *host_typetostr(int type)
@@ -393,7 +392,7 @@ static struct attribute_group bt_host_group = {
        .attrs = bt_host_attrs,
 };
 
-static struct attribute_group *bt_host_groups[] = {
+static const struct attribute_group *bt_host_groups[] = {
        &bt_host_group,
        NULL
 };
@@ -421,7 +420,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
        dev->class = bt_class;
        dev->parent = hdev->parent;
 
-       strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE);
+       dev_set_name(dev, "%s", hdev->name);
 
        dev_set_drvdata(dev, hdev);
 
@@ -441,20 +440,13 @@ void hci_unregister_sysfs(struct hci_dev *hdev)
 
 int __init bt_sysfs_init(void)
 {
-       btaddconn = create_singlethread_workqueue("btaddconn");
-       if (!btaddconn)
+       bt_workq = create_singlethread_workqueue("bluetooth");
+       if (!bt_workq)
                return -ENOMEM;
 
-       btdelconn = create_singlethread_workqueue("btdelconn");
-       if (!btdelconn) {
-               destroy_workqueue(btaddconn);
-               return -ENOMEM;
-       }
-
        bt_class = class_create(THIS_MODULE, "bluetooth");
        if (IS_ERR(bt_class)) {
-               destroy_workqueue(btdelconn);
-               destroy_workqueue(btaddconn);
+               destroy_workqueue(bt_workq);
                return PTR_ERR(bt_class);
        }
 
@@ -463,8 +455,7 @@ int __init bt_sysfs_init(void)
 
 void bt_sysfs_cleanup(void)
 {
-       destroy_workqueue(btaddconn);
-       destroy_workqueue(btdelconn);
+       destroy_workqueue(bt_workq);
 
        class_destroy(bt_class);
 }