From patchwork Thu Apr 26 07:38:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 134418 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1908043lji; Thu, 26 Apr 2018 00:38:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5iSFAUGy6qSj7Rcz0DVEgqsuGCT29Bf8fTRvec8g4qeC0DP7mV+NBj8tYSYVE4idhPyYW X-Received: by 2002:a17:902:60cd:: with SMTP id k13-v6mr33291327pln.44.1524728338061; Thu, 26 Apr 2018 00:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524728338; cv=none; d=google.com; s=arc-20160816; b=VbsDr5T7UQ32eLlNGGQ46Og7Cw4F/j0f9jwlsPl10gxM+FVqsXhs0+CnFpXT98TivU 26u7IDPbL7fH7uGvHuzVVyeykjuoKxDJEuWuCAaSxHnnFdm8YLJILCm/lobMVW0NI6pi eP0ND4OKyPnIxFVFcVgWXQKSTrT8uEhGP/1ntT6ihaeI9ta5Ki988T6boytfNf/nHupQ bcG8hVzpx+d7iV8lEklbT1E8PhDz35Px+W8R8Chw29BfrpaVBxCPOr/eE6C7XIkb5BIN k7vHschhqsA9+HKk8jQkaWzwPGT1UNy93184ckFl2hts93/MY6VlZ4CZ7pttvq404d+p 9+uQ== 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=lAYkSkQwSJWcQ8uGFriha/Xri59spcHssNyFEpYJG7E=; b=0S2WAjQMF+K2xaurm1sohFiX837z+Jqfz7dQnTe6M7948mFkgYLCfk+ElYkYf0aiOV IYsYXzLGzuL9gZ9/qmAOpEzKa9yusaRJtUTwKCEQCljeT+nsGToGPu/0s0dKtxk9F8lY Km44jUhMlKttdcz1eWqNDJPOcJ40UAh84iHzqTvuO2Y7Z7Gw4WbLoWW61TOnC95vsDVc u6pVprwnFdgq6XlSVlVmKoBWsXi4kddbxTynPZYSjHdbm9ZuY7oXaFtgmExYCiEs2Qbt obRs7fO4RwxUd/L3DfyDVHjEkEgz4pt3jCGbUAvRlg5GXxoNAxxswbR/SBvvQ7VW7gUU 4+dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ReD6p26s; 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 q5si15616075pgc.620.2018.04.26.00.38.57; Thu, 26 Apr 2018 00:38:58 -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=ReD6p26s; 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 S1753852AbeDZHi5 (ORCPT + 1 other); Thu, 26 Apr 2018 03:38:57 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:42370 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753007AbeDZHi4 (ORCPT ); Thu, 26 Apr 2018 03:38:56 -0400 Received: by mail-wr0-f195.google.com with SMTP id v5-v6so4925595wrf.9 for ; Thu, 26 Apr 2018 00:38:55 -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=oEkmp8W92Y5iivkr2iSTNXrkk7JES4sM/QEaXnPOvM4=; b=ReD6p26sauFnB+61PWQh4w0zt8/bI9s28raDEqSWmSZ5LFZ4O3Ao5/XgpwqgV1fdU2 dIUk5TvTMqhflnkIYJl1dpCwVm34Z6qn5TbfzrrmSFGsPvihkHcjC2TCZ1fX4O/slaYG qtLpt13oyAltjSNSA5o9cci98Q+hfESTqXDUI= 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=oEkmp8W92Y5iivkr2iSTNXrkk7JES4sM/QEaXnPOvM4=; b=uLTuQroB46tL/y4k3i7AMEiCEQPhqGDE6sYdB10FzcRopPj+LQEiQRXPrGGoN9oaiX HIcr72JM7BzVlDMPSEqm22R5gsKCFDN/im7RiLW0DXLO0pC8BeWvdru3kLVOxXEaL4Xt Emv9kejsz/rDRMuZxnYksK7O4sqsJviNBjRPkSPszS0A7PaNHGwEDVq7BnXaxw5Qcf7h 1gP9QeFaXkrP+xy63Hir8scHPueBHrfEH43xDcmJ/ZX9Go+SurhBOrThC0u7sWe9m1N5 uiD76uytg21t8VF4UShb6CBeTuJ1b8FXstXMeApCudu2CLzeeqRqNtWWd3UFg6miX641 rD+w== X-Gm-Message-State: ALQs6tBEzhN/f3SSAeQkqAdqW/OGlIiNMdx95yEg0EMOaiUJzwRUABwP q/zuHwhW/VBOFsdpR99U1X5UOQ== X-Received: by 2002:adf:a617:: with SMTP id k23-v6mr26877268wrc.200.1524728335180; Thu, 26 Apr 2018 00:38:55 -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 u196sm11833221wmf.30.2018.04.26.00.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 00:38:54 -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 v2 1/2] Bluetooth: Add __hci_cmd_send function Date: Thu, 26 Apr 2018 09:38:51 +0200 Message-Id: <1524728332-10093-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 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) {