Re: [PATCH 01/14] Bluetooth: use list_for_each_entry*

2015-12-19 Thread Marcel Holtmann
Hi Geliang,

> Use list_for_each_entry*() instead of list_for_each*() to simplify
> the code.
> 
> Signed-off-by: Geliang Tang 
> ---
> net/bluetooth/af_bluetooth.c | 12 ++--
> net/bluetooth/cmtp/capi.c|  8 ++--
> net/bluetooth/hci_core.c |  8 +++-
> net/bluetooth/rfcomm/core.c  | 46 ++--
> 4 files changed, 25 insertions(+), 49 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/14] Bluetooth: use list_for_each_entry*

2015-12-19 Thread Marcel Holtmann
Hi Geliang,

> Use list_for_each_entry*() instead of list_for_each*() to simplify
> the code.
> 
> Signed-off-by: Geliang Tang 
> ---
> net/bluetooth/af_bluetooth.c | 12 ++--
> net/bluetooth/cmtp/capi.c|  8 ++--
> net/bluetooth/hci_core.c |  8 +++-
> net/bluetooth/rfcomm/core.c  | 46 ++--
> 4 files changed, 25 insertions(+), 49 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/14] Bluetooth: use list_for_each_entry*

2015-12-18 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang 
---
 net/bluetooth/af_bluetooth.c | 12 ++--
 net/bluetooth/cmtp/capi.c|  8 ++--
 net/bluetooth/hci_core.c |  8 +++-
 net/bluetooth/rfcomm/core.c  | 46 ++--
 4 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index cb4e8d4..955eda9 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -174,13 +174,13 @@ EXPORT_SYMBOL(bt_accept_unlink);
 
 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
 {
-   struct list_head *p, *n;
+   struct bt_sock *s, *n;
struct sock *sk;
 
BT_DBG("parent %p", parent);
 
-   list_for_each_safe(p, n, _sk(parent)->accept_q) {
-   sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
+   list_for_each_entry_safe(s, n, _sk(parent)->accept_q, accept_q) {
+   sk = (struct sock *)s;
 
lock_sock(sk);
 
@@ -388,11 +388,11 @@ EXPORT_SYMBOL(bt_sock_stream_recvmsg);
 
 static inline unsigned int bt_accept_poll(struct sock *parent)
 {
-   struct list_head *p, *n;
+   struct bt_sock *s, *n;
struct sock *sk;
 
-   list_for_each_safe(p, n, _sk(parent)->accept_q) {
-   sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
+   list_for_each_entry_safe(s, n, _sk(parent)->accept_q, accept_q) {
+   sk = (struct sock *)s;
if (sk->sk_state == BT_CONNECTED ||
(test_bit(BT_SK_DEFER_SETUP, _sk(parent)->flags) &&
 sk->sk_state == BT_CONNECT2))
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 9a503387..46ac686 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -100,10 +100,8 @@ static void cmtp_application_del(struct cmtp_session 
*session, struct cmtp_appli
 static struct cmtp_application *cmtp_application_get(struct cmtp_session 
*session, int pattern, __u16 value)
 {
struct cmtp_application *app;
-   struct list_head *p;
 
-   list_for_each(p, >applications) {
-   app = list_entry(p, struct cmtp_application, list);
+   list_for_each_entry(app, >applications, list) {
switch (pattern) {
case CMTP_MSGNUM:
if (app->msgnum == value)
@@ -511,14 +509,12 @@ static int cmtp_proc_show(struct seq_file *m, void *v)
struct capi_ctr *ctrl = m->private;
struct cmtp_session *session = ctrl->driverdata;
struct cmtp_application *app;
-   struct list_head *p;
 
seq_printf(m, "%s\n\n", cmtp_procinfo(ctrl));
seq_printf(m, "addr %s\n", session->name);
seq_printf(m, "ctrl %d\n", session->num);
 
-   list_for_each(p, >applications) {
-   app = list_entry(p, struct cmtp_application, list);
+   list_for_each_entry(app, >applications, list) {
seq_printf(m, "appl %d -> %d\n", app->appl, app->mapping);
}
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9fb443a..47bcef7 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2713,12 +2713,10 @@ struct bdaddr_list *hci_bdaddr_list_lookup(struct 
list_head *bdaddr_list,
 
 void hci_bdaddr_list_clear(struct list_head *bdaddr_list)
 {
-   struct list_head *p, *n;
+   struct bdaddr_list *b, *n;
 
-   list_for_each_safe(p, n, bdaddr_list) {
-   struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list);
-
-   list_del(p);
+   list_for_each_entry_safe(b, n, bdaddr_list, list) {
+   list_del(>list);
kfree(b);
}
 }
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 29709fb..f7eb02f 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -692,11 +692,9 @@ static struct rfcomm_session *rfcomm_session_del(struct 
rfcomm_session *s)
 
 static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
 {
-   struct rfcomm_session *s;
-   struct list_head *p, *n;
+   struct rfcomm_session *s, *n;
struct l2cap_chan *chan;
-   list_for_each_safe(p, n, _list) {
-   s = list_entry(p, struct rfcomm_session, list);
+   list_for_each_entry_safe(s, n, _list, list) {
chan = l2cap_pi(s->sock->sk)->chan;
 
if ((!bacmp(src, BDADDR_ANY) || !bacmp(>src, src)) &&
@@ -709,16 +707,14 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t 
*src, bdaddr_t *dst)
 static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s,
   int err)
 {
-   struct rfcomm_dlc *d;
-   struct list_head *p, *n;
+   struct rfcomm_dlc *d, *n;
 
s->state = BT_CLOSED;
 
BT_DBG("session %p 

[PATCH 01/14] Bluetooth: use list_for_each_entry*

2015-12-18 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang 
---
 net/bluetooth/af_bluetooth.c | 12 ++--
 net/bluetooth/cmtp/capi.c|  8 ++--
 net/bluetooth/hci_core.c |  8 +++-
 net/bluetooth/rfcomm/core.c  | 46 ++--
 4 files changed, 25 insertions(+), 49 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index cb4e8d4..955eda9 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -174,13 +174,13 @@ EXPORT_SYMBOL(bt_accept_unlink);
 
 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
 {
-   struct list_head *p, *n;
+   struct bt_sock *s, *n;
struct sock *sk;
 
BT_DBG("parent %p", parent);
 
-   list_for_each_safe(p, n, _sk(parent)->accept_q) {
-   sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
+   list_for_each_entry_safe(s, n, _sk(parent)->accept_q, accept_q) {
+   sk = (struct sock *)s;
 
lock_sock(sk);
 
@@ -388,11 +388,11 @@ EXPORT_SYMBOL(bt_sock_stream_recvmsg);
 
 static inline unsigned int bt_accept_poll(struct sock *parent)
 {
-   struct list_head *p, *n;
+   struct bt_sock *s, *n;
struct sock *sk;
 
-   list_for_each_safe(p, n, _sk(parent)->accept_q) {
-   sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
+   list_for_each_entry_safe(s, n, _sk(parent)->accept_q, accept_q) {
+   sk = (struct sock *)s;
if (sk->sk_state == BT_CONNECTED ||
(test_bit(BT_SK_DEFER_SETUP, _sk(parent)->flags) &&
 sk->sk_state == BT_CONNECT2))
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 9a503387..46ac686 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -100,10 +100,8 @@ static void cmtp_application_del(struct cmtp_session 
*session, struct cmtp_appli
 static struct cmtp_application *cmtp_application_get(struct cmtp_session 
*session, int pattern, __u16 value)
 {
struct cmtp_application *app;
-   struct list_head *p;
 
-   list_for_each(p, >applications) {
-   app = list_entry(p, struct cmtp_application, list);
+   list_for_each_entry(app, >applications, list) {
switch (pattern) {
case CMTP_MSGNUM:
if (app->msgnum == value)
@@ -511,14 +509,12 @@ static int cmtp_proc_show(struct seq_file *m, void *v)
struct capi_ctr *ctrl = m->private;
struct cmtp_session *session = ctrl->driverdata;
struct cmtp_application *app;
-   struct list_head *p;
 
seq_printf(m, "%s\n\n", cmtp_procinfo(ctrl));
seq_printf(m, "addr %s\n", session->name);
seq_printf(m, "ctrl %d\n", session->num);
 
-   list_for_each(p, >applications) {
-   app = list_entry(p, struct cmtp_application, list);
+   list_for_each_entry(app, >applications, list) {
seq_printf(m, "appl %d -> %d\n", app->appl, app->mapping);
}
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9fb443a..47bcef7 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2713,12 +2713,10 @@ struct bdaddr_list *hci_bdaddr_list_lookup(struct 
list_head *bdaddr_list,
 
 void hci_bdaddr_list_clear(struct list_head *bdaddr_list)
 {
-   struct list_head *p, *n;
+   struct bdaddr_list *b, *n;
 
-   list_for_each_safe(p, n, bdaddr_list) {
-   struct bdaddr_list *b = list_entry(p, struct bdaddr_list, list);
-
-   list_del(p);
+   list_for_each_entry_safe(b, n, bdaddr_list, list) {
+   list_del(>list);
kfree(b);
}
 }
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 29709fb..f7eb02f 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -692,11 +692,9 @@ static struct rfcomm_session *rfcomm_session_del(struct 
rfcomm_session *s)
 
 static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
 {
-   struct rfcomm_session *s;
-   struct list_head *p, *n;
+   struct rfcomm_session *s, *n;
struct l2cap_chan *chan;
-   list_for_each_safe(p, n, _list) {
-   s = list_entry(p, struct rfcomm_session, list);
+   list_for_each_entry_safe(s, n, _list, list) {
chan = l2cap_pi(s->sock->sk)->chan;
 
if ((!bacmp(src, BDADDR_ANY) || !bacmp(>src, src)) &&
@@ -709,16 +707,14 @@ static struct rfcomm_session *rfcomm_session_get(bdaddr_t 
*src, bdaddr_t *dst)
 static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s,
   int err)
 {
-   struct rfcomm_dlc *d;
-   struct list_head *p, *n;
+   struct rfcomm_dlc *d, *n;
 
s->state = BT_CLOSED;