X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fbluetooth%2Fhci_conn.c;h=a31244e58888c39d4cab34eb082c36b53fe40ec9;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=a2bd4b1c19da3ab5044150bbdaf54fb54fdb91ce;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475;p=linux-2.6.git diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index a2bd4b1c1..a31244e58 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -348,6 +347,24 @@ int hci_conn_change_link_key(struct hci_conn *conn) } EXPORT_SYMBOL(hci_conn_change_link_key); +/* Switch role */ +int hci_conn_switch_role(struct hci_conn *conn, uint8_t role) +{ + BT_DBG("conn %p", conn); + + if (!role && conn->link_mode & HCI_LM_MASTER) + return 1; + + if (!test_and_set_bit(HCI_CONN_RSWITCH_PEND, &conn->pend)) { + struct hci_cp_switch_role cp; + bacpy(&cp.bdaddr, &conn->dst); + cp.role = role; + hci_send_cmd(conn->hdev, OGF_LINK_POLICY, OCF_SWITCH_ROLE, sizeof(cp), &cp); + } + return 0; +} +EXPORT_SYMBOL(hci_conn_switch_role); + /* Drop all connection on the device */ void hci_conn_hash_flush(struct hci_dev *hdev) {