aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sysfs.c
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/hci_sysfs.c
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/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 @@
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}