Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp354585ybe; Mon, 2 Sep 2019 02:43:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiFRnhEhhJFOX9S4YmJ5piWty3zXCAzS7/heiAoNR34KvIKcTXUxLNMS8RXvyPBRR0fW1k X-Received: by 2002:a17:902:758a:: with SMTP id j10mr21506644pll.233.1567417397770; Mon, 02 Sep 2019 02:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567417397; cv=none; d=google.com; s=arc-20160816; b=WVEemO3TNF/5gkN0RmdZ9creqTLXv0g9OE9N738sxpA57dwKuUJWJDyz0LcakaAHoN lUtxMY+oLXzU4Ly9B2HKPLepozuoVAsZzc5CBf7sl4cY2e2xjUpIYNRWNNUEreF6zPu6 CSSW7OYeP1sqf0Yy5j+tlFIu3KZlAN3mWMN8e+WBUspOeP6U3+cYKPrB0RHsELsCPQRr f3GFkl/mYt7FqyrVntUaEczLbFpLo5I8o5NZKmtTWhQn0UG6OTLVZNn3ui46gTLMbLNK MjCfsQdJLOUGdBfucMcUh2WkzYwggSotKZKho04K//P7nwZfCtHSdsC32MhCmPN8Gly0 qlvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:authenticated-by; bh=x3XZ9kG4mUF5lhVgUAChtiiigY03Z0OLZ81w7Sb1j4Q=; b=dHn5uGsXQ/zqbsQ8gcTH7KDcUUkiIFPcGZNF6ueTWb/ORmguDCWZzscC+PslrolA3H zOpWaww6a0TVG9w0438K0hjyptvqnQ4h30sTWYxkgJYadh+l+2katHX/jUJAq3ySuUIw 7JYBZUdJhaN+wxQY2BjQohy2yIs2cYxMiQbiixWCLFAAa2X2/zXIVOvGtH1dKVEzncU8 vOcXaX/fUzLXgnCUdjtmriTd9d9E8j4Ghis6RQA2VaqE57Attu9w4NFqbqDbRTXlGhYt 88PSOMqoKxJezojHZgx8CW210ThOAOPJogyoGlX9lgv08Rl+p5opI9SrYWRO1ieamx39 cBHQ== 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 d6si3078726plo.280.2019.09.02.02.42.47; Mon, 02 Sep 2019 02:43:17 -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 S1730910AbfIBJIZ (ORCPT + 99 others); Mon, 2 Sep 2019 05:08:25 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:51450 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729804AbfIBJIZ (ORCPT ); Mon, 2 Sep 2019 05:08:25 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x8298DeO009993, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCASV01.realtek.com.tw[172.21.6.18]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x8298DeO009993 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 2 Sep 2019 17:08:14 +0800 Received: from localhost.localdomain (172.21.83.238) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.468.0; Mon, 2 Sep 2019 17:08:13 +0800 From: To: , , , CC: , Subject: [PATCH] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes Date: Mon, 2 Sep 2019 17:08:09 +0800 Message-ID: <20190902090809.3409-1-max.chou@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.83.238] Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Max Chou Fix the issue that when the FW size is 32K+, it will fail for the download process because of the incorrect index. Signed-off-by: Max Chou --- drivers/bluetooth/btrtl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 0354e93e7a7c..215896af0259 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -389,6 +389,7 @@ static int rtl_download_firmware(struct hci_dev *hdev, int frag_len = RTL_FRAG_LEN; int ret = 0; int i; + int j; struct sk_buff *skb; struct hci_rp_read_local_version *rp; @@ -401,7 +402,12 @@ static int rtl_download_firmware(struct hci_dev *hdev, BT_DBG("download fw (%d/%d)", i, frag_num); - dl_cmd->index = i; + if (i > 0x7f) + j = (i & 0x7f) + 1; + else + j = i; + + dl_cmd->index = j; if (i == (frag_num - 1)) { dl_cmd->index |= 0x80; /* data end */ frag_len = fw_len % RTL_FRAG_LEN; -- 2.17.1