Skip to content

Commit

Permalink
Bluetooth: Remove work_add and work_del from hci_sysfs
Browse files Browse the repository at this point in the history
As we run in process context now we don't need worqueue to add e del from
sysfs.

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Gustavo F. Padovan committed Dec 18, 2011
1 parent 32845eb commit 6d438e3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 47 deletions.
3 changes: 0 additions & 3 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ struct hci_conn {
struct timer_list idle_timer;
struct timer_list auto_accept_timer;

struct work_struct work_add;
struct work_struct work_del;

struct device dev;
atomic_t devref;

Expand Down
71 changes: 27 additions & 44 deletions net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,35 @@ static struct device_type bt_link = {
.release = bt_link_release,
};

static void add_conn(struct work_struct *work)
/*
* The rfcomm tty device will possibly retain even when conn
* is down, and sysfs doesn't support move zombie device,
* so we should move the device before conn device is destroyed.
*/
static int __match_tty(struct device *dev, void *data)
{
return !strncmp(dev_name(dev), "rfcomm", 6);
}

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

BT_DBG("conn %p", conn);

conn->dev.type = &bt_link;
conn->dev.class = bt_class;
conn->dev.parent = &hdev->dev;

device_initialize(&conn->dev);
}

void hci_conn_add_sysfs(struct hci_conn *conn)
{
struct hci_conn *conn = container_of(work, struct hci_conn, work_add);
struct hci_dev *hdev = conn->hdev;

BT_DBG("conn %p", conn);

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

dev_set_drvdata(&conn->dev, conn);
Expand All @@ -105,19 +129,8 @@ static void add_conn(struct work_struct *work)
hci_dev_hold(hdev);
}

/*
* The rfcomm tty device will possibly retain even when conn
* is down, and sysfs doesn't support move zombie device,
* so we should move the device before conn device is destroyed.
*/
static int __match_tty(struct device *dev, void *data)
{
return !strncmp(dev_name(dev), "rfcomm", 6);
}

static void del_conn(struct work_struct *work)
void hci_conn_del_sysfs(struct hci_conn *conn)
{
struct hci_conn *conn = container_of(work, struct hci_conn, work_del);
struct hci_dev *hdev = conn->hdev;

if (!device_is_registered(&conn->dev))
Expand All @@ -139,36 +152,6 @@ static void del_conn(struct work_struct *work)
hci_dev_put(hdev);
}

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

BT_DBG("conn %p", conn);

conn->dev.type = &bt_link;
conn->dev.class = bt_class;
conn->dev.parent = &hdev->dev;

device_initialize(&conn->dev);

INIT_WORK(&conn->work_add, add_conn);
INIT_WORK(&conn->work_del, del_conn);
}

void hci_conn_add_sysfs(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);

queue_work(conn->hdev->workqueue, &conn->work_add);
}

void hci_conn_del_sysfs(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);

queue_work(conn->hdev->workqueue, &conn->work_del);
}

static inline char *host_bustostr(int bus)
{
switch (bus) {
Expand Down

0 comments on commit 6d438e3

Please sign in to comment.