diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2009-05-22 14:25:34 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-22 14:25:34 -0400 |
commit | e4b636366c00738b9609cda307014d71b1225b7f (patch) | |
tree | 760b67b3624eda62e943e48ce93635c30a5b47bf /net/bluetooth/hci_sysfs.c | |
parent | b9ed7252d219c1c663944bf03846eabb515dbe75 (diff) | |
parent | 279e677faa775ad16e75c32e1bf4a37f8158bc61 (diff) |
Merge branch 'master' into for-2.6.31
Conflicts:
drivers/block/hd.c
drivers/block/mg_disk.c
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'net/bluetooth/hci_sysfs.c')
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index ed82796d4a0f..4cc3624bd22d 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -9,8 +9,7 @@ | |||
9 | struct class *bt_class = NULL; | 9 | struct class *bt_class = NULL; |
10 | EXPORT_SYMBOL_GPL(bt_class); | 10 | EXPORT_SYMBOL_GPL(bt_class); |
11 | 11 | ||
12 | static struct workqueue_struct *btaddconn; | 12 | static struct workqueue_struct *bt_workq; |
13 | static struct workqueue_struct *btdelconn; | ||
14 | 13 | ||
15 | static inline char *link_typetostr(int type) | 14 | static inline char *link_typetostr(int type) |
16 | { | 15 | { |
@@ -88,35 +87,20 @@ static struct device_type bt_link = { | |||
88 | 87 | ||
89 | static void add_conn(struct work_struct *work) | 88 | static void add_conn(struct work_struct *work) |
90 | { | 89 | { |
91 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | 90 | struct hci_conn *conn = container_of(work, struct hci_conn, work_add); |
91 | struct hci_dev *hdev = conn->hdev; | ||
92 | |||
93 | /* ensure previous del is complete */ | ||
94 | flush_work(&conn->work_del); | ||
92 | 95 | ||
93 | flush_workqueue(btdelconn); | 96 | dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); |
94 | 97 | ||
95 | if (device_add(&conn->dev) < 0) { | 98 | if (device_add(&conn->dev) < 0) { |
96 | BT_ERR("Failed to register connection device"); | 99 | BT_ERR("Failed to register connection device"); |
97 | return; | 100 | return; |
98 | } | 101 | } |
99 | } | ||
100 | |||
101 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
102 | { | ||
103 | struct hci_dev *hdev = conn->hdev; | ||
104 | |||
105 | BT_DBG("conn %p", conn); | ||
106 | |||
107 | conn->dev.type = &bt_link; | ||
108 | conn->dev.class = bt_class; | ||
109 | conn->dev.parent = &hdev->dev; | ||
110 | |||
111 | dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle); | ||
112 | |||
113 | dev_set_drvdata(&conn->dev, conn); | ||
114 | |||
115 | device_initialize(&conn->dev); | ||
116 | 102 | ||
117 | INIT_WORK(&conn->work, add_conn); | 103 | hci_dev_hold(hdev); |
118 | |||
119 | queue_work(btaddconn, &conn->work); | ||
120 | } | 104 | } |
121 | 105 | ||
122 | /* | 106 | /* |
@@ -131,9 +115,15 @@ static int __match_tty(struct device *dev, void *data) | |||
131 | 115 | ||
132 | static void del_conn(struct work_struct *work) | 116 | static void del_conn(struct work_struct *work) |
133 | { | 117 | { |
134 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | 118 | struct hci_conn *conn = container_of(work, struct hci_conn, work_del); |
135 | struct hci_dev *hdev = conn->hdev; | 119 | struct hci_dev *hdev = conn->hdev; |
136 | 120 | ||
121 | /* ensure previous add is complete */ | ||
122 | flush_work(&conn->work_add); | ||
123 | |||
124 | if (!device_is_registered(&conn->dev)) | ||
125 | return; | ||
126 | |||
137 | while (1) { | 127 | while (1) { |
138 | struct device *dev; | 128 | struct device *dev; |
139 | 129 | ||
@@ -146,19 +136,40 @@ static void del_conn(struct work_struct *work) | |||
146 | 136 | ||
147 | device_del(&conn->dev); | 137 | device_del(&conn->dev); |
148 | put_device(&conn->dev); | 138 | put_device(&conn->dev); |
139 | |||
149 | hci_dev_put(hdev); | 140 | hci_dev_put(hdev); |
150 | } | 141 | } |
151 | 142 | ||
152 | void hci_conn_del_sysfs(struct hci_conn *conn) | 143 | void hci_conn_init_sysfs(struct hci_conn *conn) |
153 | { | 144 | { |
145 | struct hci_dev *hdev = conn->hdev; | ||
146 | |||
154 | BT_DBG("conn %p", conn); | 147 | BT_DBG("conn %p", conn); |
155 | 148 | ||
156 | if (!device_is_registered(&conn->dev)) | 149 | conn->dev.type = &bt_link; |
157 | return; | 150 | conn->dev.class = bt_class; |
151 | conn->dev.parent = &hdev->dev; | ||
152 | |||
153 | dev_set_drvdata(&conn->dev, conn); | ||
154 | |||
155 | device_initialize(&conn->dev); | ||
156 | |||
157 | INIT_WORK(&conn->work_add, add_conn); | ||
158 | INIT_WORK(&conn->work_del, del_conn); | ||
159 | } | ||
158 | 160 | ||
159 | INIT_WORK(&conn->work, del_conn); | 161 | void hci_conn_add_sysfs(struct hci_conn *conn) |
162 | { | ||
163 | BT_DBG("conn %p", conn); | ||
160 | 164 | ||
161 | queue_work(btdelconn, &conn->work); | 165 | queue_work(bt_workq, &conn->work_add); |
166 | } | ||
167 | |||
168 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
169 | { | ||
170 | BT_DBG("conn %p", conn); | ||
171 | |||
172 | queue_work(bt_workq, &conn->work_del); | ||
162 | } | 173 | } |
163 | 174 | ||
164 | static inline char *host_typetostr(int type) | 175 | static inline char *host_typetostr(int type) |
@@ -435,20 +446,13 @@ void hci_unregister_sysfs(struct hci_dev *hdev) | |||
435 | 446 | ||
436 | int __init bt_sysfs_init(void) | 447 | int __init bt_sysfs_init(void) |
437 | { | 448 | { |
438 | btaddconn = create_singlethread_workqueue("btaddconn"); | 449 | bt_workq = create_singlethread_workqueue("bluetooth"); |
439 | if (!btaddconn) | 450 | if (!bt_workq) |
440 | return -ENOMEM; | 451 | return -ENOMEM; |
441 | 452 | ||
442 | btdelconn = create_singlethread_workqueue("btdelconn"); | ||
443 | if (!btdelconn) { | ||
444 | destroy_workqueue(btaddconn); | ||
445 | return -ENOMEM; | ||
446 | } | ||
447 | |||
448 | bt_class = class_create(THIS_MODULE, "bluetooth"); | 453 | bt_class = class_create(THIS_MODULE, "bluetooth"); |
449 | if (IS_ERR(bt_class)) { | 454 | if (IS_ERR(bt_class)) { |
450 | destroy_workqueue(btdelconn); | 455 | destroy_workqueue(bt_workq); |
451 | destroy_workqueue(btaddconn); | ||
452 | return PTR_ERR(bt_class); | 456 | return PTR_ERR(bt_class); |
453 | } | 457 | } |
454 | 458 | ||
@@ -457,8 +461,7 @@ int __init bt_sysfs_init(void) | |||
457 | 461 | ||
458 | void bt_sysfs_cleanup(void) | 462 | void bt_sysfs_cleanup(void) |
459 | { | 463 | { |
460 | destroy_workqueue(btaddconn); | 464 | destroy_workqueue(bt_workq); |
461 | destroy_workqueue(btdelconn); | ||
462 | 465 | ||
463 | class_destroy(bt_class); | 466 | class_destroy(bt_class); |
464 | } | 467 | } |