From patchwork Thu Apr 26 11:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 134506 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2130530lji; Thu, 26 Apr 2018 04:13:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx491A6cPQliqq3advhsr1A8VHUrb4HR085FMqcxKqSFKF5eoRVLDDCpJtoFX830v+btXIutJ X-Received: by 10.98.137.16 with SMTP id v16mr31430135pfd.13.1524741214420; Thu, 26 Apr 2018 04:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524741214; cv=none; d=google.com; s=arc-20160816; b=T0+OKnwf0+ttZgRezUR7z751bgGIwhwZLjuXWoFKNRvKVz2TGagVsXRqNVc2EK3KC9 /e7gtkcrcYhCVI1uhDBWYPQu7IJr4O9DSrQnlOJvv8aya6hEzJUOwAT/5AYAeC0KkYpS OqCj5MkC9gjLMTMU1ej1azuvyA8FXZOOinKRpWLsZEVtp81YbnxzKkPUj9BKLFPhZDTJ LI3N0nK237QAwXpCkZC0OXLbx+9Ecg8USOtQkawAQ7O/pljnoIeLuioUEdw+0iKXwQoB 57kVqwP3ReOtZO/21uAXtENLDhvek5U2PNnnee3uupposKFTSvcgfECUJi8eBT+p0UTe XalQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=D8E88isIbVsNncOi8zzhf/t42yUuXNhYagDYCzwIiFI=; b=NZ8Hw3/MBP0fnkGoeNsGrY7jhvT0bB7tDPiTIIdXY8l2xxXPFWAJ0HJbubS5Mhqagn cbbXnA3VsQcum0OrGEtWoAzSGHO97BR4SP1xgG0wgiFWugL8BGkqZLf0aZGNlGOly2Gz bepsGny7jqyAHH2s4EewgyP+BF+EY+aU2eSP2A1zwWha9Pce9KumOuFppzNXDRL2YyVO sgvQu78EcrlSn8z1P4jBn8Lo+D8KpcnUB1XCHOs064BCnSsgIe6Tz55KsYS+BH3Z8Lv1 dAWcsHHJnnNhVymItL40+S5OddOuD7/r5AEiWEW2fycW8Dvz2kZ23Ij06kavzAtHRuOA eylg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jl1eI6YP; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f38-v6si17584718plb.44.2018.04.26.04.13.34; Thu, 26 Apr 2018 04:13:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jl1eI6YP; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755209AbeDZLNc (ORCPT + 1 other); Thu, 26 Apr 2018 07:13:32 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39470 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755171AbeDZLNb (ORCPT ); Thu, 26 Apr 2018 07:13:31 -0400 Received: by mail-wm0-f67.google.com with SMTP id b21so12536127wme.4 for ; Thu, 26 Apr 2018 04:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lqT0lbK7pBsE/GXqMIlCOn4lL7TwkuimP5Sqz3uAFmM=; b=jl1eI6YP02p0Hg4c5mDPVf2cdI8pJ1Kf88Q26NnaECGReCTtRnBPijDz1Ziauh4qZa sS8ods/2ZEAklxo4lC30edn1PFOOrZGqMWYiTRsOzrKiwVO8IBddhv25QAbizmYHGl2K spR6LEIWlIN5I8nQjibRywGm1wPmFeqCaPMXM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lqT0lbK7pBsE/GXqMIlCOn4lL7TwkuimP5Sqz3uAFmM=; b=sdkBC67/5OFduUfSJ3nC+efZR3CWrF+zixgG24MJeJ8V9lY88TCX/DjfW31nRg7e17 x7KWOEfcbGQiE0TLP4BRXOPtxGvlNnOj3EVfFU+oqoP9YjLgB/XX0t+9UWT4/dSTQzEb VIEpD9eIBIj1jLZ0MOqRj8d8Bzln/olW9RvURM12bpaBkt6pkV4GOxH5LTZzYvOwUYLC 92JN41ShwgutEKwWpR6lYMabfzo9bm0t2LDewks8TzfURPLLQ0I7zlop1PsAhvqVm+iR dEgtYSLiVaNDniqSLBUUHkz9N6QkSYCy8bfHmXF91RCMlOjml71ZUwGND0EZp2ZsWasx T38Q== X-Gm-Message-State: ALQs6tDJ6fbTRXNsU4To5uJTODkDbzkZ0X59NjsKwRKpxTcr/i9Lb9le D2K2rLI3h1eZtIF85U7Swqr8Qw== X-Received: by 10.28.58.81 with SMTP id h78mr17218059wma.110.1524741210324; Thu, 26 Apr 2018 04:13:30 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home (LFbn-1-10589-161.w90-89.abo.wanadoo.fr. [90.89.181.161]) by smtp.gmail.com with ESMTPSA id x81-v6sm18967036wrb.23.2018.04.26.04.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 04:13:29 -0700 (PDT) From: Loic Poulain To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-bluetooth@vger.kernel.org, bgodavar@codeaurora.org, Loic Poulain Subject: [PATCH v3 1/2] Bluetooth: Add __hci_cmd_send function Date: Thu, 26 Apr 2018 13:13:26 +0200 Message-Id: <1524741207-19753-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This function allows to send a HCI command without expecting any controller event/response in return. This is allowed for vendor- specific commands only. Signed-off-by: Loic Poulain --- v2: Only allow vendor-specific command to be unresponded Rename function to __hci_cmd_send v3: no change include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index b619a19..893bbbb 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1393,6 +1393,8 @@ struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u32 timeout); struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u8 event, u32 timeout); +int __hci_cmd_send(struct hci_dev *hdev, u16 opcode, u32 plen, + const void *param); int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, const void *param); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 40d260f..b0ee9ed 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3422,6 +3422,37 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, return 0; } +int __hci_cmd_send(struct hci_dev *hdev, u16 opcode, u32 plen, + const void *param) +{ + struct sk_buff *skb; + + if (hci_opcode_ogf(opcode) != 0x3f) { + /* A controller receiving a command shall respond with either + * a Command Status Event or a Command Complete Event. + * Therefore, all standard HCI commands must be sent via the + * standard API, using hci_send_cmd or hci_cmd_sync helpers. + * Some vendors do not comply with this rule for vendor-specific + * commands and do not return any event. We want to support + * unresponded commands for such cases only. + */ + bt_dev_err(hdev, "unresponded command not supported"); + return -EINVAL; + } + + skb = hci_prepare_cmd(hdev, opcode, plen, param); + if (!skb) { + bt_dev_err(hdev, "no memory for command (opcode 0x%4.4x)", + opcode); + return -ENOMEM; + } + + hci_send_frame(hdev, skb); + + return 0; +} +EXPORT_SYMBOL(__hci_cmd_send); + /* Get data from the previously sent command */ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode) {