/* On exit, the firmware will have been freed from the fw list  */
static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
/* On exit, the firmware will have been freed from the fw list  */
static int ipw2100_fw_download(struct ipw2100_priv *priv, struct ipw2100_fw *fw)
{
	unsigned int addr;
	unsigned short len;
	const unsigned char *firmware_data = fw->fw.data;
	unsigned int firmware_data_left = fw->fw.size;
	while (firmware_data_left > 0) {
		addr = *(u32 *) (firmware_data);
		firmware_data += 4;
		firmware_data_left -= 4;
		len = *(u16 *) (firmware_data);
		firmware_data += 2;
		firmware_data_left -= 2;
		if (len > 32) {
			printk(KERN_ERR DRV_NAME ": "
			       "Invalid firmware run-length of %d bytes\n",
			       len);
			return -EINVAL;
		}
		write_nic_memory(priv->net_dev, addr, len, firmware_data);
		firmware_data += len;
		firmware_data_left -= len;
	}
	return 0;
}