Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp395983ybe; Wed, 4 Sep 2019 22:48:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWR3up3tYKN3uK1gcClQmdz6zKE7FPfgkz2mRliK5rtceGzihVwUO5BObeeysBjkby+ibe X-Received: by 2002:a63:7e17:: with SMTP id z23mr1604024pgc.14.1567662539245; Wed, 04 Sep 2019 22:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567662539; cv=none; d=google.com; s=arc-20160816; b=iMDPnXkpjoZAoisn9WcQovjcWjdFqIUydqReujn7K9Z3vRjU3mhJAM+K5Mrlp1qzDu f/cZ8tA4afdPLSWIeYJRJgczZvAaKcTF073C9wwyMpZTvgbIw/uXbj3mLPG2DxCQSRrJ sgXF5p/YAsGLrKnUTV4LspHQcDt62EJBjIDyFdmxP/QDqWErFy1quEkDd19Ya12k6uai fasl008dnZhk+jhRmmmAhPyrel9XAeHDjtqQe+/o0wqeonfT5cNCkxjfpuY36CT0jmCo 0NTnGR+MXo+ImrsjGzZmN1caIueYjaRSJiZWYQS5ToJhLDeGyL6Q36+7eSUpEtgML+RX S8Kw== 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=fiUsKyTFkvdIJxrw6uVJaz1ALSS5M5KnFHHvQGJlOwY=; b=CY6fmSNUb/y/ByNeHgUcrl64JixH6sIQjay1VFSR/bwvVuECQG+Oqt2AZnyEM8gmYv IqD5hjM0jI6VsXfAnadxI4jF3F2N86QAgNNzaMro5ZHEkhaqLT1e7Ok0bv3Uu401hXXM c81Fk7HG1b5cToAKJj7GC9/P+egmUPTV3x0L+FA2IJnSsx3S+XfBrlJbLIYsSs8eV4B4 /jIXtsbk2lngHgViEOzO0HolhZwn9ALzf70kHxp2uuye7fuW2pAF1XOt3D9ivD+NESGM q57HMgK5OX0fesHQ3hDNkgGncvhtKI2vFokgIHgKHfVRNMj5UKe0Q/AHH5OMwQgMM5Ke jU/w== 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 f1si1064247plt.277.2019.09.04.22.48.14; Wed, 04 Sep 2019 22:48:59 -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 S1726119AbfIEFWO (ORCPT + 99 others); Thu, 5 Sep 2019 01:22:14 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:33912 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbfIEFWO (ORCPT ); Thu, 5 Sep 2019 01:22:14 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x855M2vq018985, 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 x855M2vq018985 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 5 Sep 2019 13:22:02 +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; Thu, 5 Sep 2019 13:22:01 +0800 From: To: , , , CC: , Subject: [PATCH v2] Bluetooth: btrtl: Fix an issue that failing to download the FW which size is over 32K bytes Date: Thu, 5 Sep 2019 13:21:57 +0800 Message-ID: <20190905052157.2052-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. When firmware patch length is over 32K, "dl_cmd->index" may >= 0x80. It will be thought as "data end" that download process will not complete. However, driver should recount the index from 1. Signed-off-by: Max Chou --- Changes in v2: - Added the comment for commit message - Remove the extra variable drivers/bluetooth/btrtl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 0354e93e7a7c..bf3c02be6930 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -401,7 +401,11 @@ 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) + dl_cmd->index = (i & 0x7f) + 1; + else + dl_cmd->index = i; + if (i == (frag_num - 1)) { dl_cmd->index |= 0x80; /* data end */ frag_len = fw_len % RTL_FRAG_LEN; -- 2.17.1