From patchwork Fri Jun 27 09:20:13 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: 32617 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C314C207CA for ; Fri, 27 Jun 2014 09:21:29 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id j17sf27433668oag.8 for ; Fri, 27 Jun 2014 02:21:29 -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=czy1tcAVR0CO0f8PCirIqNZ8BM/XUWqTOXN+QqwHn2M=; b=XL73sX1bTPpNH+O7Jb+BuD1LJeDMJLeTjEp+8kKn9P4nbxNhQa17iDdxZ7xh37yakG /Xs6ilmE16aXIBAyZ2CF1URkiu97Wc5difK8DnGCNZrPjUix5QgCJbbSuUQao+UomKd9 ZZ1CctQL8vbUrtwdPp6BzywM15U65iTqvu4eMLykV9G72WQyxoqk3KJiOr0sLk338XDU raLuu61E1S2RgD+VYbwDMLCyj1u3cQQd7OCWTGASgBFxdNoSqRR5B2CX3qAxRFi32lkO +lIfLE0eO9nBVTDEdoQNmyCCzgpvKpn1iKuxumvOmr4R/Iq0lt/2LXi7t5hKC8hhiTTK gmZQ== X-Gm-Message-State: ALoCoQmF3OblACuCxMAUGVynkSVMj6KSJCj0/OYaL89MWibcOpwhqF3Qf7JPntEuGT9An0Rs2RjX X-Received: by 10.42.101.206 with SMTP id f14mr1162137ico.23.1403860889364; Fri, 27 Jun 2014 02:21:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.72 with SMTP id k66ls574689qgd.96.gmail; Fri, 27 Jun 2014 02:21:29 -0700 (PDT) X-Received: by 10.220.114.140 with SMTP id e12mr7988549vcq.37.1403860889255; Fri, 27 Jun 2014 02:21:29 -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 g6si3991966vcn.29.2014.06.27.02.21.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:21:29 -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 jx11so4970508veb.20 for ; Fri, 27 Jun 2014 02:21:29 -0700 (PDT) X-Received: by 10.52.138.14 with SMTP id qm14mr1936636vdb.49.1403860889150; Fri, 27 Jun 2014 02:21:29 -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.221.37.5 with SMTP id tc5csp91807vcb; Fri, 27 Jun 2014 02:21:28 -0700 (PDT) X-Received: by 10.66.147.99 with SMTP id tj3mr29338390pab.47.1403860887933; Fri, 27 Jun 2014 02:21:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si13243748pas.214.2014.06.27.02.21.27; Fri, 27 Jun 2014 02:21:27 -0700 (PDT) Received-SPF: none (google.com: netdev-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 S1753210AbaF0JVY (ORCPT + 3 others); Fri, 27 Jun 2014 05:21:24 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:62383 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752779AbaF0JVU (ORCPT ); Fri, 27 Jun 2014 05:21:20 -0400 Received: by mail-pb0-f46.google.com with SMTP id md12so4333876pbc.19 for ; Fri, 27 Jun 2014 02:21:20 -0700 (PDT) X-Received: by 10.66.119.172 with SMTP id kv12mr29388443pab.34.1403860879921; Fri, 27 Jun 2014 02:21:19 -0700 (PDT) Received: from c-krapar-linux.ap.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id fu12sm48434856pad.42.2014.06.27.02.21.15 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Jun 2014 02:21:19 -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: [PATCH - RESEND] Bluetooth: Keep master role when SCO or eSCO is active Date: Fri, 27 Jun 2014 14:50:13 +0530 Message-Id: <1403860813-360-1-git-send-email-kiran.kumar@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@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 */