From patchwork Wed May 28 05:56:28 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: 31031 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B9AC12066E for ; Wed, 28 May 2014 05:57:49 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hq11sf23474877vcb.6 for ; Tue, 27 May 2014 22:57:49 -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=O5zVt9ZDiL4s/lM77LSwTLUisFIVCelw4Y2K/mFDzsU=; b=Opeh6gFSZlUYQpmxFFwnvpOVsWg30WColEsUGGTNUlhxHqv6OU+Vv/pUXc5RTOg9jY fGsFU6kBdLv+TUJ+z5oycWkDwcPuofTlK4gFQkKUT26OIilnkHeFhoUftAg6LDrILz2g cGendBmqTxSI8+Rg/whS3PDN4Z6SBrQkdheNObiYmCphN7RbzF0+A70EbO6I3S8cT+nz zf+8fTMxCdRmC3BqlnLt1bQnEvwYAbvusMQ31wYC2lcmolhrCb1dnmpkLmW9zqz3JTCZ j8JU2iW2SxXuZ+ha0CLvgn2UsBHAmWVqz+yrgk/BkLrmuJNseU+if9pSuDvk2x54tlR3 sdbg== X-Gm-Message-State: ALoCoQnm1VBQSr5Y+TYnpARvaN9s9MpIKX+NIU5sfaL+pg5Ngsl4fqgR/QTj1SfFtzLi72iJw409 X-Received: by 10.58.43.170 with SMTP id x10mr15482746vel.36.1401256669296; Tue, 27 May 2014 22:57:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.201 with SMTP id z67ls2803235qgd.94.gmail; Tue, 27 May 2014 22:57:49 -0700 (PDT) X-Received: by 10.53.0.135 with SMTP id ay7mr27065392vdd.11.1401256669190; Tue, 27 May 2014 22:57:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id eh4si9819655vec.88.2014.05.27.22.57.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 May 2014 22:57:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id la4so420432vcb.34 for ; Tue, 27 May 2014 22:57:49 -0700 (PDT) X-Received: by 10.52.241.98 with SMTP id wh2mr19160063vdc.37.1401256669073; Tue, 27 May 2014 22:57:49 -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 ib8csp175274vcb; Tue, 27 May 2014 22:57:48 -0700 (PDT) X-Received: by 10.68.249.195 with SMTP id yw3mr43086263pbc.134.1401256668139; Tue, 27 May 2014 22:57:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id js5si9496784pbc.250.2014.05.27.22.57.47 for ; Tue, 27 May 2014 22:57:47 -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 S1753917AbaE1F5k (ORCPT + 27 others); Wed, 28 May 2014 01:57:40 -0400 Received: from mail-pb0-f41.google.com ([209.85.160.41]:58376 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbaE1F5i (ORCPT ); Wed, 28 May 2014 01:57:38 -0400 Received: by mail-pb0-f41.google.com with SMTP id uo5so10636043pbc.28 for ; Tue, 27 May 2014 22:57:37 -0700 (PDT) X-Received: by 10.66.188.5 with SMTP id fw5mr41988517pac.63.1401256657590; Tue, 27 May 2014 22:57:37 -0700 (PDT) Received: from c-krapar-linux.ap.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id bu1sm26361093pbb.54.2014.05.27.22.57.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 27 May 2014 22:57:36 -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 (open list:BLUETOOTH SUBSYSTEM), netdev@vger.kernel.org (open list:NETWORKING [GENERAL]), Android Kernel Team , John Stultz , Jaikumar Ganesh , Kiran Raparthy Subject: [RFC] Bluetooth: Keep master role when SCO or eSCO is active Date: Wed, 28 May 2014 11:26:28 +0530 Message-Id: <1401256588-1467-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.220.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. Cc: Marcel Holtmann (maintainer:BLUETOOTH SUBSYSTEM) Cc: Gustavo Padovan (maintainer:BLUETOOTH SUBSYSTEM) Cc: Johan Hedberg (maintainer:BLUETOOTH SUBSYSTEM) Cc: "David S. Miller" (maintainer:NETWORKING [GENERAL]) Cc: linux-bluetooth@vger.kernel.org (open list:BLUETOOTH SUBSYSTEM) Cc: netdev@vger.kernel.org (open list:NETWORKING [GENERAL]) Cc: linux-kernel@vger.kernel.org (open list) 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..6f944d5 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -1915,6 +1915,15 @@ 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 +1970,8 @@ 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 */