public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* sungem driver patch testing..
@ 2005-09-11  3:11 Linus Torvalds
  2005-09-11  7:04 ` Willy Tarreau
  2005-09-11 12:03 ` Christoph Hellwig
  0 siblings, 2 replies; 9+ messages in thread
From: Linus Torvalds @ 2005-09-11  3:11 UTC (permalink / raw)
  To: Linux Kernel Mailing List


I've been grepping around for things that do their own PCI ROM mapping and 
do it badly, and one thing that matches that description is the sungem 
ethernet driver on PC's.

If anybody has such a beast, can you please try this patch and report 
whether it works for you? 

		Linus

---
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2817,7 +2817,7 @@ static int gem_ioctl(struct net_device *
 
 #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC))
 /* Fetch MAC address from vital product data of PCI ROM. */
-static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
+static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
 {
 	int this_offset;
 
@@ -2838,35 +2838,27 @@ static void find_eth_addr_in_vpd(void __
 
 		for (i = 0; i < 6; i++)
 			dev_addr[i] = readb(p + i);
-		break;
+		return 1;
 	}
+	return 0;
 }
 
 static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr)
 {
-	u32 rom_reg_orig;
-	void __iomem *p;
-
-	if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) {
-		if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0)
-			goto use_random;
-	}
-
-	pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig);
-	pci_write_config_dword(pdev, pdev->rom_base_reg,
-			       rom_reg_orig | PCI_ROM_ADDRESS_ENABLE);
+	size_t size;
+	void __iomem *p = pci_map_rom(pdev, &size);
 
-	p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024));
-	if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa)
-		find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
+	if (p) {
+			int found;
 
-	if (p != NULL)
-		iounmap(p);
-
-	pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig);
-	return;
+		found = readb(p) == 0x55 &&
+			readb(p + 1) == 0xaa &&
+			find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
+		pci_unmap_rom(pdev, p);
+		if (found)
+			return;
+	}
 
-use_random:
 	/* Sun MAC prefix then 3 random bytes. */
 	dev_addr[0] = 0x08;
 	dev_addr[1] = 0x00;

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-09-11 19:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-11  3:11 sungem driver patch testing Linus Torvalds
2005-09-11  7:04 ` Willy Tarreau
2005-09-11 19:03   ` David S. Miller
2005-09-11 12:03 ` Christoph Hellwig
2005-09-11 17:07   ` Linus Torvalds
2005-09-11 18:24     ` David S. Miller
2005-09-11 18:52       ` Linus Torvalds
2005-09-11 19:03         ` David S. Miller
2005-09-11 18:48     ` Pascal Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox