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: 31151 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 31EA8203E6 for ; Fri, 30 May 2014 06:25:20 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf6940429oag.4 for ; Thu, 29 May 2014 23:25:19 -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=F0yEfTnUGWc8IWgkI54hzmzAEYUTVukwxmdFDKoTijQ=; b=jKJ4n/I/B4qungrGWWhF3hfYwl63dOa2q+2L78a26r+g4KlJkE+k5rXBrViqZNnEz5 L4YGmsVZdsMHuedR5VHeMa1aKqAawiC5iVJ51FTIgxzxPKHoWIy/k7qPBE1L4zYDyHvE 1TD12k4ClfYJOHRy5XhNxr69oi+ov2AFB9QU1upT7tNsfq4r2YalJ9FAG5wxGXWsch+0 O+VtxcIUoNESqmwc5ihX7GIht6sLyUcDSGt9Rj3OTaXZvBHkD9xv0cMyqsfMmlPBnBX7 AyADJWy6qv5zCH2vZFcbW6ifp36n8wkeaWCOGfN+of8ZNX0pzSx4WNqZ1Mk1rdkhcdt2 /86A== X-Gm-Message-State: ALoCoQmGolggCy2P02glxsu97HO3iL9GD8/tC3PPmnH27JSiZp/5hMfBHb/epmSpcOBrzgM2LjF6 X-Received: by 10.43.67.67 with SMTP id xt3mr4911378icb.23.1401431119721; Thu, 29 May 2014 23:25:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.84 with SMTP id h78ls942720qge.54.gmail; Thu, 29 May 2014 23:25:19 -0700 (PDT) X-Received: by 10.52.99.168 with SMTP id er8mr10067713vdb.26.1401431119595; Thu, 29 May 2014 23:25:19 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id w3si2367408vem.39.2014.05.29.23.25.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 23:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.174 as permitted sender) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id jw12so1598042veb.5 for ; Thu, 29 May 2014 23:25:19 -0700 (PDT) X-Received: by 10.58.195.231 with SMTP id ih7mr11630127vec.32.1401431119505; Thu, 29 May 2014 23:25:19 -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 ib8csp86898vcb; Thu, 29 May 2014 23:25:19 -0700 (PDT) X-Received: by 10.68.254.103 with SMTP id ah7mr15382943pbd.159.1401431118388; Thu, 29 May 2014 23:25:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gj4si4042400pbb.112.2014.05.29.23.25.17; Thu, 29 May 2014 23:25:17 -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 S932428AbaE3GZN (ORCPT + 3 others); 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-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: 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.174 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. 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 */