Bluetooth: Add skeleton for 6LoWPAN mgmt command handling
Subsystems (2)
PATCH 1/2 Bluetooth: Add skeleton for 6LoWPAN mgmt command handling
From: Johan Hedberg <[email protected]>
This patch defines a new HCI channel for 6LoWPAN usage and registers a command handler table for it in the 6lowpan module.
--- include/net/bluetooth/hci_sock.h | 1 + net/bluetooth/6lowpan.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)
include/net/bluetooth/hci_sock.h +1 -0
@@ -45,6 +45,7 @@ struct sockaddr_hci {#define HCI_CHANNEL_USER 1#define HCI_CHANNEL_MONITOR 2#define HCI_CHANNEL_CONTROL 3 +#define HCI_CHANNEL_6LOWPAN 4struct hci_filter {unsigned long type_mask;
net/bluetooth/6lowpan.c +20 -1
@@ -25,6 +25,7 @@#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> +#include <net/bluetooth/hci_sock.h> #include <net/bluetooth/l2cap.h> #include <net/6lowpan.h> /* for the compression support */
@@ -1433,8 +1434,20 @@ static struct notifier_block bt_6lowpan_dev_notifier = { .notifier_call = device_event, }; +static const struct hci_mgmt_handler bt_6lowpan_handlers[] = { + {NULL },/* 0x0000 (no command) */ +}; + +static struct hci_mgmt_chan bt_6lowpan_chan = { + .channel =HCI_CHANNEL_6LOWPAN , + .handler_count =ARRAY_SIZE (bt_6lowpan_handlers), + .handlers = bt_6lowpan_handlers, +}; +static int __init bt_6lowpan_init (void ) { +int err; + lowpan_enable_debugfs =debugfs_create_file ("6lowpan_enable" ,0644 , bt_debugfs,NULL , &lowpan_enable_fops);
@@ -1442,11 +1455,17 @@ static int __init bt_6lowpan_init(void) bt_debugfs,NULL , &lowpan_control_fops); -return register_netdevice_notifier (&bt_6lowpan_dev_notifier); + err =register_netdevice_notifier (&bt_6lowpan_dev_notifier); +if (err) +return err; + +return hci_mgmt_chan_register (&bt_6lowpan_chan); } static void __exit bt_6lowpan_exit(void) { +hci_mgmt_chan_unregister (&bt_6lowpan_chan); +debugfs_remove (lowpan_enable_debugfs);debugfs_remove (lowpan_control_debugfs);
Signature · 1 line
2.1.0
PATCH 2/2 Bluetooth: Add proper cleanup path for bt_6lowpan_init()
From: Johan Hedberg <[email protected]>
In case part of the bt_6lowpan_init() fails we should undo any operations that succeeded before the failure. This patch add the necessary cleanup path to the function.
--- net/bluetooth/6lowpan.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
net/bluetooth/6lowpan.c +13 -2
@@ -1457,9 +1457,20 @@ static int __init bt_6lowpan_init(void) err =register_netdevice_notifier (&bt_6lowpan_dev_notifier);if (err) -return err; + goto failed; -return hci_mgmt_chan_register (&bt_6lowpan_chan); + err =hci_mgmt_chan_register (&bt_6lowpan_chan); +if (err) { +unregister_netdevice_notifier (&bt_6lowpan_dev_notifier); + goto failed; + } + +return 0 ; + +failed: +debugfs_remove (lowpan_enable_debugfs); +debugfs_remove (lowpan_control_debugfs); +return err; } static void __exit bt_6lowpan_exit(void)
Signature · 1 line
2.1.0
Hi Johan,
Quoted 6 lines · Johan Hedberg
From: Johan Hedberg <[email protected]>
This patch defines a new HCI channel for 6LoWPAN usage and registers a command handler table for it in the 6lowpan module.
Signed-off-by Johan Hedberg <[email protected]>
Looks good to me.
Quoted 59 lines
--- include/net/bluetooth/hci_sock.h | 1 + net/bluetooth/6lowpan.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)include/net/bluetooth/hci_sock.h +1
-0@@ -45,6 +45,7 @@ struct sockaddr_hci {#define HCI_CHANNEL_USER 1#define HCI_CHANNEL_MONITOR 2#define HCI_CHANNEL_CONTROL 3 +#define HCI_CHANNEL_6LOWPAN 4struct hci_filter {unsigned long type_mask;net/bluetooth/6lowpan.c +17
-1@@ -25,6 +25,7 @@#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> +#include <net/bluetooth/hci_sock.h> #include <net/bluetooth/l2cap.h> #include <net/6lowpan.h> /* for the compression support */ @@ -1433,8 +1434,20 @@ static struct notifier_block bt_6lowpan_dev_notifier = { .notifier_call = device_event, }; +static const struct hci_mgmt_handler bt_6lowpan_handlers[] = { + {NULL },/* 0x0000 (no command) */ +}; + +static struct hci_mgmt_chan bt_6lowpan_chan = { + .channel =HCI_CHANNEL_6LOWPAN , + .handler_count =ARRAY_SIZE (bt_6lowpan_handlers), + .handlers = bt_6lowpan_handlers, +}; +static int __init bt_6lowpan_init (void ) { +int err; + lowpan_enable_debugfs =debugfs_create_file ("6lowpan_enable" ,0644 , bt_debugfs,NULL , &lowpan_enable_fops);@@ -1442,11 +1455,17 @@ static int __init bt_6lowpan_init(void) bt_debugfs,NULL , &lowpan_control_fops); -return register_netdevice_notifier (&bt_6lowpan_dev_notifier); + err =register_netdevice_notifier (&bt_6lowpan_dev_notifier); +if (err) +return err; +
net/bluetooth/6lowpan.c static int __init bt_6lowpan_init(void) · line 1471
Quoted 10 lines
net/bluetooth/6lowpan.c +3
-0+return hci_mgmt_chan_register (&bt_6lowpan_chan); } static void __exit bt_6lowpan_exit(void) { +hci_mgmt_chan_unregister (&bt_6lowpan_chan); +debugfs_remove (lowpan_enable_debugfs);debugfs_remove (lowpan_control_debugfs);
Cheers,
Jukka