Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277661
b: refs/heads/master
c: 1785dbf
h: refs/heads/master
i:
  277659: d9b5ba6
v: v3
  • Loading branch information
Peter Hurley authored and Gustavo F. Padovan committed Oct 7, 2011
1 parent 3129f4a commit ab66c2f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ab88f7149e0e3284623adcaa60460a9a69d9f131
refs/heads/master: 1785dbf9e30be62ab45e34900e574b8307bc98b5
34 changes: 20 additions & 14 deletions trunk/net/bluetooth/hidp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ static void __hidp_link_session(struct hidp_session *session)
{
__module_get(THIS_MODULE);
list_add(&session->list, &hidp_session_list);

hci_conn_hold_device(session->conn);
}

static void __hidp_unlink_session(struct hidp_session *session)
Expand Down Expand Up @@ -785,24 +783,26 @@ static int hidp_session(void *arg)
return 0;
}

static struct device *hidp_get_device(struct hidp_session *session)
static struct hci_conn *hidp_find_connection(struct hidp_session *session)
{
bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src;
bdaddr_t *dst = &bt_sk(session->ctrl_sock->sk)->dst;
struct device *device = NULL;
struct hci_conn *conn;
struct hci_dev *hdev;

hdev = hci_get_route(dst, src);
if (!hdev)
return NULL;

session->conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (session->conn)
device = &session->conn->dev;
hci_dev_lock_bh(hdev);
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (conn)
hci_conn_hold_device(conn);
hci_dev_unlock_bh(hdev);

hci_dev_put(hdev);

return device;
return conn;
}

static int hidp_setup_input(struct hidp_session *session,
Expand Down Expand Up @@ -852,7 +852,7 @@ static int hidp_setup_input(struct hidp_session *session,
input->relbit[0] |= BIT_MASK(REL_WHEEL);
}

input->dev.parent = hidp_get_device(session);
input->dev.parent = &session->conn->dev;

input->event = hidp_input_event;

Expand Down Expand Up @@ -952,7 +952,7 @@ static int hidp_setup_hid(struct hidp_session *session,
strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);

hid->dev.parent = hidp_get_device(session);
hid->dev.parent = &session->conn->dev;
hid->ll_driver = &hidp_hid_driver;

hid->hid_get_raw_report = hidp_get_raw_report;
Expand Down Expand Up @@ -993,6 +993,12 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
goto failed;
}

session->conn = hidp_find_connection(session);
if (!session->conn) {
err = -ENOTCONN;
goto failed;
}

bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst);

session->ctrl_mtu = min_t(uint, l2cap_pi(ctrl_sock->sk)->chan->omtu,
Expand All @@ -1018,6 +1024,8 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID);
session->idle_to = req->idle_to;

__hidp_link_session(session);

if (req->rd_size > 0) {
err = hidp_setup_hid(session, req);
if (err)
Expand All @@ -1030,8 +1038,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
goto purge;
}

__hidp_link_session(session);

hidp_set_timer(session);

if (session->hid) {
Expand Down Expand Up @@ -1084,8 +1090,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
unlink:
hidp_del_timer(session);

__hidp_unlink_session(session);

if (session->input) {
input_unregister_device(session->input);
session->input = NULL;
Expand All @@ -1100,6 +1104,8 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
session->rd_data = NULL;

purge:
__hidp_unlink_session(session);

skb_queue_purge(&session->ctrl_transmit);
skb_queue_purge(&session->intr_transmit);

Expand Down

0 comments on commit ab66c2f

Please sign in to comment.