From patchwork Mon Jul 11 19:50:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 9224045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0E3660760 for ; Mon, 11 Jul 2016 19:51:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A37FE27D29 for ; Mon, 11 Jul 2016 19:51:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9815D27E15; Mon, 11 Jul 2016 19:51:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4211027D29 for ; Mon, 11 Jul 2016 19:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752527AbcGKTvX (ORCPT ); Mon, 11 Jul 2016 15:51:23 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:44893 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051AbcGKTvT (ORCPT ); Mon, 11 Jul 2016 15:51:19 -0400 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=omega.localdomain) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1bMhEb-00038F-Ot; Mon, 11 Jul 2016 21:51:17 +0200 From: Alexander Aring To: linux-wpan@vger.kernel.org Cc: kernel@pengutronix.de, luiz.dentz@gmail.com, kaspar@schleiser.de, jukka.rissanen@linux.intel.com, linux-bluetooth@vger.kernel.org, Patrik.Flykt@linux.intel.com, Alexander Aring Subject: [RFC bluetooth-next 09/20] bluetooth: introduce l2cap_hdev_chan_connect Date: Mon, 11 Jul 2016 21:50:33 +0200 Message-Id: <20160711195044.25343-10-aar@pengutronix.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160711195044.25343-1-aar@pengutronix.de> References: <20160711195044.25343-1-aar@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: aar@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-wpan@vger.kernel.org Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A BTLE 6LoWPAN should be binded to one hci device and is not changeable afterwards. This patch adds l2cap_hdev_chan_connect function without calling hci_get_route which decides on bluetooth side which may be the best hci device which should be use. The hci dev will be available by parameter. Signed-off-by: Alexander Aring --- include/net/bluetooth/l2cap.h | 3 +++ net/bluetooth/l2cap_core.c | 28 +++++++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 5ee3c68..8a4d26e 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -928,6 +928,9 @@ struct l2cap_chan *l2cap_chan_create(void); void l2cap_chan_close(struct l2cap_chan *chan, int reason); int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst, u8 dst_type); +int l2cap_hdev_chan_connect(struct hci_dev *hdev, + struct l2cap_chan *chan, __le16 psm, u16 cid, + bdaddr_t *dst, u8 dst_type); int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); void l2cap_chan_busy(struct l2cap_chan *chan, int busy); int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator); diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 54ceb1f..2ab8814 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -7041,21 +7041,17 @@ static bool is_valid_psm(u16 psm, u8 dst_type) { return ((psm & 0x0101) == 0x0001); } -int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, - bdaddr_t *dst, u8 dst_type) +int l2cap_hdev_chan_connect(struct hci_dev *hdev, + struct l2cap_chan *chan, __le16 psm, u16 cid, + bdaddr_t *dst, u8 dst_type) { struct l2cap_conn *conn; struct hci_conn *hcon; - struct hci_dev *hdev; int err; BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", &chan->src, dst, dst_type, __le16_to_cpu(psm)); - hdev = hci_get_route(dst, &chan->src); - if (!hdev) - return -EHOSTUNREACH; - hci_dev_lock(hdev); if (!is_valid_psm(__le16_to_cpu(psm), dst_type) && !cid && @@ -7199,7 +7195,25 @@ chan_unlock: mutex_unlock(&conn->chan_lock); done: hci_dev_unlock(hdev); + return err; +} +EXPORT_SYMBOL_GPL(l2cap_hdev_chan_connect); + +int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, + bdaddr_t *dst, u8 dst_type) +{ + struct hci_dev *hdev; + int err = -EHOSTUNREACH; + + hdev = hci_get_route(dst, &chan->src); + if (!hdev) + goto done; + + err = l2cap_hdev_chan_connect(hdev, chan, psm, cid, dst, dst_type); + hci_dev_put(hdev); + +done: return err; } EXPORT_SYMBOL_GPL(l2cap_chan_connect);