[flashrom] [PATCH 6/7] use getpagesize() to determine physmap's length in nicintel_spi.c

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Mon Mar 14 21:40:42 CET 2011


Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---
 nicintel_spi.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/nicintel_spi.c b/nicintel_spi.c
index 5a6e04d..811ed6e 100644
--- a/nicintel_spi.c
+++ b/nicintel_spi.c
@@ -26,11 +26,14 @@
  */
 
 #include <stdlib.h>
+#include <unistd.h>
 #include "flash.h"
 #include "programmer.h"
 
 #define PCI_VENDOR_ID_INTEL 0x8086
 
+#define MEMMAP_SIZE getpagesize()
+
 #define EECD	0x10
 #define FLA	0x1c
 
@@ -148,7 +151,7 @@ int nicintel_spi_init(void)
 	io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_intel_spi);
 
 	nicintel_spibar = physmap("Intel Gigabit NIC w/ SPI flash",
-				  io_base_addr, 4096);
+				  io_base_addr, MEMMAP_SIZE);
 	tmp = pci_mmio_readl(nicintel_spibar + EECD);
 	tmp &= ~FLASH_WRITES_DISABLED;
 	tmp |= FLASH_WRITES_ENABLED;
@@ -173,7 +176,7 @@ int nicintel_spi_shutdown(void)
 	tmp |= FLASH_WRITES_DISABLED;
 	pci_mmio_writel(tmp, nicintel_spibar + EECD);
 
-	physunmap(nicintel_spibar, 4096);
+	physunmap(nicintel_spibar, MEMMAP_SIZE);
 	pci_cleanup(pacc);
 	release_io_perms();
 
-- 
1.7.1




More information about the flashrom mailing list