From eeeb40c6398c7a9d2b194038193d98e3d6068a2f Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 20 Aug 2015 14:54:23 +1000 Subject: device: cleaner abstraction for device resource functions Signed-off-by: Ben Skeggs --- bin/nv_rffunc.h | 4 ++-- bin/nv_rifunc.h | 8 ++++---- bin/nv_wffunc.h | 4 ++-- bin/nv_wifunc.h | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/nv_rffunc.h b/bin/nv_rffunc.h index 4bc0e4a41..fe1d616a0 100644 --- a/bin/nv_rffunc.h +++ b/bin/nv_rffunc.h @@ -8,6 +8,7 @@ static u64 map_page = ~0ULL; static CAST nv_rfb(struct nvif_device *device, u64 offset) { + struct nvkm_device *nv = nvxx_device(device); u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); @@ -21,8 +22,7 @@ nv_rfb(struct nvif_device *device, u64 offset) if (map) iounmap(map); - map = ioremap(pci_resource_start(nvxx_device(device)->pdev, 1) + - page, PAGE_SIZE); + map = ioremap(nv->func->resource_addr(nv, 1) + page, PAGE_SIZE); if (!map) { printk("map failed\n"); exit(1); diff --git a/bin/nv_rifunc.h b/bin/nv_rifunc.h index 245a4833d..8da8898ed 100644 --- a/bin/nv_rifunc.h +++ b/bin/nv_rifunc.h @@ -8,7 +8,7 @@ static u64 map_page = ~0ULL; static CAST nv_rfb(struct nvif_device *device, u64 offset) { - struct pci_dev *pdev = nvxx_device(device)->pdev; + struct nvkm_device *nv = nvxx_device(device); u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); @@ -22,11 +22,11 @@ nv_rfb(struct nvif_device *device, u64 offset) if (map) iounmap(map); - if (pci_resource_len(pdev, 2)) { - map = ioremap(pci_resource_start(pdev, 2) + + if (nv->func->resource_size(nv, 2)) { + map = ioremap(nv->func->resource_addr(nv, 2) + page, PAGE_SIZE); } else { - map = ioremap(pci_resource_start(pdev, 3) + + map = ioremap(nv->func->resource_addr(nv, 3) + page, PAGE_SIZE); } diff --git a/bin/nv_wffunc.h b/bin/nv_wffunc.h index 6efa67e2f..94f54146f 100644 --- a/bin/nv_wffunc.h +++ b/bin/nv_wffunc.h @@ -8,6 +8,7 @@ static u64 map_page = ~0ULL; static void nv_wfb(struct nvif_device *device, u64 offset, CAST data) { + struct nvkm_device *nv = nvxx_device(device); u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); @@ -21,8 +22,7 @@ nv_wfb(struct nvif_device *device, u64 offset, CAST data) if (map) iounmap(map); - map = ioremap(pci_resource_start(nvxx_device(device)->pdev, 1) + - page, PAGE_SIZE); + map = ioremap(nv->func->resource_addr(nv, 1) + page, PAGE_SIZE); if (!map) { printk("map failed\n"); exit(1); diff --git a/bin/nv_wifunc.h b/bin/nv_wifunc.h index 0525b8423..aaa597c2d 100644 --- a/bin/nv_wifunc.h +++ b/bin/nv_wifunc.h @@ -8,7 +8,7 @@ static u64 map_page = ~0ULL; static void nv_wfb(struct nvif_device *device, u64 offset, CAST data) { - struct pci_dev *pdev = nvxx_device(device)->pdev; + struct nvkm_device *nv = nvxx_device(device); u64 page = (offset & ~(PAGE_SIZE - 1)); u64 addr = (offset & (PAGE_SIZE - 1)); @@ -22,11 +22,11 @@ nv_wfb(struct nvif_device *device, u64 offset, CAST data) if (map) iounmap(map); - if (pci_resource_len(pdev, 2)) { - map = ioremap(pci_resource_start(pdev, 2) + + if (nv->func->resource_size(nv, 2)) { + map = ioremap(nv->func->resource_addr(nv, 2) + page, PAGE_SIZE); } else { - map = ioremap(pci_resource_start(pdev, 3) + + map = ioremap(nv->func->resource_addr(nv, 3) + page, PAGE_SIZE); } -- cgit v1.2.1