From: Rusty Russell Jeff Garzik argued forcefully that __pa() should not appear in drivers, and that struct netdevice's irq field should not be used. Christoph Hellwig suggested that I run sparse, and provide an lguest-specific wrapper for mapping/unmapping virtual device memory. Results: 1) send-dma and bind-dma hypercall wrappers for drivers to use, 2) formalization of the convention that devices can use the irq corresponding to their index on the lguest_bus. 3) Helper to map and unmap virtual device memory (not classic __iomem). 4) lguest.c should include "lguest_bus.h" for lguest_devices declaration. Signed-off-by: Rusty Russell Cc: Jeff Garzik Signed-off-by: Andrew Morton --- drivers/lguest/lguest.c | 13 +++++++++++++ drivers/lguest/lguest_bus.c | 2 +- include/linux/lguest_bus.h | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff -puN drivers/lguest/lguest.c~lguest-the-guest-code-tidyups-update drivers/lguest/lguest.c --- a/drivers/lguest/lguest.c~lguest-the-guest-code-tidyups-update +++ a/drivers/lguest/lguest.c @@ -36,6 +36,7 @@ #include #include #include +#include /* Declarations for definitions in lguest_guest.S */ extern char lguest_noirq_start[], lguest_noirq_end[]; @@ -122,6 +123,18 @@ void lguest_unbind_dma(unsigned long key hcall(LHCALL_BIND_DMA, key, __pa(dmas), 0); } +/* For guests, device memory can be used as normal memory, so we cast away the + * __iomem to quieten sparse. */ +void *lguest_map(unsigned long phys_addr, unsigned long pages) +{ + return (__force void *)ioremap(phys_addr, PAGE_SIZE*pages); +} + +void lguest_unmap(void *addr) +{ + iounmap((__force void __iomem *)addr); +} + static unsigned long save_fl(void) { return lguest_data.irq_enabled; diff -puN drivers/lguest/lguest_bus.c~lguest-the-guest-code-tidyups-update drivers/lguest/lguest_bus.c --- a/drivers/lguest/lguest_bus.c~lguest-the-guest-code-tidyups-update +++ a/drivers/lguest/lguest_bus.c @@ -136,7 +136,7 @@ static int __init lguest_bus_init(void) return 0; /* Devices are in page above top of "normal" mem. */ - lguest_devices = (__force void*)ioremap(max_pfn<