Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions net/bluetooth/hci_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,11 @@ static void hci_conn_cleanup(struct hci_conn *conn)
hdev->notify(hdev, HCI_NOTIFY_CONN_DEL);
}

hci_conn_del_sysfs(conn);

debugfs_remove_recursive(conn->debugfs);

hci_dev_put(hdev);
hci_conn_del_sysfs(conn);

hci_conn_put(conn);
hci_dev_put(hdev);
}

static void le_scan_cleanup(struct work_struct *work)
Expand Down
23 changes: 12 additions & 11 deletions net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void hci_conn_init_sysfs(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;

BT_DBG("conn %p", conn);
bt_dev_dbg(hdev, "conn %p", conn);

conn->dev.type = &bt_link;
conn->dev.class = bt_class;
Expand All @@ -46,24 +46,27 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;

BT_DBG("conn %p", conn);
bt_dev_dbg(hdev, "conn %p", conn);

dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);

if (device_add(&conn->dev) < 0) {
if (device_add(&conn->dev) < 0)
bt_dev_err(hdev, "failed to register connection device");
return;
}

hci_dev_hold(hdev);
}

void hci_conn_del_sysfs(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;

if (!device_is_registered(&conn->dev))
bt_dev_dbg(hdev, "conn %p", conn);

if (!device_is_registered(&conn->dev)) {
/* If device_add() has *not* succeeded, use *only* put_device()
* to drop the reference count.
*/
put_device(&conn->dev);
return;
}

while (1) {
struct device *dev;
Expand All @@ -75,9 +78,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn)
put_device(dev);
}

device_del(&conn->dev);

hci_dev_put(hdev);
device_unregister(&conn->dev);
}

static void bt_host_release(struct device *dev)
Expand Down