diff options
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 20 | ||||
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 39 |
2 files changed, 51 insertions, 8 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 729461fcfe99..788ea7a2b744 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #define BT_DBG(D...) | 48 | #define BT_DBG(D...) |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #define VERSION "2.9" | 51 | #define VERSION "2.10" |
52 | 52 | ||
53 | /* Bluetooth sockets */ | 53 | /* Bluetooth sockets */ |
54 | #define BT_MAX_PROTO 8 | 54 | #define BT_MAX_PROTO 8 |
@@ -307,13 +307,21 @@ static struct net_proto_family bt_sock_family_ops = { | |||
307 | 307 | ||
308 | static int __init bt_init(void) | 308 | static int __init bt_init(void) |
309 | { | 309 | { |
310 | int err; | ||
311 | |||
310 | BT_INFO("Core ver %s", VERSION); | 312 | BT_INFO("Core ver %s", VERSION); |
311 | 313 | ||
312 | sock_register(&bt_sock_family_ops); | 314 | err = bt_sysfs_init(); |
315 | if (err < 0) | ||
316 | return err; | ||
313 | 317 | ||
314 | BT_INFO("HCI device and connection manager initialized"); | 318 | err = sock_register(&bt_sock_family_ops); |
319 | if (err < 0) { | ||
320 | bt_sysfs_cleanup(); | ||
321 | return err; | ||
322 | } | ||
315 | 323 | ||
316 | bt_sysfs_init(); | 324 | BT_INFO("HCI device and connection manager initialized"); |
317 | 325 | ||
318 | hci_sock_init(); | 326 | hci_sock_init(); |
319 | 327 | ||
@@ -324,9 +332,9 @@ static void __exit bt_exit(void) | |||
324 | { | 332 | { |
325 | hci_sock_cleanup(); | 333 | hci_sock_cleanup(); |
326 | 334 | ||
327 | bt_sysfs_cleanup(); | ||
328 | |||
329 | sock_unregister(PF_BLUETOOTH); | 335 | sock_unregister(PF_BLUETOOTH); |
336 | |||
337 | bt_sysfs_cleanup(); | ||
330 | } | 338 | } |
331 | 339 | ||
332 | subsys_initcall(bt_init); | 340 | subsys_initcall(bt_init); |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index 89918d2f1fdc..7789e26c84b9 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -3,6 +3,8 @@ | |||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | 5 | ||
6 | #include <linux/platform_device.h> | ||
7 | |||
6 | #include <net/bluetooth/bluetooth.h> | 8 | #include <net/bluetooth/bluetooth.h> |
7 | #include <net/bluetooth/hci_core.h> | 9 | #include <net/bluetooth/hci_core.h> |
8 | 10 | ||
@@ -197,9 +199,14 @@ struct class bt_class = { | |||
197 | .uevent = bt_uevent, | 199 | .uevent = bt_uevent, |
198 | #endif | 200 | #endif |
199 | }; | 201 | }; |
200 | |||
201 | EXPORT_SYMBOL_GPL(bt_class); | 202 | EXPORT_SYMBOL_GPL(bt_class); |
202 | 203 | ||
204 | static struct bus_type bt_bus = { | ||
205 | .name = "bluetooth", | ||
206 | }; | ||
207 | |||
208 | static struct platform_device *bt_platform; | ||
209 | |||
203 | int hci_register_sysfs(struct hci_dev *hdev) | 210 | int hci_register_sysfs(struct hci_dev *hdev) |
204 | { | 211 | { |
205 | struct class_device *cdev = &hdev->class_dev; | 212 | struct class_device *cdev = &hdev->class_dev; |
@@ -211,6 +218,11 @@ int hci_register_sysfs(struct hci_dev *hdev) | |||
211 | cdev->class = &bt_class; | 218 | cdev->class = &bt_class; |
212 | class_set_devdata(cdev, hdev); | 219 | class_set_devdata(cdev, hdev); |
213 | 220 | ||
221 | if (!cdev->dev) | ||
222 | cdev->dev = &bt_platform->dev; | ||
223 | |||
224 | hdev->dev = cdev->dev; | ||
225 | |||
214 | strlcpy(cdev->class_id, hdev->name, BUS_ID_SIZE); | 226 | strlcpy(cdev->class_id, hdev->name, BUS_ID_SIZE); |
215 | err = class_device_register(cdev); | 227 | err = class_device_register(cdev); |
216 | if (err < 0) | 228 | if (err < 0) |
@@ -233,10 +245,33 @@ void hci_unregister_sysfs(struct hci_dev *hdev) | |||
233 | 245 | ||
234 | int __init bt_sysfs_init(void) | 246 | int __init bt_sysfs_init(void) |
235 | { | 247 | { |
236 | return class_register(&bt_class); | 248 | int err; |
249 | |||
250 | bt_platform = platform_device_register_simple("bluetooth", -1, NULL, 0); | ||
251 | if (IS_ERR(bt_platform)) | ||
252 | return PTR_ERR(bt_platform); | ||
253 | |||
254 | err = bus_register(&bt_bus); | ||
255 | if (err < 0) { | ||
256 | platform_device_unregister(bt_platform); | ||
257 | return err; | ||
258 | } | ||
259 | |||
260 | err = class_register(&bt_class); | ||
261 | if (err < 0) { | ||
262 | bus_unregister(&bt_bus); | ||
263 | platform_device_unregister(bt_platform); | ||
264 | return err; | ||
265 | } | ||
266 | |||
267 | return 0; | ||
237 | } | 268 | } |
238 | 269 | ||
239 | void __exit bt_sysfs_cleanup(void) | 270 | void __exit bt_sysfs_cleanup(void) |
240 | { | 271 | { |
241 | class_unregister(&bt_class); | 272 | class_unregister(&bt_class); |
273 | |||
274 | bus_unregister(&bt_bus); | ||
275 | |||
276 | platform_device_unregister(bt_platform); | ||
242 | } | 277 | } |