From patchwork Fri May 30 06:24:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran Kumar Raparthy X-Patchwork-Id: 353883 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6E2991400E4 for ; Fri, 30 May 2014 16:25:19 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932428AbaE3GZN (ORCPT ); Fri, 30 May 2014 02:25:13 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:58263 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932186AbaE3GZL (ORCPT ); Fri, 30 May 2014 02:25:11 -0400 Received: by mail-pb0-f42.google.com with SMTP id md12so1387659pbc.1 for ; Thu, 29 May 2014 23:25:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=23PDQyV0S4O+i/E0Fvo/YLclQ+JO3D2r67hOiDcgV9E=; b=IC5MJIA63JoYNYhFqrh6jTztS1AXGbRmdHGKWh8aNi9P3ZkI0NCmhSY2Ed+xVe4Xbe B34SaaCDGF05Rgw2i4N6PCP2g+qQhnIlBHNKGzqEU4Mg4l2t9f+zm37I+vO6kjItCw5C D0JTK324IJxgy6PwAhRZtW/pAvoZmEF2kOCmXvOdrdutimfzDVVrGtKucs4GICFLUzgn 9QuTFWhUDthRKTCK3ZAXgp3tK7nAzifSl+qHH13Pb0qiqtEjerRVJlwVMj+S9Lfzxmif OKbHoJuG3eSA+U+1vZLRv+0k/qCCv/nqsVSgvEuRotRTuIJWglQeH82F7V8ScQazeu22 R3+w== X-Gm-Message-State: ALoCoQlRsQADbBmNzl7hXrHQfhTTFMwveRb+82i/YjydNIiD4Aakidq0jmWfw7C4Y4Dn5NQzk8YI X-Received: by 10.68.166.36 with SMTP id zd4mr15893806pbb.54.1401431110443; Thu, 29 May 2014 23:25:10 -0700 (PDT) Received: from c-krapar-linux.ap.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id yl9sm13827552pac.25.2014.05.29.23.25.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 May 2014 23:25:09 -0700 (PDT) From: Kiran Kumar Raparthy To: linux-kernel@vger.kernel.org Cc: "hyungseoung.yoo" , Marcel Holtmann , Gustavo Padovan , Johan Hedberg , "David S. Miller" , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, Android Kernel Team , John Stultz , Jaikumar Ganesh , Kiran Raparthy Subject: [RFC v2] Bluetooth: Keep master role when SCO or eSCO is active Date: Fri, 30 May 2014 11:54:54 +0530 Message-Id: <1401431094-2833-1-git-send-email-kiran.kumar@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: "hyungseoung.yoo" Preserve the master role when SCO or eSCO is active as this improves compatability with lots of headset and chipset combinations. This is one of the number of patches from the Android AOSP common.git tree, which is used on almost all Android devices. It looks like it would improve support for compatibility with lot of headset,so I wanted to submit it for review to see if it should go upstream. v2: Fixed formatting issues pointed by Sergei Cc: Marcel Holtmann Cc: Gustavo Padovan Cc: Johan Hedberg Cc: "David S. Miller" Cc: linux-bluetooth@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Android Kernel Team Cc: John Stultz Signed-off-by: hyungseoung.yoo Signed-off-by: Jaikumar Ganesh [kiran: Added context to commit message] Signed-off-by: Kiran Raparthy --- net/bluetooth/hci_event.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 15010a2..48bc772 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1915,6 +1915,14 @@ unlock: hci_conn_check_pending(hdev); } +static inline bool is_sco_active(struct hci_dev *hdev) +{ + if (hci_conn_hash_lookup_state(hdev, SCO_LINK, BT_CONNECTED) || + hci_conn_hash_lookup_state(hdev, ESCO_LINK, BT_CONNECTED)) + return true; + return false; +} + static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_conn_request *ev = (void *) skb->data; @@ -1961,7 +1969,9 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) bacpy(&cp.bdaddr, &ev->bdaddr); - if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) + if (lmp_rswitch_capable(hdev) && + ((mask & HCI_LM_MASTER) || + is_sco_active(hdev))) cp.role = 0x00; /* Become master */ else cp.role = 0x01; /* Remain slave */