From: Kiran K <kiran.k@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com,
kiraank@gmail.com, Kiran K <kiran.k@intel.com>,
Amit K Bag <amit.k.bag@intel.com>,
Raghuram Hegde <raghuram.hegde@intel.com>
Subject: [PATCH v2 3/5] Bluetooth: btintel: Refactor firmware payload download code
Date: Fri, 3 Jul 2020 12:42:10 +0530 [thread overview]
Message-ID: <20200703071212.17046-3-kiran.k@intel.com> (raw)
In-Reply-To: <20200703071212.17046-1-kiran.k@intel.com>
Move firmware payload download code to a separate function to
enhance readability and reusability
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
Reviewed-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Reviewed-by: Sathish Narasimman <Sathish.Narasimman@intel.com>
Reviewed-by: Srivatsa Ravishankar <ravishankar.srivatsa@intel.com>
---
Changes in v2:
- Avoid exporting new public function for firmware download
- Move firmware payload download code to a new function
Changes in v1:
- Move firmware payload download code to a new function
drivers/bluetooth/btintel.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index ffc888c4e9e3..2cb55a97598c 100644
--- a/drivers/bluetooth/btintel.c
+++ b/drivers/bluetooth/btintel.c
@@ -19,6 +19,7 @@
#define VERSION "0.1"
#define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}})
+#define RSA_HEADER_LEN 644
int btintel_check_bdaddr(struct hci_dev *hdev)
{
@@ -682,8 +683,9 @@ static int btintel_sfi_rsa_header_secure_send(struct hci_dev *hdev,
return err;
}
-int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw,
- u32 *boot_param)
+static int btintel_download_firmware_payload(struct hci_dev *hdev,
+ const struct firmware *fw,
+ u32 *boot_param, size_t offset)
{
int err;
const u8 *fw_ptr;
@@ -693,8 +695,9 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw,
if (err)
goto done;
- fw_ptr = fw->data + 644;
+ fw_ptr = fw->data + offset;
frag_len = 0;
+ err = -EINVAL;
while (fw_ptr - fw->data < fw->size) {
struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len);
@@ -740,6 +743,19 @@ int btintel_download_firmware(struct hci_dev *hdev, const struct firmware *fw,
done:
return err;
}
+
+int btintel_download_firmware(struct hci_dev *hdev,
+ const struct firmware *fw,
+ u32 *boot_param)
+{
+ int err;
+
+ err = btintel_sfi_rsa_header_secure_send(hdev, fw);
+ if (err)
+ return err;
+
+ return btintel_download_firmware_payload(hdev, fw, boot_param, RSA_HEADER_LEN);
+}
EXPORT_SYMBOL_GPL(btintel_download_firmware);
void btintel_reset_to_bootloader(struct hci_dev *hdev)
--
2.17.1
next prev parent reply other threads:[~2020-07-03 7:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 7:12 [PATCH v2 1/5] Bluetooth: btintel: Make controller version read generic Kiran K
2020-07-03 7:12 ` [PATCH v2 2/5] Bluetooth: btintel: Refactor firmware header download sequence Kiran K
2020-07-03 7:12 ` Kiran K [this message]
2020-07-13 19:16 ` [PATCH v2 3/5] Bluetooth: btintel: Refactor firmware payload download code Marcel Holtmann
2020-07-03 7:12 ` [PATCH v2 4/5] Bluetooth: btintel: Define tlv structure for new generation Controllers Kiran K
2020-07-13 19:18 ` Marcel Holtmann
2020-07-03 7:12 ` [PATCH v2 5/5] Bluetooth: btintel: Parse controller information present in TLV format Kiran K
2020-07-13 19:26 ` Marcel Holtmann
2020-07-13 19:14 ` [PATCH v2 1/5] Bluetooth: btintel: Make controller version read generic Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200703071212.17046-3-kiran.k@intel.com \
--to=kiran.k@intel.com \
--cc=amit.k.bag@intel.com \
--cc=chethan.tumkur.narayan@intel.com \
--cc=kiraank@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=raghuram.hegde@intel.com \
--cc=ravishankar.srivatsa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).