Commit 7b57b2dd authored by Kalle Valo's avatar Kalle Valo

ath11k: create a common function to request all firmware files

To avoid duplicating the logic how the full firmware path is created create a
common function ath11k_core_firmware_request() and convert also qmi.c to use it.

Also remove a useless info print, it's more like a debug message anyway.

No functional changes. Compile tested only.
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1592316055-24958-7-git-send-email-kvalo@codeaurora.org
parent 3b94ae4c
...@@ -48,9 +48,9 @@ static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name, ...@@ -48,9 +48,9 @@ static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
return 0; return 0;
} }
static const struct firmware *ath11k_fetch_fw_file(struct ath11k_base *ab, const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
const char *dir, const char *dir,
const char *file) const char *file)
{ {
char filename[100]; char filename[100];
const struct firmware *fw; const struct firmware *fw;
...@@ -63,14 +63,13 @@ static const struct firmware *ath11k_fetch_fw_file(struct ath11k_base *ab, ...@@ -63,14 +63,13 @@ static const struct firmware *ath11k_fetch_fw_file(struct ath11k_base *ab,
dir = "."; dir = ".";
snprintf(filename, sizeof(filename), "%s/%s", dir, file); snprintf(filename, sizeof(filename), "%s/%s", dir, file);
ret = firmware_request_nowarn(&fw, filename, ab->dev);
ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot fw request '%s': %d\n",
filename, ret);
ret = firmware_request_nowarn(&fw, filename, ab->dev);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ath11k_warn(ab, "Downloading BDF: %s, size: %zu\n",
filename, fw->size); ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot firmware request %s size %zu\n",
filename, fw->size);
return fw; return fw;
} }
...@@ -176,9 +175,9 @@ static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab, ...@@ -176,9 +175,9 @@ static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab,
int ret, ie_id; int ret, ie_id;
if (!bd->fw) if (!bd->fw)
bd->fw = ath11k_fetch_fw_file(ab, bd->fw = ath11k_core_firmware_request(ab,
ab->hw_params.fw.dir, ab->hw_params.fw.dir,
filename); filename);
if (IS_ERR(bd->fw)) if (IS_ERR(bd->fw))
return PTR_ERR(bd->fw); return PTR_ERR(bd->fw);
...@@ -268,9 +267,9 @@ static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab, ...@@ -268,9 +267,9 @@ static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab,
static int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab, static int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab,
struct ath11k_board_data *bd) struct ath11k_board_data *bd)
{ {
bd->fw = ath11k_fetch_fw_file(ab, bd->fw = ath11k_core_firmware_request(ab,
ab->hw_params.fw.dir, ab->hw_params.fw.dir,
ATH11K_DEFAULT_BOARD_FILE); ATH11K_DEFAULT_BOARD_FILE);
if (IS_ERR(bd->fw)) if (IS_ERR(bd->fw))
return PTR_ERR(bd->fw); return PTR_ERR(bd->fw);
......
...@@ -861,6 +861,10 @@ void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd); ...@@ -861,6 +861,10 @@ void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd);
void ath11k_core_halt(struct ath11k *ar); void ath11k_core_halt(struct ath11k *ar);
const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
const char *dir,
const char *file);
static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state) static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state)
{ {
switch (state) { switch (state) {
......
...@@ -1790,8 +1790,6 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1790,8 +1790,6 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
struct qmi_wlanfw_bdf_download_req_msg_v01 *req, struct qmi_wlanfw_bdf_download_req_msg_v01 *req,
void __iomem *bdf_addr) void __iomem *bdf_addr)
{ {
struct device *dev = ab->dev;
char filename[ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE];
const struct firmware *fw_entry; const struct firmware *fw_entry;
struct ath11k_board_data bd; struct ath11k_board_data bd;
u32 fw_size; u32 fw_size;
...@@ -1812,11 +1810,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1812,11 +1810,11 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
ath11k_core_free_bdf(ab, &bd); ath11k_core_free_bdf(ab, &bd);
break; break;
case ATH11K_QMI_FILE_TYPE_CALDATA: case ATH11K_QMI_FILE_TYPE_CALDATA:
snprintf(filename, sizeof(filename), fw_entry = ath11k_core_firmware_request(ab, ab->hw_params.fw.dir,
"%s/%s", ab->hw_params.fw.dir, ATH11K_QMI_DEFAULT_CAL_FILE_NAME); ATH11K_QMI_DEFAULT_CAL_FILE_NAME);
ret = request_firmware(&fw_entry, filename, dev);
if (ret) { if (ret) {
ath11k_warn(ab, "qmi failed to load CAL: %s\n", filename); ath11k_warn(ab, "failed to load %s: %d\n",
ATH11K_QMI_DEFAULT_CAL_FILE_NAME, ret);
goto out; goto out;
} }
...@@ -1825,8 +1823,6 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1825,8 +1823,6 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
memcpy_toio(bdf_addr + ATH11K_QMI_CALDATA_OFFSET, memcpy_toio(bdf_addr + ATH11K_QMI_CALDATA_OFFSET,
fw_entry->data, fw_size); fw_entry->data, fw_size);
ath11k_info(ab, "qmi downloading BDF: %s, size: %zu\n",
filename, fw_entry->size);
release_firmware(fw_entry); release_firmware(fw_entry);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment