mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
Automatically unmap physmap()s
Similarly to the previous PCI self-clean up patch this one allows to get rid of a huge number of programmer shutdown functions and makes introducing bugs harder. It adds a new function rphysmap() that takes care of unmapping at shutdown. Callers are changed where it makes sense. Corresponding to flashrom svn r1714. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
15
mcp6x_spi.c
15
mcp6x_spi.c
@ -135,25 +135,20 @@ int mcp6x_spi_init(int want_spi)
|
||||
|
||||
/* Accessing a NULL pointer BAR is evil. Don't do it. */
|
||||
if (!mcp6x_spibaraddr && want_spi) {
|
||||
msg_perr("Error: Chipset is strapped for SPI, but MCP SPI BAR "
|
||||
"is invalid.\n");
|
||||
msg_perr("Error: Chipset is strapped for SPI, but MCP SPI BAR is invalid.\n");
|
||||
return 1;
|
||||
} else if (!mcp6x_spibaraddr && !want_spi) {
|
||||
msg_pdbg("MCP SPI is not used.\n");
|
||||
return 0;
|
||||
} else if (mcp6x_spibaraddr && !want_spi) {
|
||||
msg_pdbg("Strange. MCP SPI BAR is valid, but chipset apparently"
|
||||
" doesn't have SPI enabled.\n");
|
||||
msg_pdbg("Strange. MCP SPI BAR is valid, but chipset apparently doesn't have SPI enabled.\n");
|
||||
/* FIXME: Should we enable SPI anyway? */
|
||||
return 0;
|
||||
}
|
||||
/* Map the BAR. Bytewise/wordwise access at 0x530 and 0x540. */
|
||||
mcp6x_spibar = physmap("NVIDIA MCP6x SPI", mcp6x_spibaraddr, 0x544);
|
||||
|
||||
#if 0
|
||||
/* FIXME: Run the physunmap in a shutdown function. */
|
||||
physunmap(mcp6x_spibar, 0x544);
|
||||
#endif
|
||||
mcp6x_spibar = rphysmap("NVIDIA MCP6x SPI", mcp6x_spibaraddr, 0x544);
|
||||
if (mcp6x_spibar == ERROR_PTR)
|
||||
return 1;
|
||||
|
||||
status = mmio_readw(mcp6x_spibar + 0x530);
|
||||
msg_pdbg("SPI control is 0x%04x, req=%i, gnt=%i\n",
|
||||
|
Reference in New Issue
Block a user