* [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h
@ 2011-12-20 12:57 Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Gustavo F. Padovan
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2011-12-20 12:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
It is the only place where it is used.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/l2cap.h | 15 +++++++++++++++
net/bluetooth/l2cap_core.c | 14 --------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index c0d168a..e199c2f 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -595,6 +595,21 @@ enum {
FLAG_EFS_ENABLE,
};
+static inline void l2cap_set_timer(struct l2cap_chan *chan,
+ struct delayed_work *work, long timeout)
+{
+ BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout);
+
+ cancel_delayed_work_sync(work);
+
+ schedule_delayed_work(work, timeout);
+}
+
+static inline void l2cap_clear_timer(struct delayed_work *work)
+{
+ cancel_delayed_work_sync(work);
+}
+
#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
#define __clear_chan_timer(c) l2cap_clear_timer(&c->chan_timer)
#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ffa2f6b..5978d69 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -228,20 +228,6 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn)
return 0;
}
-static void l2cap_set_timer(struct l2cap_chan *chan, struct delayed_work *work, long timeout)
-{
- BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout);
-
- cancel_delayed_work_sync(work);
-
- schedule_delayed_work(work, timeout);
-}
-
-static void l2cap_clear_timer(struct delayed_work *work)
-{
- cancel_delayed_work_sync(work);
-}
-
static char *state_to_string(int state)
{
switch(state) {
--
1.7.6.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] Bluetooth: convert security timer to delayed_work
2011-12-20 12:57 [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Gustavo F. Padovan
@ 2011-12-20 12:57 ` Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 3/3] Bluetooth: Rename info_work to info_timer Gustavo F. Padovan
2011-12-20 16:51 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Marcel Holtmann
2011-12-20 13:09 ` [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Anderson Lizardo
2011-12-20 16:50 ` Marcel Holtmann
2 siblings, 2 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2011-12-20 12:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
This one also needs to run in process context
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 12 ++++++------
net/bluetooth/smp.c | 7 ++++---
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index e199c2f..fc481d1 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -532,7 +532,7 @@ struct l2cap_conn {
__u8 disc_reason;
- struct timer_list security_timer;
+ struct delayed_work security_timer;
struct smp_chan *smp_chan;
struct list_head chan_l;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 5978d69..d006455 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1032,7 +1032,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
cancel_delayed_work_sync(&conn->info_work);
if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) {
- del_timer(&conn->security_timer);
+ cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);
}
@@ -1040,9 +1040,10 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
kfree(conn);
}
-static void security_timeout(unsigned long arg)
+static void security_timeout(struct work_struct *work)
{
- struct l2cap_conn *conn = (void *) arg;
+ struct l2cap_conn *conn = container_of(work, struct l2cap_conn,
+ security_timer.work);
l2cap_conn_del(conn->hcon, ETIMEDOUT);
}
@@ -1086,8 +1087,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
INIT_LIST_HEAD(&conn->chan_l);
if (hcon->type == LE_LINK)
- setup_timer(&conn->security_timer, security_timeout,
- (unsigned long) conn);
+ INIT_DELAYED_WORK(&conn->security_timer, security_timeout);
else
INIT_DELAYED_WORK(&conn->info_work, l2cap_info_timeout);
@@ -4519,7 +4519,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
if (hcon->type == LE_LINK) {
smp_distribute_keys(conn, 0);
- del_timer(&conn->security_timer);
+ cancel_delayed_work_sync(&conn->security_timer);
}
rcu_read_lock();
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 0b96737..0ee2905 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -184,7 +184,8 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data)
skb->priority = HCI_PRIO_MAX;
hci_send_acl(conn->hchan, skb, 0);
- mod_timer(&conn->security_timer, jiffies +
+ cancel_delayed_work_sync(&conn->security_timer);
+ schedule_delayed_work(&conn->security_timer,
msecs_to_jiffies(SMP_TIMEOUT));
}
@@ -240,7 +241,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->pend);
mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason);
- del_timer(&conn->security_timer);
+ cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);
}
@@ -800,7 +801,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force)
if (conn->hcon->out || force) {
clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend);
- del_timer(&conn->security_timer);
+ cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);
}
--
1.7.6.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] Bluetooth: Rename info_work to info_timer
2011-12-20 12:57 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Gustavo F. Padovan
@ 2011-12-20 12:57 ` Gustavo F. Padovan
2011-12-20 16:51 ` Marcel Holtmann
2011-12-20 16:51 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Marcel Holtmann
1 sibling, 1 reply; 8+ messages in thread
From: Gustavo F. Padovan @ 2011-12-20 12:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
It makes more sense this way, since info_timer is a timer using delayed
work API.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/l2cap.h | 2 +-
net/bluetooth/l2cap_core.c | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index fc481d1..f141fbe 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -522,7 +522,7 @@ struct l2cap_conn {
__u8 info_state;
__u8 info_ident;
- struct delayed_work info_work;
+ struct delayed_work info_timer;
spinlock_t lock;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d006455..a898285 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -699,7 +699,7 @@ static void l2cap_do_start(struct l2cap_chan *chan)
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_SENT;
conn->info_ident = l2cap_get_ident(conn);
- schedule_delayed_work(&conn->info_work,
+ schedule_delayed_work(&conn->info_timer,
msecs_to_jiffies(L2CAP_INFO_TIMEOUT));
l2cap_send_cmd(conn, conn->info_ident,
@@ -996,7 +996,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
static void l2cap_info_timeout(struct work_struct *work)
{
struct l2cap_conn *conn = container_of(work, struct l2cap_conn,
- info_work.work);
+ info_timer.work);
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
conn->info_ident = 0;
@@ -1029,7 +1029,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
hci_chan_del(conn->hchan);
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)
- cancel_delayed_work_sync(&conn->info_work);
+ cancel_delayed_work_sync(&conn->info_timer);
if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &hcon->pend)) {
cancel_delayed_work_sync(&conn->security_timer);
@@ -1089,7 +1089,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
if (hcon->type == LE_LINK)
INIT_DELAYED_WORK(&conn->security_timer, security_timeout);
else
- INIT_DELAYED_WORK(&conn->info_work, l2cap_info_timeout);
+ INIT_DELAYED_WORK(&conn->info_timer, l2cap_info_timeout);
conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM;
@@ -2583,7 +2583,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd
if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) &&
cmd->ident == conn->info_ident) {
- cancel_delayed_work_sync(&conn->info_work);
+ cancel_delayed_work_sync(&conn->info_timer);
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
conn->info_ident = 0;
@@ -2704,7 +2704,7 @@ sendresp:
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_SENT;
conn->info_ident = l2cap_get_ident(conn);
- schedule_delayed_work(&conn->info_work,
+ schedule_delayed_work(&conn->info_timer,
msecs_to_jiffies(L2CAP_INFO_TIMEOUT));
l2cap_send_cmd(conn, conn->info_ident,
@@ -3129,7 +3129,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)
return 0;
- cancel_delayed_work_sync(&conn->info_work);
+ cancel_delayed_work_sync(&conn->info_timer);
if (result != L2CAP_IR_SUCCESS) {
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h
2011-12-20 12:57 [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Gustavo F. Padovan
@ 2011-12-20 13:09 ` Anderson Lizardo
2011-12-20 19:10 ` Gustavo Padovan
2011-12-20 16:50 ` Marcel Holtmann
2 siblings, 1 reply; 8+ messages in thread
From: Anderson Lizardo @ 2011-12-20 13:09 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
Hi Padovan,
On Tue, Dec 20, 2011 at 8:57 AM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> From: "Gustavo F. Padovan" <padovan@profusion.mobi>
>
> It is the only place where it is used.
I don't understand. If l2cap.h is the only place where it is used, how
it used to work/compile before? I can only imagine that the macros
using l2cap_{set,clear}_timer are in l2cap_core.c , in which case
they should be moved to l2cap_core.c , not the other way around?
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h
2011-12-20 12:57 [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Gustavo F. Padovan
2011-12-20 13:09 ` [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Anderson Lizardo
@ 2011-12-20 16:50 ` Marcel Holtmann
2 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2011-12-20 16:50 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
Hi Gustavo,
it is Move and not Nove ;)
> From: "Gustavo F. Padovan" <padovan@profusion.mobi>
>
> It is the only place where it is used.
>
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> include/net/bluetooth/l2cap.h | 15 +++++++++++++++
> net/bluetooth/l2cap_core.c | 14 --------------
> 2 files changed, 15 insertions(+), 14 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] Bluetooth: convert security timer to delayed_work
2011-12-20 12:57 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 3/3] Bluetooth: Rename info_work to info_timer Gustavo F. Padovan
@ 2011-12-20 16:51 ` Marcel Holtmann
1 sibling, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2011-12-20 16:51 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
Hi Gustavo,
> This one also needs to run in process context
>
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> include/net/bluetooth/l2cap.h | 2 +-
> net/bluetooth/l2cap_core.c | 12 ++++++------
> net/bluetooth/smp.c | 7 ++++---
> 3 files changed, 11 insertions(+), 10 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] Bluetooth: Rename info_work to info_timer
2011-12-20 12:57 ` [PATCH 3/3] Bluetooth: Rename info_work to info_timer Gustavo F. Padovan
@ 2011-12-20 16:51 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2011-12-20 16:51 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
Hi Gustavo,
> It makes more sense this way, since info_timer is a timer using delayed
> work API.
>
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> include/net/bluetooth/l2cap.h | 2 +-
> net/bluetooth/l2cap_core.c | 14 +++++++-------
> 2 files changed, 8 insertions(+), 8 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h
2011-12-20 13:09 ` [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Anderson Lizardo
@ 2011-12-20 19:10 ` Gustavo Padovan
0 siblings, 0 replies; 8+ messages in thread
From: Gustavo Padovan @ 2011-12-20 19:10 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Anderson,
* Anderson Lizardo <anderson.lizardo@openbossa.org> [2011-12-20 09:09:23 -0400]:
> Hi Padovan,
>
> On Tue, Dec 20, 2011 at 8:57 AM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
> > From: "Gustavo F. Padovan" <padovan@profusion.mobi>
> >
> > It is the only place where it is used.
>
> I don't understand. If l2cap.h is the only place where it is used, how
> it used to work/compile before? I can only imagine that the macros
> using l2cap_{set,clear}_timer are in l2cap_core.c , in which case
> they should be moved to l2cap_core.c , not the other way around?
It worked because only macros were using them. Also l2cap.h keeps a lot of
helpers functions to be used only in l2cap_core.c. So to me this seems the
right move.
Gustavo
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-12-20 19:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-20 12:57 [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Gustavo F. Padovan
2011-12-20 12:57 ` [PATCH 3/3] Bluetooth: Rename info_work to info_timer Gustavo F. Padovan
2011-12-20 16:51 ` Marcel Holtmann
2011-12-20 16:51 ` [PATCH 2/3] Bluetooth: convert security timer to delayed_work Marcel Holtmann
2011-12-20 13:09 ` [PATCH 1/3] Bluetooth: Nove l2cap_{set,clear}_timer to l2cap.h Anderson Lizardo
2011-12-20 19:10 ` Gustavo Padovan
2011-12-20 16:50 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).