Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1281287ybl; Fri, 30 Aug 2019 15:15:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwosJICSbF8tAQn2noGj88zyAyyy62bR65rp/S+/XceC501N8TswLYxZ/OjcN94mtVMOgFh X-Received: by 2002:a05:6a00:c7:: with SMTP id e7mr20620589pfj.52.1567203313467; Fri, 30 Aug 2019 15:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567203313; cv=none; d=google.com; s=arc-20160816; b=kboCIR3gXBiLlfiJopUSSMtaVNekfannK42zVkesZF5tkuTCP1qMuRUl5vB1P7M6ly YFKUm5+S5JP15vFTNotVQQyMr1rpKNlXlMN5NATYoSednb5CbrROyaDyjZ1h1DPQg71F GWZpvA4RsvaPbFcQxRlZvGJHKb5UByZjH4KRgH2oWnXuEJ/hkEdO1HKnPIFOvCM0KOB8 dFacUG1QSBDYTFNKTYJTMAsJHg+C1Nfp0XaBxXaimy83Iu3GbHRTnzFRE5D6DMzSolht qib6y+5OBxBrBQRAHhBa7yG0fzRuUQSwCsVxwX2M7Vi1JlcouVDHIBZ/dGGNWCxdMZaI dtRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:authenticated-by; bh=c2fpAuwPwA1qBNgdHa3dTV5eXPqvZdKoXygyzt6iwZM=; b=C+l/W62Tn5aPxEwhBWe9Uw/CKivEMEGxJnvXf1pVg7JVVRJbQFmpPOXd1MZfECbli6 0OaHswvlnPVSfIqv/gDnAUFd5iPjgTDk4ynD5aHP4cZwz7MPGvNE9oYPGqgNdc3nXO6y /MBIc7tjXVNy6EfOechbE7Q7sebsXdlePOTf3T4kaK4ogOueSBOpXm0BKA7jXKWj16SK C8uUz3CqRABnEt+e3ACXbYeB8iJxyXhkPe/ytXUNlBTyY4dbBGd0NfK2d0RKVHkQtkhz RxUR+XA3p10kGpyAQm2nyzj+tslOd1iulDRD9h2OcAODexT7zo9jl0C0/DxnLr3WCthN isBw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si5656272plw.37.2019.08.30.15.14.28; Fri, 30 Aug 2019 15:15:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbfH3WO1 (ORCPT + 99 others); Fri, 30 Aug 2019 18:14:27 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:48559 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728176AbfH3WO1 (ORCPT ); Fri, 30 Aug 2019 18:14:27 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x7UMEF4I012637, This message is accepted by code: ctloc85258 Received: from RS-CAS02.realsil.com.cn (rsn1.realsil.com.cn[172.29.17.3](maybeforged)) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x7UMEF4I012637 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 31 Aug 2019 06:14:16 +0800 Received: from laptop-alex (59.63.203.251) by RS-CAS02.realsil.com.cn (172.29.17.3) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 31 Aug 2019 06:14:15 +0800 Date: Sat, 31 Aug 2019 06:13:56 +0800 From: Alex Lu To: Marcel Holtmann CC: Johan Hedberg , , , Max Chou Subject: [PATCH v2 2/2] Bluetooth: btrtl: Add firmware version print Message-ID: <20190830221356.GA9697@laptop-alex> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [59.63.203.251] Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Alex Lu This patch is used to print fw version for debug convenience Signed-off-by: Alex Lu --- Changes in v2 - Re-order the code so that no forward declaration is needed drivers/bluetooth/btrtl.c | 56 ++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index b7487ab99eed..e32ef7c60a22 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -178,6 +178,27 @@ static const struct id_table *btrtl_match_ic(u16 lmp_subver, u16 hci_rev, return &ic_id_table[i]; } +static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev) +{ + struct sk_buff *skb; + + skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, + HCI_INIT_TIMEOUT); + if (IS_ERR(skb)) { + rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION failed (%ld)\n", + PTR_ERR(skb)); + return skb; + } + + if (skb->len != sizeof(struct hci_rp_read_local_version)) { + rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION event length mismatch\n"); + kfree_skb(skb); + return ERR_PTR(-EIO); + } + + return skb; +} + static int rtl_read_rom_version(struct hci_dev *hdev, u8 *version) { struct rtl_rom_version_evt *rom_version; @@ -368,6 +389,8 @@ static int rtl_download_firmware(struct hci_dev *hdev, int frag_len = RTL_FRAG_LEN; int ret = 0; int i; + struct sk_buff *skb; + struct hci_rp_read_local_version *rp; dl_cmd = kmalloc(sizeof(struct rtl_download_cmd), GFP_KERNEL); if (!dl_cmd) @@ -406,6 +429,18 @@ static int rtl_download_firmware(struct hci_dev *hdev, data += RTL_FRAG_LEN; } + skb = btrtl_read_local_version(hdev); + if (IS_ERR(skb)) { + ret = PTR_ERR(skb); + rtl_dev_err(hdev, "read local version failed"); + goto out; + } + + rp = (struct hci_rp_read_local_version *)skb->data; + rtl_dev_info(hdev, "rtl: fw version 0x%04x%04x", + __le16_to_cpu(rp->hci_rev), __le16_to_cpu(rp->lmp_subver)); + kfree_skb(skb); + out: kfree(dl_cmd); return ret; @@ -484,27 +519,6 @@ static int btrtl_setup_rtl8723b(struct hci_dev *hdev, return ret; } -static struct sk_buff *btrtl_read_local_version(struct hci_dev *hdev) -{ - struct sk_buff *skb; - - skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, - HCI_INIT_TIMEOUT); - if (IS_ERR(skb)) { - rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION failed (%ld)\n", - PTR_ERR(skb)); - return skb; - } - - if (skb->len != sizeof(struct hci_rp_read_local_version)) { - rtl_dev_err(hdev, "HCI_OP_READ_LOCAL_VERSION event length mismatch\n"); - kfree_skb(skb); - return ERR_PTR(-EIO); - } - - return skb; -} - void btrtl_free(struct btrtl_device_info *btrtl_dev) { kfree(btrtl_dev->fw_data); -- 2.21.0