* [PATCH] Bluetooth: Use kref for l2cap channel reference counting
@ 2012-07-27 18:21 Syam Sidhardhan
2012-07-27 18:21 ` [PATCH] Bluetooth: debug: Correct the PSM printing Syam Sidhardhan
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Syam Sidhardhan @ 2012-07-27 18:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: jaganath.k, Syam Sidhardhan
This patch changes the struct l2cap_chan and associated code to use
kref api for object refcounting and freeing.
Suggested-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
include/net/bluetooth/l2cap.h | 3 +--
net/bluetooth/l2cap_core.c | 15 ++++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index d206296..7ed8e35 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -433,11 +433,10 @@ struct l2cap_chan {
struct sock *sk;
struct l2cap_conn *conn;
+ struct kref kref;
__u8 state;
- atomic_t refcnt;
-
__le16 psm;
__u16 dcid;
__u16 scid;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6dde7c5..bedc960 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -406,7 +406,7 @@ struct l2cap_chan *l2cap_chan_create(void)
chan->state = BT_OPEN;
- atomic_set(&chan->refcnt, 1);
+ kref_init(&chan->kref);
/* This flag is cleared in l2cap_chan_ready() */
set_bit(CONF_NOT_COMPLETE, &chan->conf_state);
@@ -416,8 +416,10 @@ struct l2cap_chan *l2cap_chan_create(void)
return chan;
}
-static void l2cap_chan_destroy(struct l2cap_chan *chan)
+static void l2cap_chan_destroy(struct kref *kref)
{
+ struct l2cap_chan *chan = container_of(kref, struct l2cap_chan, kref);
+
BT_DBG("chan %p", chan);
write_lock(&chan_list_lock);
@@ -429,17 +431,16 @@ static void l2cap_chan_destroy(struct l2cap_chan *chan)
void l2cap_chan_hold(struct l2cap_chan *c)
{
- BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
+ BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));
- atomic_inc(&c->refcnt);
+ kref_get(&c->kref);
}
void l2cap_chan_put(struct l2cap_chan *c)
{
- BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
+ BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));
- if (atomic_dec_and_test(&c->refcnt))
- l2cap_chan_destroy(c);
+ kref_put(&c->kref, l2cap_chan_destroy);
}
void l2cap_chan_set_defaults(struct l2cap_chan *chan)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Bluetooth: debug: Correct the PSM printing
2012-07-27 18:21 [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
@ 2012-07-27 18:21 ` Syam Sidhardhan
2012-08-06 9:46 ` Andrei Emeltchenko
2012-08-21 17:29 ` Gustavo Padovan
2012-08-13 14:35 ` [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
2012-08-21 17:34 ` Gustavo Padovan
2 siblings, 2 replies; 7+ messages in thread
From: Syam Sidhardhan @ 2012-07-27 18:21 UTC (permalink / raw)
To: linux-bluetooth; +Cc: jaganath.k, Syam Sidhardhan
Earlier we were printing chan->psm before assigning any value.
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
net/bluetooth/l2cap_core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index bedc960..0912a63 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1447,7 +1447,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
int err;
BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
- dst_type, __le16_to_cpu(chan->psm));
+ dst_type, __le16_to_cpu(psm));
hdev = hci_get_route(dst, src);
if (!hdev)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Bluetooth: debug: Correct the PSM printing
2012-07-27 18:21 ` [PATCH] Bluetooth: debug: Correct the PSM printing Syam Sidhardhan
@ 2012-08-06 9:46 ` Andrei Emeltchenko
2012-08-13 14:37 ` Syam Sidhardhan
2012-08-21 17:29 ` Gustavo Padovan
1 sibling, 1 reply; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-08-06 9:46 UTC (permalink / raw)
To: Syam Sidhardhan; +Cc: linux-bluetooth, jaganath.k
Hi Syam,
On Fri, Jul 27, 2012 at 11:51:22PM +0530, Syam Sidhardhan wrote:
> Earlier we were printing chan->psm before assigning any value.
>
> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index bedc960..0912a63 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -1447,7 +1447,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
> int err;
>
> BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
> - dst_type, __le16_to_cpu(chan->psm));
> + dst_type, __le16_to_cpu(psm));
>
> hdev = hci_get_route(dst, src);
> if (!hdev)
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Bluetooth: Use kref for l2cap channel reference counting
2012-07-27 18:21 [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
2012-07-27 18:21 ` [PATCH] Bluetooth: debug: Correct the PSM printing Syam Sidhardhan
@ 2012-08-13 14:35 ` Syam Sidhardhan
2012-08-21 17:34 ` Gustavo Padovan
2 siblings, 0 replies; 7+ messages in thread
From: Syam Sidhardhan @ 2012-08-13 14:35 UTC (permalink / raw)
To: Syam Sidhardhan, linux-bluetooth; +Cc: jaganath.k
Hi,
----- Original Message -----
From: "Syam Sidhardhan" <s.syam@samsung.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: <jaganath.k@samsung.com>; "Syam Sidhardhan" <s.syam@samsung.com>
Sent: Friday, July 27, 2012 11:51 PM
Subject: [PATCH] Bluetooth: Use kref for l2cap channel reference counting
> This patch changes the struct l2cap_chan and associated code to use
> kref api for object refcounting and freeing.
>
> Suggested-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
> ---
> include/net/bluetooth/l2cap.h | 3 +--
> net/bluetooth/l2cap_core.c | 15 ++++++++-------
> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index d206296..7ed8e35 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -433,11 +433,10 @@ struct l2cap_chan {
> struct sock *sk;
>
> struct l2cap_conn *conn;
> + struct kref kref;
>
> __u8 state;
>
> - atomic_t refcnt;
> -
> __le16 psm;
> __u16 dcid;
> __u16 scid;
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 6dde7c5..bedc960 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -406,7 +406,7 @@ struct l2cap_chan *l2cap_chan_create(void)
>
> chan->state = BT_OPEN;
>
> - atomic_set(&chan->refcnt, 1);
> + kref_init(&chan->kref);
>
> /* This flag is cleared in l2cap_chan_ready() */
> set_bit(CONF_NOT_COMPLETE, &chan->conf_state);
> @@ -416,8 +416,10 @@ struct l2cap_chan *l2cap_chan_create(void)
> return chan;
> }
>
> -static void l2cap_chan_destroy(struct l2cap_chan *chan)
> +static void l2cap_chan_destroy(struct kref *kref)
> {
> + struct l2cap_chan *chan = container_of(kref, struct l2cap_chan, kref);
> +
> BT_DBG("chan %p", chan);
>
> write_lock(&chan_list_lock);
> @@ -429,17 +431,16 @@ static void l2cap_chan_destroy(struct l2cap_chan
> *chan)
>
> void l2cap_chan_hold(struct l2cap_chan *c)
> {
> - BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
> + BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));
>
> - atomic_inc(&c->refcnt);
> + kref_get(&c->kref);
> }
>
> void l2cap_chan_put(struct l2cap_chan *c)
> {
> - BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
> + BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->kref.refcount));
>
> - if (atomic_dec_and_test(&c->refcnt))
> - l2cap_chan_destroy(c);
> + kref_put(&c->kref, l2cap_chan_destroy);
> }
>
> void l2cap_chan_set_defaults(struct l2cap_chan *chan)
> --
ping
Regards,
Syam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Bluetooth: debug: Correct the PSM printing
2012-08-06 9:46 ` Andrei Emeltchenko
@ 2012-08-13 14:37 ` Syam Sidhardhan
0 siblings, 0 replies; 7+ messages in thread
From: Syam Sidhardhan @ 2012-08-13 14:37 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth, jaganath.k
Hi,
----- Original Message -----
From: "Andrei Emeltchenko" <andrei.emeltchenko.news@gmail.com>
To: "Syam Sidhardhan" <s.syam@samsung.com>
Cc: <linux-bluetooth@vger.kernel.org>; <jaganath.k@samsung.com>
Sent: Monday, August 06, 2012 3:16 PM
Subject: Re: [PATCH] Bluetooth: debug: Correct the PSM printing
> Hi Syam,
>
> On Fri, Jul 27, 2012 at 11:51:22PM +0530, Syam Sidhardhan wrote:
>> Earlier we were printing chan->psm before assigning any value.
>>
>> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
>
> Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
>> ---
>> net/bluetooth/l2cap_core.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
>> index bedc960..0912a63 100644
>> --- a/net/bluetooth/l2cap_core.c
>> +++ b/net/bluetooth/l2cap_core.c
>> @@ -1447,7 +1447,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan,
>> __le16 psm, u16 cid,
>> int err;
>>
>> BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
>> - dst_type, __le16_to_cpu(chan->psm));
>> + dst_type, __le16_to_cpu(psm));
>>
>> hdev = hci_get_route(dst, src);
>> if (!hdev)
>> --
>> 1.7.4.1
>>
ping..
Regards,
Syam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Bluetooth: debug: Correct the PSM printing
2012-07-27 18:21 ` [PATCH] Bluetooth: debug: Correct the PSM printing Syam Sidhardhan
2012-08-06 9:46 ` Andrei Emeltchenko
@ 2012-08-21 17:29 ` Gustavo Padovan
1 sibling, 0 replies; 7+ messages in thread
From: Gustavo Padovan @ 2012-08-21 17:29 UTC (permalink / raw)
To: Syam Sidhardhan; +Cc: linux-bluetooth, jaganath.k
Hi Syam,
* Syam Sidhardhan <s.syam@samsung.com> [2012-07-27 23:51:22 +0530]:
> Earlier we were printing chan->psm before assigning any value.
>
> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
> ---
> net/bluetooth/l2cap_core.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Patch has been applied to bluetooth-next. Thanks.
Gustavo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Bluetooth: Use kref for l2cap channel reference counting
2012-07-27 18:21 [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
2012-07-27 18:21 ` [PATCH] Bluetooth: debug: Correct the PSM printing Syam Sidhardhan
2012-08-13 14:35 ` [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
@ 2012-08-21 17:34 ` Gustavo Padovan
2 siblings, 0 replies; 7+ messages in thread
From: Gustavo Padovan @ 2012-08-21 17:34 UTC (permalink / raw)
To: Syam Sidhardhan; +Cc: linux-bluetooth, jaganath.k
Hi Syam,
* Syam Sidhardhan <s.syam@samsung.com> [2012-07-27 23:51:21 +0530]:
> This patch changes the struct l2cap_chan and associated code to use
> kref api for object refcounting and freeing.
>
> Suggested-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
> ---
> include/net/bluetooth/l2cap.h | 3 +--
> net/bluetooth/l2cap_core.c | 15 ++++++++-------
> 2 files changed, 9 insertions(+), 9 deletions(-)
Patch has been applied to linux-bluetooth. Thanks.
Gustavo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-08-21 17:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-27 18:21 [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
2012-07-27 18:21 ` [PATCH] Bluetooth: debug: Correct the PSM printing Syam Sidhardhan
2012-08-06 9:46 ` Andrei Emeltchenko
2012-08-13 14:37 ` Syam Sidhardhan
2012-08-21 17:29 ` Gustavo Padovan
2012-08-13 14:35 ` [PATCH] Bluetooth: Use kref for l2cap channel reference counting Syam Sidhardhan
2012-08-21 17:34 ` Gustavo Padovan
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).