}
static const struct firmware *typhoon_fw;
+static u8 *typhoon_fw_image;
static int
typhoon_request_firmware(struct typhoon *tp)
memcmp(typhoon_fw->data, "TYPHOON", 8)) {
printk(KERN_ERR "%s: Invalid firmware image\n",
tp->name);
- release_firmware(typhoon_fw);
- typhoon_fw = NULL;
- return -EINVAL;
+ err = -EINVAL;
+ goto out_err;
+ }
+
+ typhoon_fw_image = kmalloc(typhoon_fw->size, GFP_KERNEL);
+ if (!typhoon_fw_image) {
+ err = -ENOMEM;
+ goto out_err;
}
return 0;
+
+out_err:
+ release_firmware(typhoon_fw);
+ typhoon_fw = NULL;
+ return err;
}
static int
int i;
int err;
- image_data = typhoon_fw->data;
+ image_data = typhoon_fw_image;
fHdr = (struct typhoon_file_header *) image_data;
err = -ENOMEM;
- image_dma = pci_map_single(pdev, (u8 *) typhoon_fw->data,
+ image_dma = pci_map_single(pdev, (u8 *) image_data,
typhoon_fw->size, PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(pdev, image_dma)) {
printk(KERN_ERR "%s: no DMA mem for firmware\n", tp->name);
iowrite32(load_addr,
ioaddr + TYPHOON_REG_BOOT_DEST_ADDR);
iowrite32(0, ioaddr + TYPHOON_REG_BOOT_DATA_HI);
- iowrite32(image_dma + (image_data - typhoon_fw->data),
+ iowrite32(image_dma + (image_data - typhoon_fw_image),
ioaddr + TYPHOON_REG_BOOT_DATA_LO);
typhoon_post_pci_writes(ioaddr);
iowrite32(TYPHOON_BOOTCMD_SEG_AVAILABLE,
static void __exit
typhoon_cleanup(void)
{
- if (typhoon_fw)
+ if (typhoon_fw) {
+ kfree(typhoon_fw_image);
release_firmware(typhoon_fw);
+ }
pci_unregister_driver(&typhoon_driver);
}