* [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work
@ 2013-10-16 15:11 johan.hedberg
2013-10-16 15:11 ` [PATCH 2/2] Bluetooth: Convert idle " johan.hedberg
2013-10-16 16:13 ` [PATCH 1/2] Bluetooth: Convert auto accept " Marcel Holtmann
0 siblings, 2 replies; 4+ messages in thread
From: johan.hedberg @ 2013-10-16 15:11 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
Since the entire Bluetooth subsystem runs in workqueues these days there
is no need to use a timer for deferring work.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 2 +-
net/bluetooth/hci_conn.c | 14 ++++++--------
net/bluetooth/hci_event.c | 3 ++-
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d987c79..2504a25 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -341,8 +341,8 @@ struct hci_conn {
struct list_head chan_list;
struct delayed_work disc_work;
+ struct delayed_work auto_accept_work;
struct timer_list idle_timer;
- struct timer_list auto_accept_timer;
struct device dev;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index ff04b05..8d1f466 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -361,12 +361,12 @@ static void hci_conn_idle(unsigned long arg)
hci_conn_enter_sniff_mode(conn);
}
-static void hci_conn_auto_accept(unsigned long arg)
+static void hci_conn_auto_accept(struct work_struct *work)
{
- struct hci_conn *conn = (void *) arg;
- struct hci_dev *hdev = conn->hdev;
+ struct hci_conn *conn = container_of(work, struct hci_conn,
+ auto_accept_work.work);
- hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
+ hci_send_cmd(conn->hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
&conn->dst);
}
@@ -415,9 +415,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
INIT_LIST_HEAD(&conn->chan_list);
INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
+ INIT_DELAYED_WORK(&conn->auto_accept_work, hci_conn_auto_accept);
setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
- setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept,
- (unsigned long) conn);
atomic_set(&conn->refcnt, 0);
@@ -441,8 +440,7 @@ int hci_conn_del(struct hci_conn *conn)
del_timer(&conn->idle_timer);
cancel_delayed_work_sync(&conn->disc_work);
-
- del_timer(&conn->auto_accept_timer);
+ cancel_delayed_work_sync(&conn->auto_accept_work);
if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index e71c98f..6c3b193 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3188,7 +3188,8 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev,
if (hdev->auto_accept_delay > 0) {
int delay = msecs_to_jiffies(hdev->auto_accept_delay);
- mod_timer(&conn->auto_accept_timer, jiffies + delay);
+ queue_delayed_work(conn->hdev->workqueue,
+ &conn->auto_accept_work, delay);
goto unlock;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] Bluetooth: Convert idle timer to use delayed work
2013-10-16 15:11 [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work johan.hedberg
@ 2013-10-16 15:11 ` johan.hedberg
2013-10-16 16:13 ` Marcel Holtmann
2013-10-16 16:13 ` [PATCH 1/2] Bluetooth: Convert auto accept " Marcel Holtmann
1 sibling, 1 reply; 4+ messages in thread
From: johan.hedberg @ 2013-10-16 15:11 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
There is no need to use a timer since the entire Bluetooth subsystem
runs using workqueues these days.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 4 ++--
net/bluetooth/hci_conn.c | 22 +++++++---------------
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 2504a25..07c2da4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -342,7 +342,7 @@ struct hci_conn {
struct delayed_work disc_work;
struct delayed_work auto_accept_work;
- struct timer_list idle_timer;
+ struct delayed_work idle_work;
struct device dev;
@@ -651,7 +651,7 @@ static inline void hci_conn_drop(struct hci_conn *conn)
switch (conn->type) {
case ACL_LINK:
case LE_LINK:
- del_timer(&conn->idle_timer);
+ cancel_delayed_work(&conn->idle_work);
if (conn->state == BT_CONNECTED) {
timeo = conn->disc_timeout;
if (!conn->out)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 8d1f466..4e72650 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -317,8 +317,10 @@ static void hci_conn_timeout(struct work_struct *work)
}
/* Enter sniff mode */
-static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
+static void hci_conn_idle(struct work_struct *work)
{
+ struct hci_conn *conn = container_of(work, struct hci_conn,
+ idle_work.work);
struct hci_dev *hdev = conn->hdev;
BT_DBG("hcon %p mode %d", conn, conn->mode);
@@ -352,15 +354,6 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
}
}
-static void hci_conn_idle(unsigned long arg)
-{
- struct hci_conn *conn = (void *) arg;
-
- BT_DBG("hcon %p mode %d", conn, conn->mode);
-
- hci_conn_enter_sniff_mode(conn);
-}
-
static void hci_conn_auto_accept(struct work_struct *work)
{
struct hci_conn *conn = container_of(work, struct hci_conn,
@@ -416,7 +409,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
INIT_DELAYED_WORK(&conn->auto_accept_work, hci_conn_auto_accept);
- setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
+ INIT_DELAYED_WORK(&conn->idle_work, hci_conn_idle);
atomic_set(&conn->refcnt, 0);
@@ -437,10 +430,9 @@ int hci_conn_del(struct hci_conn *conn)
BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
- del_timer(&conn->idle_timer);
-
cancel_delayed_work_sync(&conn->disc_work);
cancel_delayed_work_sync(&conn->auto_accept_work);
+ cancel_delayed_work_sync(&conn->idle_work);
if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
@@ -920,8 +912,8 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
timer:
if (hdev->idle_timeout > 0)
- mod_timer(&conn->idle_timer,
- jiffies + msecs_to_jiffies(hdev->idle_timeout));
+ queue_delayed_work(hdev->workqueue, &conn->idle_work,
+ msecs_to_jiffies(hdev->idle_timeout));
}
/* Drop all connection on the device */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work
2013-10-16 15:11 [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work johan.hedberg
2013-10-16 15:11 ` [PATCH 2/2] Bluetooth: Convert idle " johan.hedberg
@ 2013-10-16 16:13 ` Marcel Holtmann
1 sibling, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2013-10-16 16:13 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
Hi Johan,
> Since the entire Bluetooth subsystem runs in workqueues these days there
> is no need to use a timer for deferring work.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 2 +-
> net/bluetooth/hci_conn.c | 14 ++++++--------
> net/bluetooth/hci_event.c | 3 ++-
> 3 files changed, 9 insertions(+), 10 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-16 16:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-16 15:11 [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work johan.hedberg
2013-10-16 15:11 ` [PATCH 2/2] Bluetooth: Convert idle " johan.hedberg
2013-10-16 16:13 ` Marcel Holtmann
2013-10-16 16:13 ` [PATCH 1/2] Bluetooth: Convert auto accept " Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox