[PATCH 1/3] Bluetooth: btrtl: try config w/o postfix if postfixed one failed to load

From: icenowy
Date: Fri Apr 22 2022 - 12:03:20 EST


From: Icenowy Zheng <icenowy@xxxxxxxxxx>

We should try the non-prefixed config file name if the prefixed one
failed to load (possibly because of it does not exist).

Add this behavior to firmware-loading routine.

Signed-off-by: Icenowy Zheng <icenowy@xxxxxxxxxx>
---
drivers/bluetooth/btrtl.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 481d488bca0f..1f834513762b 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -699,6 +699,12 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
}
btrtl_dev->cfg_len = rtl_load_file(hdev, cfg_name,
&btrtl_dev->cfg_data);
+ if (postfix && btrtl_dev->cfg_len <= 0) {
+ snprintf(cfg_name, sizeof(cfg_name), "%s.bin",
+ btrtl_dev->ic_info->cfg_name);
+ btrtl_dev->cfg_len = rtl_load_file(hdev, cfg_name,
+ &btrtl_dev->cfg_data);
+ }
if (btrtl_dev->ic_info->config_needed &&
btrtl_dev->cfg_len <= 0) {
rtl_dev_err(hdev, "mandatory config file %s not found",
--
2.35.1