From 410a5105f5ad7d89bdbd1142a6b27937696b858f Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 22 Feb 2009 19:25:27 +0000 Subject: [PATCH 09/18] typhoon: Use request_firmware() Based on a patch by Jaswinder Singh . Compile-tested only. --- drivers/net/Kconfig | 2 +- drivers/net/typhoon.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index c639aea..334472d 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -733,7 +733,7 @@ config VORTEX config TYPHOON tristate "3cr990 series \"Typhoon\" support" depends on NET_VENDOR_3COM && PCI - depends on BROKEN + select FW_LOADER select CRC32 ---help--- This option enables driver support for the 3cr990 series of cards: diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index 3af9a95..83226a2 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c @@ -129,16 +129,18 @@ static const int multicast_filter_limit = 32; #include #include #include +#include #include "typhoon.h" -#include "typhoon-firmware.h" static char version[] __devinitdata = "typhoon.c: version " DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; +#define FIRMWARE_NAME "3com/typhoon.bin" MODULE_AUTHOR("David Dillow "); MODULE_VERSION(DRV_MODULE_VERSION); MODULE_LICENSE("GPL"); +MODULE_FIRMWARE(FIRMWARE_NAME); MODULE_DESCRIPTION("3Com Typhoon Family (3C990, 3CR990, and variants)"); MODULE_PARM_DESC(rx_copybreak, "Packets smaller than this are copied and " "the buffer given back to the NIC. Default " @@ -1349,9 +1351,10 @@ typhoon_download_firmware(struct typhoon *tp) { void __iomem *ioaddr = tp->ioaddr; struct pci_dev *pdev = tp->pdev; - struct typhoon_file_header *fHdr; - struct typhoon_section_header *sHdr; - u8 *image_data; + const struct firmware *fw; + const struct typhoon_file_header *fHdr; + const struct typhoon_section_header *sHdr; + const u8 *image_data; void *dpage; dma_addr_t dpage_dma; __sum16 csum; @@ -1365,11 +1368,18 @@ typhoon_download_firmware(struct typhoon *tp) int i; int err; + err = request_firmware(&fw, FIRMWARE_NAME, &tp->pdev->dev); + if (err) { + printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n", + tp->name, FIRMWARE_NAME); + return err; + } + err = -EINVAL; - fHdr = (struct typhoon_file_header *) typhoon_firmware_image; + fHdr = (struct typhoon_file_header *) fw->data; image_data = (u8 *) fHdr; - if(memcmp(fHdr->tag, "TYPHOON", 8)) { + if(fw->size < sizeof(*fHdr) || memcmp(fHdr->tag, "TYPHOON", 8)) { printk(KERN_ERR "%s: Invalid firmware image!\n", tp->name); goto err_out; } @@ -1491,6 +1501,7 @@ err_out_irq: pci_free_consistent(pdev, PAGE_SIZE, dpage, dpage_dma); err_out: + release_firmware(fw); return err; } -- 1.6.1.3