aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-07-03 04:02:37 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-07-03 22:54:00 -0400
commit27d35284258c596900e0e41c46932ec4abe6a7b1 (patch)
treed1a0f236b589e14f3c6251e9dfcb2b2aafdaf5ad /net/bluetooth
parent04837f6447c7f3ef114cda1ad761822dedbff8cf (diff)
[Bluetooth] Add platform device for virtual and serial devices
This patch adds a generic Bluetooth platform device that can be used as parent device by virtual and serial devices. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/af_bluetooth.c20
-rw-r--r--net/bluetooth/hci_sysfs.c39
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
308static int __init bt_init(void) 308static 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
332subsys_initcall(bt_init); 340subsys_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
201EXPORT_SYMBOL_GPL(bt_class); 202EXPORT_SYMBOL_GPL(bt_class);
202 203
204static struct bus_type bt_bus = {
205 .name = "bluetooth",
206};
207
208static struct platform_device *bt_platform;
209
203int hci_register_sysfs(struct hci_dev *hdev) 210int 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
234int __init bt_sysfs_init(void) 246int __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
239void __exit bt_sysfs_cleanup(void) 270void __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}