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

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Thu Mar 31 08:45:39 CEST 2011


Am 15.03.2011 16:29 schrieb Stefan Tauner:
> Signed-off-by: Stefan Tauner<stefan.tauner at student.tuwien.ac.at>
>    

Right, this is a really good idea.

Could you patch physmap instead to round down the requested address and 
round up the end of the range? Then we could just request the amount we 
need without having to care in each programmer driver about page size.
I think somewhere in flashrom we even have rounding code for physmap, it 
just needs to be moved from a driver to the generic physmap.

Your code looks solid.

> ---
>   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();
>
>    

Regards,
Carl-Daniel

-- 
http://www.hailfinger.org/





More information about the flashrom mailing list