From patchwork Thu Oct 19 12:29:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 116392 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp436520qgn; Thu, 19 Oct 2017 05:29:15 -0700 (PDT) X-Received: by 10.99.185.79 with SMTP id v15mr1250706pgo.258.1508416155495; Thu, 19 Oct 2017 05:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508416155; cv=none; d=google.com; s=arc-20160816; b=CnQd/a6RvQfnkmitxB7X+EhzaaFEOZO0zsS80ZiXG6mBLSJf5Ee1zmwQDIHzBJqG9E /KuFw10LgqzN+l60kL8c+WwmUmq2XmwGz2duUmPBIlrPvNwekB4xYjdHMqVV/AiXcOhK tz33E73X3JULieZlamB5KMisRwzIFY7Px107+CPtuEeKgVhI9r09p0OJY4KGhsgK6Gj1 zudP0bh+l9QC33djBa9+Ao4FW76mm86Sh1tGdVepE50spg8bNgi8lqKtfjNkuXBXLrx+ kCFlmNl5/UfgXRJv1PS7K5COJXdNfuOmopao6ypu2wk+kf06sqjKNEt6EhurTMuSQtY8 p99w== 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=hWYfO677e5HBVa7N0HzReWkHyeL0CDFCbJww3kIOfLU=; b=fjruG920loK/yAdNZlUcwWyu0jJnjUMzopuste5PoWQkMxckJBqyDfi1RqZGgwdbql jCkKNDVX/16ikxmweVxLB0u5cGlNTEt/NorEWzZwN5Io+qyHpk/mM3W87mXr2qRiQ6w/ unMj+2vHYpymr1s+5OUMbrykAV7JpEBlzDn6Rw8dYcRq2exLFs/3zBhJ+cyUInL3aHxd UQeM2JsTYiIuINoKtW3x08soEz6Yatg9zXt2MZuAqBF9Im+Vb/bZHiHnCE3I6ppwHWlu 1DFSLRNDjLdqZ2Sk0QMDfYVQWT1G7MX83FaT/U9jExwvVJinxkhBgae4KYB3nPdSxTIB bE1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AP/LzR/G; 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 z7si9211340pfk.378.2017.10.19.05.29.15; Thu, 19 Oct 2017 05:29:15 -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=AP/LzR/G; 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 S1751714AbdJSM3O (ORCPT + 1 other); Thu, 19 Oct 2017 08:29:14 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:46298 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750979AbdJSM3N (ORCPT ); Thu, 19 Oct 2017 08:29:13 -0400 Received: by mail-wm0-f66.google.com with SMTP id m72so15718051wmc.1 for ; Thu, 19 Oct 2017 05:29:13 -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=mYH5amyQoD37xWzHmEoW/zCRRDfV4ZpwH77qffgUZak=; b=AP/LzR/GFl6UTM1O2fg2FEJ/8iF0BeqGuukF2atFLiBeTT2h2qDIeJ4UgMMIav2x+4 4qV3P+5G1/jUS/otEuSVzSzTV3ImdyfDinDa+kbpefSMFDA8y+94cOOXTzxDNIzwFwuM PPoTlxBT7XTJZUsJj4i92qiY75MvMSx9eS+dU= 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=mYH5amyQoD37xWzHmEoW/zCRRDfV4ZpwH77qffgUZak=; b=ftqHze7eCaQ8yVp6ky6BKw4yhToPymQULSFIzfCZt3hHHZcmU6bDBTjUdnsTICzD8v qKc3I8rh/KSiEATOcXaxX3HuISbPhD5VYguuMMSxZ8lIzmaq5g+OOrw5FkZW510BzRJd 7c1zk3I7+1+GgfhJ01+MU5AG+9+EAZtMOZpwiGMYL5fIdqAxqIvX+61im5kGNIYzhBTK 4A6Zvta18504y54yGJw/GvX43PeZBzNotvZlEj/bRppnyaekdFF0gwxMII8eeD2gLqOD +O5AlRkJU5KgNsW9Ktys3T6P/DlcH5Hg2m4DKc/MjJg6QVQObwJdk7iZxkApFoB6dbqX FBjg== X-Gm-Message-State: AMCzsaXIXlBZi028MUaU0m8t5rF+sQ8ExK5KraZSN6+9eprAdd8NhPX0 5NW1/sVCKgE2+wLMRCN3SMmMCQ== X-Google-Smtp-Source: ABhQp+TAuRtNRVBlOnk0Idisnatg7M87W7KJeAYWycOnCKdnUo7U1PHakgwNBTK6SuPasLu1fnKORg== X-Received: by 10.28.71.25 with SMTP id u25mr1431046wma.126.1508416152731; Thu, 19 Oct 2017 05:29:12 -0700 (PDT) Received: from lpoulain-ThinkPad-T470p.home ([2a01:cb19:8345:1d00:f849:a5b6:bf2e:543f]) by smtp.gmail.com with ESMTPSA id e6sm949334wra.48.2017.10.19.05.29.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 05:29:12 -0700 (PDT) From: Loic Poulain To: marcel@holtmann.org, johan.hedberg@gmail.com Cc: linux-bluetooth@vger.kernel.org, Loic Poulain Subject: [PATCH] Bluetooth: hci_ath: Add ath_vendor_cmd helper Date: Thu, 19 Oct 2017 14:29:10 +0200 Message-Id: <1508416150-26259-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 Introduce ath_vendor_cmd function which can be used to configure 'tags' and patch the firmware. ATH vendor command has the following format: | OPCODE (u8) | INDEX (LE16) | DLEN (U8) | DATA (U8 * DLEN) | BD address configuration tag is at index 0x0001. Signed-off-by: Loic Poulain --- drivers/bluetooth/hci_ath.c | 49 +++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-) -- 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/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c index 0ccf6bf..5f17ec3 100644 --- a/drivers/bluetooth/hci_ath.c +++ b/drivers/bluetooth/hci_ath.c @@ -50,6 +50,17 @@ struct ath_struct { struct work_struct ctxtsw; }; +#define OP_WRITE_TAG 0x01 + +#define INDEX_BDADDR 0x01 + +struct ath_vendor_cmd { + __u8 opcode; + __le16 index; + __u8 len; + __u8 data[251]; +} __packed; + static int ath_wakeup_ar3k(struct tty_struct *tty) { int status = tty->driver->ops->tiocmget(tty); @@ -144,30 +155,34 @@ static int ath_flush(struct hci_uart *hu) return 0; } -static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) +static int ath_vendor_cmd(struct hci_dev *hdev, uint8_t opcode, uint16_t index, + const void *data, size_t dlen) { struct sk_buff *skb; - u8 buf[10]; - int err; - - buf[0] = 0x01; - buf[1] = 0x01; - buf[2] = 0x00; - buf[3] = sizeof(bdaddr_t); - memcpy(buf + 4, bdaddr, sizeof(bdaddr_t)); - - skb = __hci_cmd_sync(hdev, 0xfc0b, sizeof(buf), buf, HCI_INIT_TIMEOUT); - if (IS_ERR(skb)) { - err = PTR_ERR(skb); - BT_ERR("%s: Change address command failed (%d)", - hdev->name, err); - return err; - } + struct ath_vendor_cmd cmd; + + if (dlen > sizeof(cmd.data)) + return -EINVAL; + + cmd.opcode = opcode; + cmd.index = cpu_to_le16(index); + cmd.len = dlen; + memcpy(cmd.data, data, dlen); + + skb = __hci_cmd_sync(hdev, 0xfc0b, dlen + 4, &cmd, HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) + return PTR_ERR(skb); kfree_skb(skb); return 0; } +static int ath_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) +{ + return ath_vendor_cmd(hdev, OP_WRITE_TAG, INDEX_BDADDR, bdaddr, + sizeof(*bdaddr)); +} + static int ath_setup(struct hci_uart *hu) { BT_DBG("hu %p", hu);