Commit 6f157edb authored by Eliad Peller's avatar Eliad Peller Committed by Kalle Valo

wl18xx: fallback to default conf in case of invalid conf file

If the wl18xx-conf.bin file is missing or invalid (e.g. due
to recent driver change), fallback to default configuration
instead of failing driver load.
Reported-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4aff53ef
...@@ -1375,9 +1375,10 @@ static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver) ...@@ -1375,9 +1375,10 @@ static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
} }
#define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin" #define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin"
static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
static int wl18xx_load_conf_file(struct device *dev, struct wlcore_conf *conf,
struct wl18xx_priv_conf *priv_conf)
{ {
struct wl18xx_priv *priv = wl->priv;
struct wlcore_conf_file *conf_file; struct wlcore_conf_file *conf_file;
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
...@@ -1386,14 +1387,14 @@ static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev) ...@@ -1386,14 +1387,14 @@ static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
if (ret < 0) { if (ret < 0) {
wl1271_error("could not get configuration binary %s: %d", wl1271_error("could not get configuration binary %s: %d",
WL18XX_CONF_FILE_NAME, ret); WL18XX_CONF_FILE_NAME, ret);
goto out_fallback; return ret;
} }
if (fw->size != WL18XX_CONF_SIZE) { if (fw->size != WL18XX_CONF_SIZE) {
wl1271_error("configuration binary file size is wrong, expected %zu got %zu", wl1271_error("configuration binary file size is wrong, expected %zu got %zu",
WL18XX_CONF_SIZE, fw->size); WL18XX_CONF_SIZE, fw->size);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out_release;
} }
conf_file = (struct wlcore_conf_file *) fw->data; conf_file = (struct wlcore_conf_file *) fw->data;
...@@ -1403,7 +1404,7 @@ static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev) ...@@ -1403,7 +1404,7 @@ static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
"expected 0x%0x got 0x%0x", WL18XX_CONF_MAGIC, "expected 0x%0x got 0x%0x", WL18XX_CONF_MAGIC,
conf_file->header.magic); conf_file->header.magic);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out_release;
} }
if (conf_file->header.version != cpu_to_le32(WL18XX_CONF_VERSION)) { if (conf_file->header.version != cpu_to_le32(WL18XX_CONF_VERSION)) {
...@@ -1411,28 +1412,32 @@ static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev) ...@@ -1411,28 +1412,32 @@ static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
"expected 0x%08x got 0x%08x", "expected 0x%08x got 0x%08x",
WL18XX_CONF_VERSION, conf_file->header.version); WL18XX_CONF_VERSION, conf_file->header.version);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out_release;
} }
memcpy(&wl->conf, &conf_file->core, sizeof(wl18xx_conf)); memcpy(conf, &conf_file->core, sizeof(*conf));
memcpy(&priv->conf, &conf_file->priv, sizeof(priv->conf)); memcpy(priv_conf, &conf_file->priv, sizeof(*priv_conf));
goto out; out_release:
release_firmware(fw);
return ret;
}
out_fallback: static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
wl1271_warning("falling back to default config"); {
struct wl18xx_priv *priv = wl->priv;
/* apply driver default configuration */ if (wl18xx_load_conf_file(dev, &wl->conf, &priv->conf) < 0) {
memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf)); wl1271_warning("falling back to default config");
/* apply default private configuration */
memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf));
/* For now we just fallback */ /* apply driver default configuration */
return 0; memcpy(&wl->conf, &wl18xx_conf, sizeof(wl->conf));
/* apply default private configuration */
memcpy(&priv->conf, &wl18xx_default_priv_conf,
sizeof(priv->conf));
}
out: return 0;
release_firmware(fw);
return ret;
} }
static int wl18xx_plt_init(struct wl1271 *wl) static int wl18xx_plt_init(struct wl1271 *wl)
......
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