[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#501152: binary firmware in drivers/net/starfire_firmware.h



Here's a patch for starfire to make it use request_firmware.  This is
compile-tested only.  The firmware files can be produced by writing out
the firmware_rx and firmware_tx arrays as 32-bit little-endian values.
However, the licence remains a problem.

Ben.

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 4a12477..3e433cb 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1306,6 +1306,7 @@ config ADAPTEC_STARFIRE
 	depends on NET_PCI && PCI
 	select CRC32
 	select MII
+	select FW_LOADER
 	help
 	  Say Y here if you have an Adaptec Starfire (or DuraLAN) PCI network
 	  adapter. The DuraLAN chip is used on the 64 bit PCI boards from
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 7b7b171..73394d9 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -42,11 +42,11 @@
 #include <linux/mii.h>
 #include <linux/if_vlan.h>
 #include <linux/mm.h>
+#include <linux/firmware.h>
 #include <asm/processor.h>		/* Processor type for cache alignment. */
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
-#include "starfire_firmware.h"
 /*
  * The current frame processor firmware fails to checksum a fragment
  * of length 1. If and when this is fixed, the #define below can be removed.
@@ -224,6 +224,8 @@ MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
 MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
+MODULE_FIRMWARE("starfire/gfp_rx.bin");
+MODULE_FIRMWARE("starfire/gfp_tx.bin");
 
 module_param(max_interrupt_work, int, 0);
 module_param(mtu, int, 0);
@@ -948,12 +950,21 @@ static int netdev_open(struct net_device *dev)
 	void __iomem *ioaddr = np->base;
 	int i, retval;
 	size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;
+	const struct firmware *fw_rx, *fw_tx;
+	const __le32 *fw_data;
 
 	/* Do we ever need to reset the chip??? */
 
-	retval = request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev);
+	retval = request_firmware(&fw_rx, "starfire/gfp_rx.bin", &np->pci_dev->dev);
 	if (retval)
 		return retval;
+	retval = request_firmware(&fw_tx, "starfire/gfp_tx.bin", &np->pci_dev->dev);
+	if (retval)
+		goto out_release_fw_rx;
+	
+	retval = request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev);
+	if (retval)
+		goto out_release_fw_tx;
 
 	/* Disable the Rx and Tx, and reset the chip. */
 	writel(0, ioaddr + GenCtrl);
@@ -1084,10 +1095,12 @@ static int netdev_open(struct net_device *dev)
 #endif /* VLAN_SUPPORT */
 
 	/* Load Rx/Tx firmware into the frame processors */
-	for (i = 0; i < FIRMWARE_RX_SIZE * 2; i++)
-		writel(firmware_rx[i], ioaddr + RxGfpMem + i * 4);
-	for (i = 0; i < FIRMWARE_TX_SIZE * 2; i++)
-		writel(firmware_tx[i], ioaddr + TxGfpMem + i * 4);
+	fw_data = (const __le32 *)fw_rx->data;
+	for (i = 0; i < fw_rx->size / 4; i++)
+		writel(le32_to_cpu(fw_data[i]), ioaddr + RxGfpMem + i * 4);
+	fw_data = (const __le32 *)fw_tx->data;
+	for (i = 0; i < fw_tx->size / 4; i++)
+		writel(le32_to_cpu(fw_data[i]), ioaddr + TxGfpMem + i * 4);
 	if (enable_hw_cksum)
 		/* Enable the Rx and Tx units, and the Rx/Tx frame processors. */
 		writel(TxEnable|TxGFPEnable|RxEnable|RxGFPEnable, ioaddr + GenCtrl);
@@ -1099,7 +1112,11 @@ static int netdev_open(struct net_device *dev)
 		printk(KERN_DEBUG "%s: Done netdev_open().\n",
 		       dev->name);
 
-	return 0;
+out_release_fw_tx:
+	release_firmware(fw_tx);
+out_release_fw_rx:
+	release_firmware(fw_rx);
+	return retval;
 }
 
 
--- END ---

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: