]> err.no Git - linux-2.6/commitdiff
[Bluetooth] Add platform device for virtual and serial devices
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 3 Jul 2006 08:02:37 +0000 (10:02 +0200)
committerDavid S. Miller <davem@sunset.davemloft.net>
Tue, 4 Jul 2006 02:54:00 +0000 (19:54 -0700)
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>
drivers/bluetooth/bluecard_cs.c
drivers/bluetooth/bt3c_cs.c
drivers/bluetooth/btuart_cs.c
drivers/bluetooth/dtl1_cs.c
drivers/bluetooth/hci_vhci.c
include/net/bluetooth/hci_core.h
net/bluetooth/af_bluetooth.c
net/bluetooth/hci_sysfs.c

index 2830f58d6f779453bf9cdc434e188e77415ad0a3..8eebf9ca378664d3068fd963e1ae7f0fccf97b29 100644 (file)
@@ -739,6 +739,7 @@ static int bluecard_open(bluecard_info_t *info)
 
        hdev->type = HCI_PCCARD;
        hdev->driver_data = info;
+       SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
        hdev->open     = bluecard_hci_open;
        hdev->close    = bluecard_hci_close;
index c9dba5565caceacca71d53092bb7759540a32244..df7bb016df491bdda5296eeee2b74e60e7713704 100644 (file)
@@ -582,6 +582,7 @@ static int bt3c_open(bt3c_info_t *info)
 
        hdev->type = HCI_PCCARD;
        hdev->driver_data = info;
+       SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
        hdev->open     = bt3c_hci_open;
        hdev->close    = bt3c_hci_close;
index c889bf8109a152de59c57367cdd17b5c56bb3606..746ccca97f6f93aae72b8ffff71d6be269cb3417 100644 (file)
@@ -502,6 +502,7 @@ static int btuart_open(btuart_info_t *info)
 
        hdev->type = HCI_PCCARD;
        hdev->driver_data = info;
+       SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
        hdev->open     = btuart_hci_open;
        hdev->close    = btuart_hci_close;
index be6eed175aa3ff74dea2291a3d9bc6b5af0520ae..0e99def8a1e3886f9abab5591343600515943efb 100644 (file)
@@ -484,6 +484,7 @@ static int dtl1_open(dtl1_info_t *info)
 
        hdev->type = HCI_PCCARD;
        hdev->driver_data = info;
+       SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
        hdev->open     = dtl1_hci_open;
        hdev->close    = dtl1_hci_close;
index ea589007fa260e903a13cb47ec06ab889c232fc2..aac67a3a6019958a5ad77347aa0dcc11c6609c99 100644 (file)
@@ -277,7 +277,6 @@ static int vhci_open(struct inode *inode, struct file *file)
 
        hdev->type = HCI_VHCI;
        hdev->driver_data = vhci;
-       SET_HCIDEV_DEV(hdev, vhci_miscdev.dev);
 
        hdev->open     = vhci_open_dev;
        hdev->close    = vhci_close_dev;
index f6852707bd6480a320e6f7962e453e84376572a4..ae67b36d76dc108568518db52d00b2d6ad31af47 100644 (file)
@@ -124,6 +124,7 @@ struct hci_dev {
 
        atomic_t                promisc;
 
+       struct device           *dev;
        struct class_device     class_dev;
 
        struct module           *owner;
index 729461fcfe9933217a9df9642a3fa59f5d9a2aa4..788ea7a2b74498c10534501e62c3e91fd17c117e 100644 (file)
@@ -48,7 +48,7 @@
 #define BT_DBG(D...)
 #endif
 
-#define VERSION "2.9"
+#define VERSION "2.10"
 
 /* Bluetooth sockets */
 #define BT_MAX_PROTO   8
@@ -307,13 +307,21 @@ static struct net_proto_family bt_sock_family_ops = {
 
 static int __init bt_init(void)
 {
+       int err;
+
        BT_INFO("Core ver %s", VERSION);
 
-       sock_register(&bt_sock_family_ops);
+       err = bt_sysfs_init();
+       if (err < 0)
+               return err;
 
-       BT_INFO("HCI device and connection manager initialized");
+       err = sock_register(&bt_sock_family_ops);
+       if (err < 0) {
+               bt_sysfs_cleanup();
+               return err;
+       }
 
-       bt_sysfs_init();
+       BT_INFO("HCI device and connection manager initialized");
 
        hci_sock_init();
 
@@ -324,9 +332,9 @@ static void __exit bt_exit(void)
 {
        hci_sock_cleanup();
 
-       bt_sysfs_cleanup();
-
        sock_unregister(PF_BLUETOOTH);
+
+       bt_sysfs_cleanup();
 }
 
 subsys_initcall(bt_init);
index 89918d2f1fdccbb33d9eb35c93b9bfad91fb38d3..7789e26c84b9d20afc748d13d8e65b8d62f22d4d 100644 (file)
@@ -3,6 +3,8 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
+#include <linux/platform_device.h>
+
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
@@ -197,9 +199,14 @@ struct class bt_class = {
        .uevent         = bt_uevent,
 #endif
 };
-
 EXPORT_SYMBOL_GPL(bt_class);
 
+static struct bus_type bt_bus = {
+       .name   = "bluetooth",
+};
+
+static struct platform_device *bt_platform;
+
 int hci_register_sysfs(struct hci_dev *hdev)
 {
        struct class_device *cdev = &hdev->class_dev;
@@ -211,6 +218,11 @@ int hci_register_sysfs(struct hci_dev *hdev)
        cdev->class = &bt_class;
        class_set_devdata(cdev, hdev);
 
+       if (!cdev->dev)
+               cdev->dev = &bt_platform->dev;
+
+       hdev->dev = cdev->dev;
+
        strlcpy(cdev->class_id, hdev->name, BUS_ID_SIZE);
        err = class_device_register(cdev);
        if (err < 0)
@@ -233,10 +245,33 @@ void hci_unregister_sysfs(struct hci_dev *hdev)
 
 int __init bt_sysfs_init(void)
 {
-       return class_register(&bt_class);
+       int err;
+
+       bt_platform = platform_device_register_simple("bluetooth", -1, NULL, 0);
+       if (IS_ERR(bt_platform))
+               return PTR_ERR(bt_platform);
+
+       err = bus_register(&bt_bus);
+       if (err < 0) {
+               platform_device_unregister(bt_platform);
+               return err;
+       }
+
+       err = class_register(&bt_class);
+       if (err < 0) {
+               bus_unregister(&bt_bus);
+               platform_device_unregister(bt_platform);
+               return err;
+       }
+
+       return 0;
 }
 
 void __exit bt_sysfs_cleanup(void)
 {
        class_unregister(&bt_class);
+
+       bus_unregister(&bt_bus);
+
+       platform_device_unregister(bt_platform);
 }