return ret;
}
-static int tb_switch_nvm_add(struct tb_switch *sw)
+static int tb_switch_nvm_init(struct tb_switch *sw)
{
struct tb_nvm *nvm;
int ret;
if (ret)
goto err_nvm;
+ sw->nvm = nvm;
+ return 0;
+
+err_nvm:
+ tb_sw_dbg(sw, "NVM upgrade disabled\n");
+ sw->no_nvm_upgrade = true;
+ if (!IS_ERR(nvm))
+ tb_nvm_free(nvm);
+
+ return ret;
+}
+
+static int tb_switch_nvm_add(struct tb_switch *sw)
+{
+ struct tb_nvm *nvm = sw->nvm;
+ int ret;
+
+ if (!nvm)
+ return 0;
+
/*
* If the switch is in safe-mode the only accessible portion of
* the NVM is the non-active one where userspace is expected to
goto err_nvm;
}
- sw->nvm = nvm;
return 0;
err_nvm:
tb_sw_dbg(sw, "NVM upgrade disabled\n");
sw->no_nvm_upgrade = true;
- if (!IS_ERR(nvm))
- tb_nvm_free(nvm);
+ tb_nvm_free(nvm);
return ret;
}
return ret;
}
+ ret = tb_switch_nvm_init(sw);
+ if (ret)
+ return ret;
+
if (!sw->safe_mode) {
tb_switch_credits_init(sw);