aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-17 20:24:17 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-18 03:45:45 -0400
commit0153e2ecab657be17aaecca234b29c1154a98202 (patch)
tree40b5ea1fabd7ff59a7708060f54cbc8179cf0136
parent1120e4bfa5f9c28cb55d815ab3c6bed81dfc595c (diff)
Bluetooth: Create HCI device debugfs directory in hci_register_dev
Create the debugfs directory for each HCI device directly in hci_register_dev function and remove it during hci_unregister_dev. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--net/bluetooth/hci_core.c5
-rw-r--r--net/bluetooth/hci_sysfs.c16
2 files changed, 6 insertions, 15 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0fb9f6d1f60f..f7ba81885b42 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2479,6 +2479,9 @@ int hci_register_dev(struct hci_dev *hdev)
2479 goto err; 2479 goto err;
2480 } 2480 }
2481 2481
2482 if (!IS_ERR_OR_NULL(bt_debugfs))
2483 hdev->debugfs = debugfs_create_dir(hdev->name, bt_debugfs);
2484
2482 error = hci_add_sysfs(hdev); 2485 error = hci_add_sysfs(hdev);
2483 if (error < 0) 2486 if (error < 0)
2484 goto err_wqueue; 2487 goto err_wqueue;
@@ -2569,6 +2572,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
2569 2572
2570 hci_del_sysfs(hdev); 2573 hci_del_sysfs(hdev);
2571 2574
2575 debugfs_remove_recursive(hdev->debugfs);
2576
2572 destroy_workqueue(hdev->workqueue); 2577 destroy_workqueue(hdev->workqueue);
2573 destroy_workqueue(hdev->req_workqueue); 2578 destroy_workqueue(hdev->req_workqueue);
2574 2579
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 077037e7f912..0e71318b0c82 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -409,32 +409,18 @@ void hci_init_sysfs(struct hci_dev *hdev)
409int hci_add_sysfs(struct hci_dev *hdev) 409int hci_add_sysfs(struct hci_dev *hdev)
410{ 410{
411 struct device *dev = &hdev->dev; 411 struct device *dev = &hdev->dev;
412 int err;
413 412
414 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); 413 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
415 414
416 dev_set_name(dev, "%s", hdev->name); 415 dev_set_name(dev, "%s", hdev->name);
417 416
418 err = device_add(dev); 417 return device_add(dev);
419 if (err < 0)
420 return err;
421
422 if (!bt_debugfs)
423 return 0;
424
425 hdev->debugfs = debugfs_create_dir(hdev->name, bt_debugfs);
426 if (!hdev->debugfs)
427 return 0;
428
429 return 0;
430} 418}
431 419
432void hci_del_sysfs(struct hci_dev *hdev) 420void hci_del_sysfs(struct hci_dev *hdev)
433{ 421{
434 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); 422 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
435 423
436 debugfs_remove_recursive(hdev->debugfs);
437
438 device_del(&hdev->dev); 424 device_del(&hdev->dev);
439} 425}
440 426