Bluetooth: replace list_for_each with list_for_each_entry whenever possible
When all items in the list have the same type there is no much of a point to use list_for_each except if you want to use the list pointer itself. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
This commit is contained in:
parent
457f48507d
commit
8035ded466
|
@ -65,15 +65,13 @@ static DECLARE_RWSEM(bnep_session_sem);
|
||||||
static struct bnep_session *__bnep_get_session(u8 *dst)
|
static struct bnep_session *__bnep_get_session(u8 *dst)
|
||||||
{
|
{
|
||||||
struct bnep_session *s;
|
struct bnep_session *s;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
BT_DBG("");
|
BT_DBG("");
|
||||||
|
|
||||||
list_for_each(p, &bnep_session_list) {
|
list_for_each_entry(s, &bnep_session_list, list)
|
||||||
s = list_entry(p, struct bnep_session, list);
|
|
||||||
if (!compare_ether_addr(dst, s->eh.h_source))
|
if (!compare_ether_addr(dst, s->eh.h_source))
|
||||||
return s;
|
return s;
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,17 +665,14 @@ static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s)
|
||||||
|
|
||||||
int bnep_get_connlist(struct bnep_connlist_req *req)
|
int bnep_get_connlist(struct bnep_connlist_req *req)
|
||||||
{
|
{
|
||||||
struct list_head *p;
|
struct bnep_session *s;
|
||||||
int err = 0, n = 0;
|
int err = 0, n = 0;
|
||||||
|
|
||||||
down_read(&bnep_session_sem);
|
down_read(&bnep_session_sem);
|
||||||
|
|
||||||
list_for_each(p, &bnep_session_list) {
|
list_for_each_entry(s, &bnep_session_list, list) {
|
||||||
struct bnep_session *s;
|
|
||||||
struct bnep_conninfo ci;
|
struct bnep_conninfo ci;
|
||||||
|
|
||||||
s = list_entry(p, struct bnep_session, list);
|
|
||||||
|
|
||||||
__bnep_copy_ci(&ci, s);
|
__bnep_copy_ci(&ci, s);
|
||||||
|
|
||||||
if (copy_to_user(req->ci, &ci, sizeof(ci))) {
|
if (copy_to_user(req->ci, &ci, sizeof(ci))) {
|
||||||
|
|
|
@ -53,15 +53,13 @@ static LIST_HEAD(cmtp_session_list);
|
||||||
static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr)
|
static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr)
|
||||||
{
|
{
|
||||||
struct cmtp_session *session;
|
struct cmtp_session *session;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
BT_DBG("");
|
BT_DBG("");
|
||||||
|
|
||||||
list_for_each(p, &cmtp_session_list) {
|
list_for_each_entry(session, &cmtp_session_list, list)
|
||||||
session = list_entry(p, struct cmtp_session, list);
|
|
||||||
if (!bacmp(bdaddr, &session->bdaddr))
|
if (!bacmp(bdaddr, &session->bdaddr))
|
||||||
return session;
|
return session;
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,19 +429,16 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
|
||||||
|
|
||||||
int cmtp_get_connlist(struct cmtp_connlist_req *req)
|
int cmtp_get_connlist(struct cmtp_connlist_req *req)
|
||||||
{
|
{
|
||||||
struct list_head *p;
|
struct cmtp_session *session;
|
||||||
int err = 0, n = 0;
|
int err = 0, n = 0;
|
||||||
|
|
||||||
BT_DBG("");
|
BT_DBG("");
|
||||||
|
|
||||||
down_read(&cmtp_session_sem);
|
down_read(&cmtp_session_sem);
|
||||||
|
|
||||||
list_for_each(p, &cmtp_session_list) {
|
list_for_each_entry(session, &cmtp_session_list, list) {
|
||||||
struct cmtp_session *session;
|
|
||||||
struct cmtp_conninfo ci;
|
struct cmtp_conninfo ci;
|
||||||
|
|
||||||
session = list_entry(p, struct cmtp_session, list);
|
|
||||||
|
|
||||||
__cmtp_copy_session(session, &ci);
|
__cmtp_copy_session(session, &ci);
|
||||||
|
|
||||||
if (copy_to_user(req->ci, &ci, sizeof(ci))) {
|
if (copy_to_user(req->ci, &ci, sizeof(ci))) {
|
||||||
|
|
|
@ -453,16 +453,13 @@ int hci_conn_del(struct hci_conn *conn)
|
||||||
struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
|
struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
|
||||||
{
|
{
|
||||||
int use_src = bacmp(src, BDADDR_ANY);
|
int use_src = bacmp(src, BDADDR_ANY);
|
||||||
struct hci_dev *hdev = NULL;
|
struct hci_dev *hdev = NULL, *d;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
BT_DBG("%s -> %s", batostr(src), batostr(dst));
|
BT_DBG("%s -> %s", batostr(src), batostr(dst));
|
||||||
|
|
||||||
read_lock_bh(&hci_dev_list_lock);
|
read_lock_bh(&hci_dev_list_lock);
|
||||||
|
|
||||||
list_for_each(p, &hci_dev_list) {
|
list_for_each_entry(d, &hci_dev_list, list) {
|
||||||
struct hci_dev *d = list_entry(p, struct hci_dev, list);
|
|
||||||
|
|
||||||
if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags))
|
if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -855,10 +852,10 @@ EXPORT_SYMBOL(hci_conn_put_device);
|
||||||
|
|
||||||
int hci_get_conn_list(void __user *arg)
|
int hci_get_conn_list(void __user *arg)
|
||||||
{
|
{
|
||||||
|
register struct hci_conn *c;
|
||||||
struct hci_conn_list_req req, *cl;
|
struct hci_conn_list_req req, *cl;
|
||||||
struct hci_conn_info *ci;
|
struct hci_conn_info *ci;
|
||||||
struct hci_dev *hdev;
|
struct hci_dev *hdev;
|
||||||
struct list_head *p;
|
|
||||||
int n = 0, size, err;
|
int n = 0, size, err;
|
||||||
|
|
||||||
if (copy_from_user(&req, arg, sizeof(req)))
|
if (copy_from_user(&req, arg, sizeof(req)))
|
||||||
|
@ -882,10 +879,7 @@ int hci_get_conn_list(void __user *arg)
|
||||||
ci = cl->conn_info;
|
ci = cl->conn_info;
|
||||||
|
|
||||||
hci_dev_lock_bh(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
list_for_each(p, &hdev->conn_hash.list) {
|
list_for_each_entry(c, &hdev->conn_hash.list, list) {
|
||||||
register struct hci_conn *c;
|
|
||||||
c = list_entry(p, struct hci_conn, list);
|
|
||||||
|
|
||||||
bacpy(&(ci + n)->bdaddr, &c->dst);
|
bacpy(&(ci + n)->bdaddr, &c->dst);
|
||||||
(ci + n)->handle = c->handle;
|
(ci + n)->handle = c->handle;
|
||||||
(ci + n)->type = c->type;
|
(ci + n)->type = c->type;
|
||||||
|
|
|
@ -319,8 +319,7 @@ static void hci_linkpol_req(struct hci_dev *hdev, unsigned long opt)
|
||||||
* Device is held on return. */
|
* Device is held on return. */
|
||||||
struct hci_dev *hci_dev_get(int index)
|
struct hci_dev *hci_dev_get(int index)
|
||||||
{
|
{
|
||||||
struct hci_dev *hdev = NULL;
|
struct hci_dev *hdev = NULL, *d;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
BT_DBG("%d", index);
|
BT_DBG("%d", index);
|
||||||
|
|
||||||
|
@ -328,8 +327,7 @@ struct hci_dev *hci_dev_get(int index)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
read_lock(&hci_dev_list_lock);
|
read_lock(&hci_dev_list_lock);
|
||||||
list_for_each(p, &hci_dev_list) {
|
list_for_each_entry(d, &hci_dev_list, list) {
|
||||||
struct hci_dev *d = list_entry(p, struct hci_dev, list);
|
|
||||||
if (d->id == index) {
|
if (d->id == index) {
|
||||||
hdev = hci_dev_hold(d);
|
hdev = hci_dev_hold(d);
|
||||||
break;
|
break;
|
||||||
|
@ -794,9 +792,9 @@ int hci_dev_cmd(unsigned int cmd, void __user *arg)
|
||||||
|
|
||||||
int hci_get_dev_list(void __user *arg)
|
int hci_get_dev_list(void __user *arg)
|
||||||
{
|
{
|
||||||
|
struct hci_dev *hdev;
|
||||||
struct hci_dev_list_req *dl;
|
struct hci_dev_list_req *dl;
|
||||||
struct hci_dev_req *dr;
|
struct hci_dev_req *dr;
|
||||||
struct list_head *p;
|
|
||||||
int n = 0, size, err;
|
int n = 0, size, err;
|
||||||
__u16 dev_num;
|
__u16 dev_num;
|
||||||
|
|
||||||
|
@ -815,11 +813,7 @@ int hci_get_dev_list(void __user *arg)
|
||||||
dr = dl->dev_req;
|
dr = dl->dev_req;
|
||||||
|
|
||||||
read_lock_bh(&hci_dev_list_lock);
|
read_lock_bh(&hci_dev_list_lock);
|
||||||
list_for_each(p, &hci_dev_list) {
|
list_for_each_entry(hdev, &hci_dev_list, list) {
|
||||||
struct hci_dev *hdev;
|
|
||||||
|
|
||||||
hdev = list_entry(p, struct hci_dev, list);
|
|
||||||
|
|
||||||
hci_del_off_timer(hdev);
|
hci_del_off_timer(hdev);
|
||||||
|
|
||||||
if (!test_bit(HCI_MGMT, &hdev->flags))
|
if (!test_bit(HCI_MGMT, &hdev->flags))
|
||||||
|
@ -1008,16 +1002,11 @@ int hci_link_keys_clear(struct hci_dev *hdev)
|
||||||
|
|
||||||
struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
|
struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
|
||||||
{
|
{
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
list_for_each(p, &hdev->link_keys) {
|
|
||||||
struct link_key *k;
|
struct link_key *k;
|
||||||
|
|
||||||
k = list_entry(p, struct link_key, list);
|
list_for_each_entry(k, &hdev->link_keys, list)
|
||||||
|
|
||||||
if (bacmp(bdaddr, &k->bdaddr) == 0)
|
if (bacmp(bdaddr, &k->bdaddr) == 0)
|
||||||
return k;
|
return k;
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1280,16 +1269,11 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
|
||||||
struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev,
|
struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev,
|
||||||
bdaddr_t *bdaddr)
|
bdaddr_t *bdaddr)
|
||||||
{
|
{
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
list_for_each(p, &hdev->blacklist) {
|
|
||||||
struct bdaddr_list *b;
|
struct bdaddr_list *b;
|
||||||
|
|
||||||
b = list_entry(p, struct bdaddr_list, list);
|
list_for_each_entry(b, &hdev->blacklist, list)
|
||||||
|
|
||||||
if (bacmp(bdaddr, &b->bdaddr) == 0)
|
if (bacmp(bdaddr, &b->bdaddr) == 0)
|
||||||
return b;
|
return b;
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2031,16 +2015,12 @@ EXPORT_SYMBOL(hci_send_sco);
|
||||||
static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote)
|
static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote)
|
||||||
{
|
{
|
||||||
struct hci_conn_hash *h = &hdev->conn_hash;
|
struct hci_conn_hash *h = &hdev->conn_hash;
|
||||||
struct hci_conn *conn = NULL;
|
struct hci_conn *conn = NULL, *c;
|
||||||
int num = 0, min = ~0;
|
int num = 0, min = ~0;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
/* We don't have to lock device here. Connections are always
|
/* We don't have to lock device here. Connections are always
|
||||||
* added and removed with TX task disabled. */
|
* added and removed with TX task disabled. */
|
||||||
list_for_each(p, &h->list) {
|
list_for_each_entry(c, &h->list, list) {
|
||||||
struct hci_conn *c;
|
|
||||||
c = list_entry(p, struct hci_conn, list);
|
|
||||||
|
|
||||||
if (c->type != type || skb_queue_empty(&c->data_q))
|
if (c->type != type || skb_queue_empty(&c->data_q))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -2089,14 +2069,12 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
|
||||||
static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
|
static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
|
||||||
{
|
{
|
||||||
struct hci_conn_hash *h = &hdev->conn_hash;
|
struct hci_conn_hash *h = &hdev->conn_hash;
|
||||||
struct list_head *p;
|
|
||||||
struct hci_conn *c;
|
struct hci_conn *c;
|
||||||
|
|
||||||
BT_ERR("%s link tx timeout", hdev->name);
|
BT_ERR("%s link tx timeout", hdev->name);
|
||||||
|
|
||||||
/* Kill stalled connections */
|
/* Kill stalled connections */
|
||||||
list_for_each(p, &h->list) {
|
list_for_each_entry(c, &h->list, list) {
|
||||||
c = list_entry(p, struct hci_conn, list);
|
|
||||||
if (c->type == type && c->sent) {
|
if (c->type == type && c->sent) {
|
||||||
BT_ERR("%s killing stalled connection %s",
|
BT_ERR("%s killing stalled connection %s",
|
||||||
hdev->name, batostr(&c->dst));
|
hdev->name, batostr(&c->dst));
|
||||||
|
|
|
@ -435,17 +435,12 @@ static const struct file_operations inquiry_cache_fops = {
|
||||||
static int blacklist_show(struct seq_file *f, void *p)
|
static int blacklist_show(struct seq_file *f, void *p)
|
||||||
{
|
{
|
||||||
struct hci_dev *hdev = f->private;
|
struct hci_dev *hdev = f->private;
|
||||||
struct list_head *l;
|
struct bdaddr_list *b;
|
||||||
|
|
||||||
hci_dev_lock_bh(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
list_for_each(l, &hdev->blacklist) {
|
list_for_each_entry(b, &hdev->blacklist, list)
|
||||||
struct bdaddr_list *b;
|
|
||||||
|
|
||||||
b = list_entry(l, struct bdaddr_list, list);
|
|
||||||
|
|
||||||
seq_printf(f, "%s\n", batostr(&b->bdaddr));
|
seq_printf(f, "%s\n", batostr(&b->bdaddr));
|
||||||
}
|
|
||||||
|
|
||||||
hci_dev_unlock_bh(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
|
|
||||||
|
@ -484,17 +479,12 @@ static void print_bt_uuid(struct seq_file *f, u8 *uuid)
|
||||||
static int uuids_show(struct seq_file *f, void *p)
|
static int uuids_show(struct seq_file *f, void *p)
|
||||||
{
|
{
|
||||||
struct hci_dev *hdev = f->private;
|
struct hci_dev *hdev = f->private;
|
||||||
struct list_head *l;
|
struct bt_uuid *uuid;
|
||||||
|
|
||||||
hci_dev_lock_bh(hdev);
|
hci_dev_lock_bh(hdev);
|
||||||
|
|
||||||
list_for_each(l, &hdev->uuids) {
|
list_for_each_entry(uuid, &hdev->uuids, list)
|
||||||
struct bt_uuid *uuid;
|
|
||||||
|
|
||||||
uuid = list_entry(l, struct bt_uuid, list);
|
|
||||||
|
|
||||||
print_bt_uuid(f, uuid->uuid);
|
print_bt_uuid(f, uuid->uuid);
|
||||||
}
|
|
||||||
|
|
||||||
hci_dev_unlock_bh(hdev);
|
hci_dev_unlock_bh(hdev);
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr)
|
||||||
if (!bacmp(bdaddr, &session->bdaddr))
|
if (!bacmp(bdaddr, &session->bdaddr))
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ static int read_index_list(struct sock *sk)
|
||||||
{
|
{
|
||||||
struct mgmt_rp_read_index_list *rp;
|
struct mgmt_rp_read_index_list *rp;
|
||||||
struct list_head *p;
|
struct list_head *p;
|
||||||
|
struct hci_dev *d;
|
||||||
size_t rp_len;
|
size_t rp_len;
|
||||||
u16 count;
|
u16 count;
|
||||||
int i, err;
|
int i, err;
|
||||||
|
@ -146,9 +147,7 @@ static int read_index_list(struct sock *sk)
|
||||||
put_unaligned_le16(count, &rp->num_controllers);
|
put_unaligned_le16(count, &rp->num_controllers);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
list_for_each(p, &hci_dev_list) {
|
list_for_each_entry(d, &hci_dev_list, list) {
|
||||||
struct hci_dev *d = list_entry(p, struct hci_dev, list);
|
|
||||||
|
|
||||||
hci_del_off_timer(d);
|
hci_del_off_timer(d);
|
||||||
|
|
||||||
set_bit(HCI_MGMT, &d->flags);
|
set_bit(HCI_MGMT, &d->flags);
|
||||||
|
@ -277,13 +276,9 @@ static void mgmt_pending_foreach(u16 opcode, int index,
|
||||||
|
|
||||||
static struct pending_cmd *mgmt_pending_find(u16 opcode, int index)
|
static struct pending_cmd *mgmt_pending_find(u16 opcode, int index)
|
||||||
{
|
{
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
list_for_each(p, &cmd_list) {
|
|
||||||
struct pending_cmd *cmd;
|
struct pending_cmd *cmd;
|
||||||
|
|
||||||
cmd = list_entry(p, struct pending_cmd, list);
|
list_for_each_entry(cmd, &cmd_list, list) {
|
||||||
|
|
||||||
if (cmd->opcode != opcode)
|
if (cmd->opcode != opcode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -592,7 +587,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
|
||||||
u16 eir_len = 0;
|
u16 eir_len = 0;
|
||||||
u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)];
|
u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)];
|
||||||
int i, truncated = 0;
|
int i, truncated = 0;
|
||||||
struct list_head *p;
|
struct bt_uuid *uuid;
|
||||||
size_t name_len;
|
size_t name_len;
|
||||||
|
|
||||||
name_len = strlen(hdev->dev_name);
|
name_len = strlen(hdev->dev_name);
|
||||||
|
@ -617,8 +612,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
|
||||||
memset(uuid16_list, 0, sizeof(uuid16_list));
|
memset(uuid16_list, 0, sizeof(uuid16_list));
|
||||||
|
|
||||||
/* Group all UUID16 types */
|
/* Group all UUID16 types */
|
||||||
list_for_each(p, &hdev->uuids) {
|
list_for_each_entry(uuid, &hdev->uuids, list) {
|
||||||
struct bt_uuid *uuid = list_entry(p, struct bt_uuid, list);
|
|
||||||
u16 uuid16;
|
u16 uuid16;
|
||||||
|
|
||||||
uuid16 = get_uuid16(uuid->uuid);
|
uuid16 = get_uuid16(uuid->uuid);
|
||||||
|
@ -1069,6 +1063,7 @@ static int get_connections(struct sock *sk, u16 index)
|
||||||
{
|
{
|
||||||
struct mgmt_rp_get_connections *rp;
|
struct mgmt_rp_get_connections *rp;
|
||||||
struct hci_dev *hdev;
|
struct hci_dev *hdev;
|
||||||
|
struct hci_conn *c;
|
||||||
struct list_head *p;
|
struct list_head *p;
|
||||||
size_t rp_len;
|
size_t rp_len;
|
||||||
u16 count;
|
u16 count;
|
||||||
|
@ -1097,11 +1092,8 @@ static int get_connections(struct sock *sk, u16 index)
|
||||||
put_unaligned_le16(count, &rp->conn_count);
|
put_unaligned_le16(count, &rp->conn_count);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
list_for_each(p, &hdev->conn_hash.list) {
|
list_for_each_entry(c, &hdev->conn_hash.list, list)
|
||||||
struct hci_conn *c = list_entry(p, struct hci_conn, list);
|
|
||||||
|
|
||||||
bacpy(&rp->conn[i++], &c->dst);
|
bacpy(&rp->conn[i++], &c->dst);
|
||||||
}
|
|
||||||
|
|
||||||
err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len);
|
err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len);
|
||||||
|
|
||||||
|
@ -1270,13 +1262,9 @@ static int set_io_capability(struct sock *sk, u16 index, unsigned char *data,
|
||||||
static inline struct pending_cmd *find_pairing(struct hci_conn *conn)
|
static inline struct pending_cmd *find_pairing(struct hci_conn *conn)
|
||||||
{
|
{
|
||||||
struct hci_dev *hdev = conn->hdev;
|
struct hci_dev *hdev = conn->hdev;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
list_for_each(p, &cmd_list) {
|
|
||||||
struct pending_cmd *cmd;
|
struct pending_cmd *cmd;
|
||||||
|
|
||||||
cmd = list_entry(p, struct pending_cmd, list);
|
list_for_each_entry(cmd, &cmd_list, list) {
|
||||||
|
|
||||||
if (cmd->opcode != MGMT_OP_PAIR_DEVICE)
|
if (cmd->opcode != MGMT_OP_PAIR_DEVICE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -377,13 +377,11 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d)
|
||||||
static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci)
|
static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci)
|
||||||
{
|
{
|
||||||
struct rfcomm_dlc *d;
|
struct rfcomm_dlc *d;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
list_for_each(p, &s->dlcs) {
|
list_for_each_entry(d, &s->dlcs, list)
|
||||||
d = list_entry(p, struct rfcomm_dlc, list);
|
|
||||||
if (d->dlci == dlci)
|
if (d->dlci == dlci)
|
||||||
return d;
|
return d;
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2115,15 +2113,13 @@ static struct hci_cb rfcomm_cb = {
|
||||||
static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
|
static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
|
||||||
{
|
{
|
||||||
struct rfcomm_session *s;
|
struct rfcomm_session *s;
|
||||||
struct list_head *pp, *p;
|
|
||||||
|
|
||||||
rfcomm_lock();
|
rfcomm_lock();
|
||||||
|
|
||||||
list_for_each(p, &session_list) {
|
list_for_each_entry(s, &session_list, list) {
|
||||||
s = list_entry(p, struct rfcomm_session, list);
|
struct rfcomm_dlc *d;
|
||||||
list_for_each(pp, &s->dlcs) {
|
list_for_each_entry(d, &s->dlcs, list) {
|
||||||
struct sock *sk = s->sock->sk;
|
struct sock *sk = s->sock->sk;
|
||||||
struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list);
|
|
||||||
|
|
||||||
seq_printf(f, "%s %s %ld %d %d %d %d\n",
|
seq_printf(f, "%s %s %ld %d %d %d %d\n",
|
||||||
batostr(&bt_sk(sk)->src),
|
batostr(&bt_sk(sk)->src),
|
||||||
|
|
|
@ -134,13 +134,10 @@ static inline void rfcomm_dev_put(struct rfcomm_dev *dev)
|
||||||
static struct rfcomm_dev *__rfcomm_dev_get(int id)
|
static struct rfcomm_dev *__rfcomm_dev_get(int id)
|
||||||
{
|
{
|
||||||
struct rfcomm_dev *dev;
|
struct rfcomm_dev *dev;
|
||||||
struct list_head *p;
|
|
||||||
|
|
||||||
list_for_each(p, &rfcomm_dev_list) {
|
list_for_each_entry(dev, &rfcomm_dev_list, list)
|
||||||
dev = list_entry(p, struct rfcomm_dev, list);
|
|
||||||
if (dev->id == id)
|
if (dev->id == id)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +195,7 @@ static DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL);
|
||||||
|
|
||||||
static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
||||||
{
|
{
|
||||||
struct rfcomm_dev *dev;
|
struct rfcomm_dev *dev, *entry;
|
||||||
struct list_head *head = &rfcomm_dev_list, *p;
|
struct list_head *head = &rfcomm_dev_list, *p;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
@ -213,8 +210,8 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
||||||
if (req->dev_id < 0) {
|
if (req->dev_id < 0) {
|
||||||
dev->id = 0;
|
dev->id = 0;
|
||||||
|
|
||||||
list_for_each(p, &rfcomm_dev_list) {
|
list_for_each_entry(entry, &rfcomm_dev_list, list) {
|
||||||
if (list_entry(p, struct rfcomm_dev, list)->id != dev->id)
|
if (entry->id != dev->id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dev->id++;
|
dev->id++;
|
||||||
|
@ -223,9 +220,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
|
||||||
} else {
|
} else {
|
||||||
dev->id = req->dev_id;
|
dev->id = req->dev_id;
|
||||||
|
|
||||||
list_for_each(p, &rfcomm_dev_list) {
|
list_for_each_entry(entry, &rfcomm_dev_list, list) {
|
||||||
struct rfcomm_dev *entry = list_entry(p, struct rfcomm_dev, list);
|
|
||||||
|
|
||||||
if (entry->id == dev->id) {
|
if (entry->id == dev->id) {
|
||||||
err = -EADDRINUSE;
|
err = -EADDRINUSE;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -456,9 +451,9 @@ static int rfcomm_release_dev(void __user *arg)
|
||||||
|
|
||||||
static int rfcomm_get_dev_list(void __user *arg)
|
static int rfcomm_get_dev_list(void __user *arg)
|
||||||
{
|
{
|
||||||
|
struct rfcomm_dev *dev;
|
||||||
struct rfcomm_dev_list_req *dl;
|
struct rfcomm_dev_list_req *dl;
|
||||||
struct rfcomm_dev_info *di;
|
struct rfcomm_dev_info *di;
|
||||||
struct list_head *p;
|
|
||||||
int n = 0, size, err;
|
int n = 0, size, err;
|
||||||
u16 dev_num;
|
u16 dev_num;
|
||||||
|
|
||||||
|
@ -480,8 +475,7 @@ static int rfcomm_get_dev_list(void __user *arg)
|
||||||
|
|
||||||
read_lock_bh(&rfcomm_dev_lock);
|
read_lock_bh(&rfcomm_dev_lock);
|
||||||
|
|
||||||
list_for_each(p, &rfcomm_dev_list) {
|
list_for_each_entry(dev, &rfcomm_dev_list, list) {
|
||||||
struct rfcomm_dev *dev = list_entry(p, struct rfcomm_dev, list);
|
|
||||||
if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
|
if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
|
||||||
continue;
|
continue;
|
||||||
(di + n)->id = dev->id;
|
(di + n)->id = dev->id;
|
||||||
|
|
Loading…
Reference in a new issue