if (offset + section_size > bcf_len) {
dev_err(dev, "fw %s: bad section #%zu, "
"end (@%zu) beyond EOF (@%zu)\n",
- i2400m->bus_fw_name, section,
+ i2400m->fw_name, section,
offset + section_size, bcf_len);
ret = -EINVAL;
goto error_section_beyond_eof;
&ack, sizeof(ack), I2400M_BM_CMD_RAW);
if (ret < 0) {
dev_err(dev, "fw %s: section #%zu (@%zu %zu B) "
- "failed %d\n", i2400m->bus_fw_name, section,
+ "failed %d\n", i2400m->fw_name, section,
offset, sizeof(*bh) + data_size, (int) ret);
goto error_send;
}
if (result < 0)
dev_err(dev, "fw %s: non-signed download "
"initialization failed: %d\n",
- i2400m->bus_fw_name, result);
+ i2400m->fw_name, result);
} else if (i2400m->sboot == 0
&& (module_id & I2400M_BCF_MOD_ID_POKES)) {
/* non-signed boot process with pokes, nothing to do */
if (result < 0)
dev_err(dev, "fw %s: signed boot download "
"initialization failed: %d\n",
- i2400m->bus_fw_name, result);
+ i2400m->fw_name, result);
}
return result;
}
if (bcf_size < sizeof(*bcf)) { /* big enough header? */
dev_err(dev, "firmware %s too short: "
"%zu B vs %zu (at least) expected\n",
- i2400m->bus_fw_name, bcf_size, sizeof(*bcf));
+ i2400m->fw_name, bcf_size, sizeof(*bcf));
goto error;
}
if (bcf_size != size) { /* annoyingly paranoid */
dev_err(dev, "firmware %s: bad size, got "
"%zu B vs %u expected\n",
- i2400m->bus_fw_name, bcf_size, size);
+ i2400m->fw_name, bcf_size, size);
goto error;
}
if (module_type != 6) { /* built for the right hardware? */
dev_err(dev, "bad fw %s: unexpected module type 0x%x; "
- "aborting\n", i2400m->bus_fw_name, module_type);
+ "aborting\n", i2400m->fw_name, module_type);
goto error;
}
result = 0;
if (module_vendor != 0x8086)
dev_err(dev, "bad fw %s? unexpected vendor 0x%04x\n",
- i2400m->bus_fw_name, module_vendor);
+ i2400m->fw_name, module_vendor);
if (date < 0x20080300)
dev_err(dev, "bad fw %s? build date too old %08x\n",
- i2400m->bus_fw_name, date);
+ i2400m->fw_name, date);
error:
return result;
}
goto error_dev_rebooted;
if (ret < 0) {
dev_err(dev, "fw %s: download failed: %d\n",
- i2400m->bus_fw_name, ret);
+ i2400m->fw_name, ret);
goto error_dnload_bcf;
}
if (ret < 0) {
dev_err(dev, "fw %s: "
"download finalization failed: %d\n",
- i2400m->bus_fw_name, ret);
+ i2400m->fw_name, ret);
goto error_dnload_finalize;
}
d_printf(2, dev, "fw %s successfully uploaded\n",
- i2400m->bus_fw_name);
+ i2400m->fw_name);
i2400m->boot_mode = 0;
error_dnload_finalize:
error_dnload_bcf:
*/
int i2400m_dev_bootstrap(struct i2400m *i2400m, enum i2400m_bri flags)
{
- int ret = 0;
+ int ret = 0, itr = 0;
struct device *dev = i2400m_dev(i2400m);
const struct firmware *fw;
const struct i2400m_bcf_hdr *bcf; /* Firmware data */
+ const char *fw_name;
d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
+
/* Load firmware files to memory. */
- ret = request_firmware(&fw, i2400m->bus_fw_name, dev);
- if (ret) {
- dev_err(dev, "fw %s: request failed: %d\n",
- i2400m->bus_fw_name, ret);
- goto error_fw_req;
+ itr = 0;
+ while(1) {
+ fw_name = i2400m->bus_fw_names[itr];
+ if (fw_name == NULL) {
+ dev_err(dev, "Could not find a usable firmware image\n");
+ ret = -ENOENT;
+ goto error_no_fw;
+ }
+ ret = request_firmware(&fw, fw_name, dev);
+ if (ret == 0)
+ break; /* got it */
+ if (ret < 0)
+ dev_err(dev, "fw %s: cannot load file: %d\n",
+ fw_name, ret);
+ itr++;
}
- bcf = (void *) fw->data;
+ bcf = (void *) fw->data;
+ i2400m->fw_name = fw_name;
ret = i2400m_fw_check(i2400m, bcf, fw->size);
if (ret < 0)
goto error_fw_bad;
ret = i2400m_fw_dnload(i2400m, bcf, fw->size, flags);
error_fw_bad:
release_firmware(fw);
-error_fw_req:
+error_no_fw:
d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
return ret;
}
};
-/* Firmware version we request when pulling the fw image file */
-#define I2400M_FW_VERSION "1.4"
-
-
/**
* i2400m_reset_type - methods to reset a device
*
* The caller to this function will check if the response is a
* barker that indicates the device going into reset mode.
*
- * @bus_fw_name: [fill] name of the firmware image (in most cases,
- * they are all the same for a single release, except that they
- * have the type of the bus embedded in the name (eg:
- * i2400m-fw-X-VERSION.sbcf, where X is the bus name).
+ * @bus_fw_names: [fill] a NULL-terminated array with the names of the
+ * firmware images to try loading. This is made a list so we can
+ * support backward compatibility of firmware releases (eg: if we
+ * can't find the default v1.4, we try v1.3). In general, the name
+ * should be i2400m-fw-X-VERSION.sbcf, where X is the bus name.
+ * The list is tried in order and the first one that loads is
+ * used. The fw loader will set i2400m->fw_name to point to the
+ * active firmware image.
*
* @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC
* address provided in boot mode is kind of broken and needs to
* These have to be in a separate directory, a child of
* (wimax_dev->debugfs_dentry) so they can be removed when the
* module unloads, as we don't keep each dentry.
+ *
+ * @fw_name: name of the firmware image that is currently being used.
*/
struct i2400m {
struct wimax_dev wimax_dev; /* FIRST! See doc */
size_t, int flags);
ssize_t (*bus_bm_wait_for_ack)(struct i2400m *,
struct i2400m_bootrom_header *, size_t);
- const char *bus_fw_name;
+ const char **bus_fw_names;
unsigned bus_bm_mac_addr_impaired:1;
spinlock_t tx_lock; /* protect TX state */
struct sk_buff *wake_tx_skb;
struct dentry *debugfs_dentry;
+ const char *fw_name; /* name of the current firmware image */
};
/* Our firmware file name */
-#define I2400MU_FW_FILE_NAME "i2400m-fw-usb-" I2400M_FW_VERSION ".sbcf"
+static const char *i2400mu_bus_fw_names[] = {
+#define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf"
+ I2400MU_FW_FILE_NAME_v1_4,
+#define I2400MU_FW_FILE_NAME_v1_3 "i2400m-fw-usb-1.3.sbcf"
+ I2400MU_FW_FILE_NAME_v1_3,
+ NULL,
+};
+
static
int i2400mu_bus_dev_start(struct i2400m *i2400m)
i2400m->bus_reset = i2400mu_bus_reset;
i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send;
i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack;
- i2400m->bus_fw_name = I2400MU_FW_FILE_NAME;
+ i2400m->bus_fw_names = i2400mu_bus_fw_names;
i2400m->bus_bm_mac_addr_impaired = 0;
#ifdef CONFIG_PM
MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
MODULE_DESCRIPTION("Intel 2400M WiMAX networking for USB");
MODULE_LICENSE("GPL");
-MODULE_FIRMWARE(I2400MU_FW_FILE_NAME);
+MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_4);
+MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_3);