mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
[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 <[email protected]>
This commit is contained in:
parent
04837f6447
commit
27d3528425
8 changed files with 56 additions and 9 deletions
|
|
@ -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,14 +307,22 @@ 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;
|
||||
|
||||
err = sock_register(&bt_sock_family_ops);
|
||||
if (err < 0) {
|
||||
bt_sysfs_cleanup();
|
||||
return err;
|
||||
}
|
||||
|
||||
BT_INFO("HCI device and connection manager initialized");
|
||||
|
||||
bt_sysfs_init();
|
||||
|
||||
hci_sock_init();
|
||||
|
||||
return 0;
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue