From patchwork Sun Jun 1 05:20:34 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: 31240 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 804EC20068 for ; Sun, 1 Jun 2014 05:23:40 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id fp1sf10657293pdb.6 for ; Sat, 31 May 2014 22:23:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=HK5lilW1lnb9hZKVHsZX/Hgk2V+z92spDmrvjanrWVQ=; b=kmT96Sl7Oe+aj55YckjIPwpmGE+bZ52G7zMb3GnvURoIIvke/5+6qzClVqAbF1D14x YlQ/xYv/jfVDJSPNjz47pSF0kDlg+bnRppe9fPoLquP2OwD7Pzz3/TM4dV7YkwrjyfDh RGgTdqJF3vXsHi4BY0ZS59cb/q9enWitVBKt6b1z3Z+2iTapFfSG5nuK4oUtyyBNjqu3 qH3GeQW6JDCgq97fA/g9g/lc9Hu1cViIjEhecF9NyEfZFLMbkX5GWY8oV6dEvvx65Ck+ ZWGB3/UZfesWqe/7aEgBcDKZp/a0sL9Gt17WhHkorQnmMfgkIetuqK/jDyzSDu8+oNWE mvYA== X-Gm-Message-State: ALoCoQlQV6cvjlK7n7GkthrvmPAtIHm9bXTbcUW/xMgiPcWVTEqMfWB0gzNwkrWjNfPtjfoPTeTS X-Received: by 10.66.138.17 with SMTP id qm17mr10759159pab.34.1401600218706; Sat, 31 May 2014 22:23:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.225 with SMTP id b88ls1579467qgb.32.gmail; Sat, 31 May 2014 22:23:38 -0700 (PDT) X-Received: by 10.52.113.1 with SMTP id iu1mr19376686vdb.35.1401600218423; Sat, 31 May 2014 22:23:38 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id yf17si6316518vdb.9.2014.05.31.22.23.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 May 2014 22:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so3819955veb.6 for ; Sat, 31 May 2014 22:23:38 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr23440315vcb.2.1401600218072; Sat, 31 May 2014 22:23:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp14791vcb; Sat, 31 May 2014 22:23:37 -0700 (PDT) X-Received: by 10.68.213.198 with SMTP id nu6mr30618899pbc.21.1401600217054; Sat, 31 May 2014 22:23:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id td3si11927179pab.128.2014.05.31.22.23.36; Sat, 31 May 2014 22:23:36 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751219AbaFAFX0 (ORCPT + 28 others); Sun, 1 Jun 2014 01:23:26 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:50607 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750728AbaFAFXY (ORCPT ); Sun, 1 Jun 2014 01:23:24 -0400 Received: by mail-pa0-f54.google.com with SMTP id lf10so2877434pab.27 for ; Sat, 31 May 2014 22:23:23 -0700 (PDT) X-Received: by 10.66.222.100 with SMTP id ql4mr31138676pac.109.1401600203839; Sat, 31 May 2014 22:23:23 -0700 (PDT) Received: from c-krapar-linux.ap.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id ln2sm43577862pab.35.2014.05.31.22.23.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 May 2014 22:23:23 -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 v3] Bluetooth: Keep master role when SCO or eSCO is active Date: Sun, 1 Jun 2014 10:50:34 +0530 Message-Id: <1401600034-16687-1-git-send-email-kiran.kumar@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kiran.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. v3: 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..cfb1355 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 */