summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sysfs.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-07-03 10:02:37 +0200
committerDavid S. Miller <davem@sunset.davemloft.net>2006-07-03 19:54:00 -0700
commit27d35284258c596900e0e41c46932ec4abe6a7b1 (patch)
treed1a0f236b589e14f3c6251e9dfcb2b2aafdaf5ad /net/bluetooth/hci_sysfs.c
parent04837f6447c7f3ef114cda1ad761822dedbff8cf (diff)
downloadblackbird-op-linux-27d35284258c596900e0e41c46932ec4abe6a7b1.tar.gz
blackbird-op-linux-27d35284258c596900e0e41c46932ec4abe6a7b1.zip
[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/hci_sysfs.c')
-rw-r--r--net/bluetooth/hci_sysfs.c39
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 @@
#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);
}
OpenPOWER on IntegriCloud