X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fbluetooth%2Fhci_conn.c;h=f812ed129e589cc1929bdf06830eef5f60243006;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=a2bd4b1c19da3ab5044150bbdaf54fb54fdb91ce;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index a2bd4b1c1..f812ed129 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) { @@ -386,7 +403,7 @@ int hci_get_conn_list(void __user *arg) size = sizeof(req) + req.conn_num * sizeof(*ci); - if (!(cl = (void *) kmalloc(size, GFP_KERNEL))) + if (!(cl = kmalloc(size, GFP_KERNEL))) return -ENOMEM; if (!(hdev = hci_dev_get(req.dev_id))) {