[POC][PATCH 64/83] drivers/video/fbdev: switch to get_free_pages()

From: Al Viro
Date: Mon Dec 21 2015 - 18:55:55 EST


From: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
---
drivers/video/fbdev/grvga.c | 20 +++++++++-----------
drivers/video/fbdev/vermilion/vermilion.c | 17 ++++++++---------
drivers/video/fbdev/vermilion/vermilion.h | 2 +-
3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/drivers/video/fbdev/grvga.c b/drivers/video/fbdev/grvga.c
index b471f92..28fd657 100644
--- a/drivers/video/fbdev/grvga.c
+++ b/drivers/video/fbdev/grvga.c
@@ -333,7 +333,7 @@ static int grvga_probe(struct platform_device *dev)
{
struct fb_info *info;
int retval = -ENOMEM;
- unsigned long virtual_start;
+ void *virtual_start;
unsigned long grvga_fix_addr = 0;
unsigned long physical_start = 0;
unsigned long grvga_mem_size = 0;
@@ -435,8 +435,7 @@ static int grvga_probe(struct platform_device *dev)
goto dealloc_cmap;
}

- virtual_start = (unsigned long) ioremap(physical_start, grvga_mem_size);
-
+ virtual_start = ioremap(physical_start, grvga_mem_size);
if (!virtual_start) {
dev_err(&dev->dev, "error mapping framebuffer memory\n");
retval = -ENOMEM;
@@ -444,10 +443,9 @@ static int grvga_probe(struct platform_device *dev)
}
} else { /* Allocate frambuffer memory */

- unsigned long page;
+ void *page;

- virtual_start = (unsigned long) __get_free_pages(GFP_DMA,
- get_order(grvga_mem_size));
+ virtual_start = get_free_pages(GFP_DMA, get_order(grvga_mem_size));
if (!virtual_start) {
dev_err(&dev->dev,
"unable to allocate framebuffer memory (%lu bytes)\n",
@@ -456,13 +454,13 @@ static int grvga_probe(struct platform_device *dev)
goto dealloc_cmap;
}

- physical_start = dma_map_single(&dev->dev, (void *)virtual_start, grvga_mem_size, DMA_TO_DEVICE);
+ physical_start = dma_map_single(&dev->dev, virtual_start, grvga_mem_size, DMA_TO_DEVICE);

/* Set page reserved so that mmap will work. This is necessary
* since we'll be remapping normal memory.
*/
for (page = virtual_start;
- page < PAGE_ALIGN(virtual_start + grvga_mem_size);
+ page < virtual_start + ALIGN(grvga_mem_size, PAGE_SIZE);
page += PAGE_SIZE) {
SetPageReserved(virt_to_page(page));
}
@@ -470,7 +468,7 @@ static int grvga_probe(struct platform_device *dev)
par->fb_alloced = 1;
}

- memset((unsigned long *) virtual_start, 0, grvga_mem_size);
+ memset(virtual_start, 0, grvga_mem_size);

info->screen_base = (char __iomem *) virtual_start;
info->fix.smem_start = physical_start;
@@ -497,9 +495,9 @@ static int grvga_probe(struct platform_device *dev)

free_mem:
if (grvga_fix_addr)
- iounmap((void *)virtual_start);
+ iounmap(virtual_start);
else
- kfree((void *)virtual_start);
+ kfree(virtual_start);
dealloc_cmap:
fb_dealloc_cmap(&info->cmap);
unmap_regs:
diff --git a/drivers/video/fbdev/vermilion/vermilion.c b/drivers/video/fbdev/vermilion/vermilion.c
index 0882f41..4e9e02f 100644
--- a/drivers/video/fbdev/vermilion/vermilion.c
+++ b/drivers/video/fbdev/vermilion/vermilion.c
@@ -88,7 +88,7 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order,
unsigned min_order)
{
gfp_t flags;
- unsigned long i;
+ void *i;

max_order++;
do {
@@ -100,14 +100,13 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order,
*/

flags = __GFP_DMA | __GFP_HIGH | __GFP_KSWAPD_RECLAIM;
- va->logical =
- __get_free_pages(flags, --max_order);
- } while (va->logical == 0 && max_order > min_order);
+ va->logical = get_free_pages(flags, --max_order);
+ } while (va->logical == NULL && max_order > min_order);

if (!va->logical)
return -ENOMEM;

- va->phys = virt_to_phys((void *)va->logical);
+ va->phys = virt_to_phys(va->logical);
va->size = PAGE_SIZE << max_order;
va->order = max_order;

@@ -118,7 +117,7 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order,
* compound page).
*/

- memset((void *)va->logical, 0x00, va->size);
+ memset(va->logical, 0x00, va->size);
for (i = va->logical; i < va->logical + va->size; i += PAGE_SIZE) {
get_page(virt_to_page(i));
}
@@ -143,7 +142,7 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order,

static void vmlfb_free_vram_area(struct vram_area *va)
{
- unsigned long j;
+ void *j;

if (va->logical) {

@@ -167,9 +166,9 @@ static void vmlfb_free_vram_area(struct vram_area *va)
printk(KERN_DEBUG MODULE_NAME
": Freeing %ld bytes vram area at 0x%08lx\n",
va->size, va->phys);
- free_pages((void *)va->logical, va->order);
+ free_pages(va->logical, va->order);

- va->logical = 0;
+ va->logical = NULL;
}
}

diff --git a/drivers/video/fbdev/vermilion/vermilion.h b/drivers/video/fbdev/vermilion/vermilion.h
index 43d11ec..65f1a63 100644
--- a/drivers/video/fbdev/vermilion/vermilion.h
+++ b/drivers/video/fbdev/vermilion/vermilion.h
@@ -203,7 +203,7 @@ struct vml_par {
};

struct vram_area {
- unsigned long logical;
+ void *logical;
unsigned long phys;
unsigned long size;
unsigned order;
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/