diff options
Diffstat (limited to 'net/bluetooth/hci_sysfs.c')
-rw-r--r-- | net/bluetooth/hci_sysfs.c | 39 |
1 files changed, 37 insertions, 2 deletions
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 | } |