Commit 34d9fc80 authored by Kalle Valo's avatar Kalle Valo

ath11k: don't use defines for hw specific firmware directories

The downside of using defines in struct ath11k_hw_params.fw.dir is that it's
easy to get it wrong as the full path is not visible. So drop the use of
defines and instead create the patch runtime using a static inline function
ath11k_core_create_firmware_path(). Hopefully this reduces the chances of using
incorrect firmware path.

No functional changes. Compile tested only.
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1592316055-24958-8-git-send-email-kvalo@codeaurora.org
parent 7b57b2dd
...@@ -22,7 +22,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { ...@@ -22,7 +22,7 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.hw_rev = ATH11K_HW_IPQ8074, .hw_rev = ATH11K_HW_IPQ8074,
.name = "ipq8074 hw2.0", .name = "ipq8074 hw2.0",
.fw = { .fw = {
.dir = IPQ8074_FW_DIR, .dir = "IPQ8074/hw2.0",
.board_size = IPQ8074_MAX_BOARD_DATA_SZ, .board_size = IPQ8074_MAX_BOARD_DATA_SZ,
.cal_size = IPQ8074_MAX_CAL_DATA_SZ, .cal_size = IPQ8074_MAX_CAL_DATA_SZ,
}, },
...@@ -49,27 +49,23 @@ static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name, ...@@ -49,27 +49,23 @@ static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name,
} }
const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab, const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
const char *dir,
const char *file) const char *file)
{ {
char filename[100];
const struct firmware *fw; const struct firmware *fw;
char path[100];
int ret; int ret;
if (file == NULL) if (file == NULL)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
if (dir == NULL) ath11k_core_create_firmware_path(ab, file, path, sizeof(path));
dir = ".";
snprintf(filename, sizeof(filename), "%s/%s", dir, file); ret = firmware_request_nowarn(&fw, path, ab->dev);
ret = firmware_request_nowarn(&fw, filename, ab->dev);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot firmware request %s size %zu\n", ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot firmware request %s size %zu\n",
filename, fw->size); path, fw->size);
return fw; return fw;
} }
...@@ -175,9 +171,8 @@ static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab, ...@@ -175,9 +171,8 @@ 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_core_firmware_request(ab, bd->fw = ath11k_core_firmware_request(ab, filename);
ab->hw_params.fw.dir,
filename);
if (IS_ERR(bd->fw)) if (IS_ERR(bd->fw))
return PTR_ERR(bd->fw); return PTR_ERR(bd->fw);
...@@ -267,9 +262,7 @@ static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab, ...@@ -267,9 +262,7 @@ 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_core_firmware_request(ab, bd->fw = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_BOARD_FILE);
ab->hw_params.fw.dir,
ATH11K_DEFAULT_BOARD_FILE);
if (IS_ERR(bd->fw)) if (IS_ERR(bd->fw))
return PTR_ERR(bd->fw); return PTR_ERR(bd->fw);
......
...@@ -862,8 +862,7 @@ void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd); ...@@ -862,8 +862,7 @@ 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 struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab,
const char *dir, const char *filename);
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)
{ {
...@@ -897,4 +896,12 @@ static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif) ...@@ -897,4 +896,12 @@ static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif)
return (struct ath11k_vif *)vif->drv_priv; return (struct ath11k_vif *)vif->drv_priv;
} }
static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab,
const char *filename,
void *buf, size_t buf_len)
{
snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR,
ab->hw_params.fw.dir, filename);
}
#endif /* _CORE_H_ */ #endif /* _CORE_H_ */
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
#define ATH11K_FW_DIR "ath11k" #define ATH11K_FW_DIR "ath11k"
/* IPQ8074 definitions */ /* IPQ8074 definitions */
#define IPQ8074_FW_DIR ATH11K_FW_DIR "/IPQ8074/hw2.0"
#define IPQ8074_MAX_BOARD_DATA_SZ (256 * 1024) #define IPQ8074_MAX_BOARD_DATA_SZ (256 * 1024)
#define IPQ8074_MAX_CAL_DATA_SZ IPQ8074_MAX_BOARD_DATA_SZ #define IPQ8074_MAX_CAL_DATA_SZ IPQ8074_MAX_BOARD_DATA_SZ
......
...@@ -1810,7 +1810,7 @@ ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type, ...@@ -1810,7 +1810,7 @@ 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:
fw_entry = ath11k_core_firmware_request(ab, ab->hw_params.fw.dir, fw_entry = ath11k_core_firmware_request(ab,
ATH11K_QMI_DEFAULT_CAL_FILE_NAME); ATH11K_QMI_DEFAULT_CAL_FILE_NAME);
if (ret) { if (ret) {
ath11k_warn(ab, "failed to load %s: %d\n", ath11k_warn(ab, "failed to load %s: %d\n",
......
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