Skip to contentSkip to conversation

free_pages stuff

RFC New Al Viro 4 participants 94 messages Dec 21, 2015 – Jan 5, 2016 1 message not in the archive Page 2 of 2

Subsystems (194)
lore
Share & tools
lore
author maintainer
#49 lore raw

PATCH 49/83 get rid of casts in alloc_exact stuff

In reply to Al Viro

From: Al Viro <[email protected]>

---
 mm/page_alloc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
mm/page_alloc.c +12 -15
index aa37489..a1aa8eb 100644
@@ -3449,20 +3449,20 @@ void free_kmem_pages(unsigned long addr, unsigned int order)
 	}
 }
 
-static void *make_alloc_exact(unsigned long addr, unsigned int order,
+static void *make_alloc_exact(void *addr, unsigned int order,
 		size_t size)
 {
 	if (addr) {
-		unsigned long alloc_end = addr + (PAGE_SIZE << order);
-		unsigned long used = addr + PAGE_ALIGN(size);
+		void *alloc_end = addr + (PAGE_SIZE << order);
+		void *used = addr + PAGE_ALIGN(size);
 
-		split_page(virt_to_page((void *)addr), order);
+		split_page(virt_to_page(addr), order);
 		while (used < alloc_end) {
-			free_page((void *)used);
+			free_page(used);
 			used += PAGE_SIZE;
 		}
 	}
-	return (void *)addr;
+	return addr;
 }
 
 /**
@@ -3481,9 +3481,7 @@ static void *make_alloc_exact(unsigned long addr, unsigned int order,
 void *alloc_pages_exact(size_t size, gfp_t gfp_mask)
 {
 	unsigned int order = get_order(size);
-	unsigned long addr;
-
-	addr = __get_free_pages(gfp_mask, order);
+	void *addr = (void *)__get_free_pages(gfp_mask, order);
 	return make_alloc_exact(addr, order, size);
 }
 EXPORT_SYMBOL(alloc_pages_exact);
@@ -3504,7 +3502,7 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask)
 	struct page *p = alloc_pages_node(nid, gfp_mask, order);
 	if (!p)
 		return NULL;
-	return make_alloc_exact((unsigned long)page_address(p), order, size);
+	return make_alloc_exact(page_address(p), order, size);
 }
 
 /**
@@ -3516,12 +3514,11 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask)
  */
 void free_pages_exact(void *virt, size_t size)
 {
-	unsigned long addr = (unsigned long)virt;
-	unsigned long end = addr + PAGE_ALIGN(size);
+	void *end = virt + PAGE_ALIGN(size);
 
-	while (addr < end) {
-		free_page((void *)addr);
-		addr += PAGE_SIZE;
+	while (virt < end) {
+		free_page(virt);
+		virt += PAGE_SIZE;
 	}
 }
 EXPORT_SYMBOL(free_pages_exact);
Signature · 1 line
2.1.4
author maintainer
#50 lore raw

PATCH 50/83 s390 cmm: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/s390/mm/cmm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/s390/mm/cmm.c +7 -7
index b0ca6af..e5879ba 100644
@@ -38,7 +38,7 @@ MODULE_PARM_DESC(sender,
 struct cmm_page_array {
 	struct cmm_page_array *next;
 	unsigned long index;
-	unsigned long pages[CMM_NR_PAGES];
+	void *pages[CMM_NR_PAGES];
 };
 
 static long cmm_pages;
@@ -64,10 +64,10 @@ static long cmm_alloc_pages(long nr, long *counter,
 			    struct cmm_page_array **list)
 {
 	struct cmm_page_array *pa, *npa;
-	unsigned long addr;
+	void *addr;
 
 	while (nr) {
-		addr = __get_free_page(GFP_NOIO);
+		addr = (void *)__get_free_page(GFP_NOIO);
 		if (!addr)
 			break;
 		spin_lock(&cmm_lock);
@@ -78,7 +78,7 @@ static long cmm_alloc_pages(long nr, long *counter,
 			npa = (struct cmm_page_array *)
 				__get_free_page(GFP_NOIO);
 			if (!npa) {
-				free_page((void *)addr);
+				free_page(addr);
 				break;
 			}
 			spin_lock(&cmm_lock);
@@ -91,7 +91,7 @@ static long cmm_alloc_pages(long nr, long *counter,
 			} else
 				free_page(npa);
 		}
-		diag10_range(addr >> PAGE_SHIFT, 1);
+		diag10_range((unsigned long)addr >> PAGE_SHIFT, 1);
 		pa->pages[pa->index++] = addr;
 		(*counter)++;
 		spin_unlock(&cmm_lock);
@@ -103,7 +103,7 @@ static long cmm_alloc_pages(long nr, long *counter,
 static long cmm_free_pages(long nr, long *counter, struct cmm_page_array **list)
 {
 	struct cmm_page_array *pa;
-	unsigned long addr;
+	void *addr;
 
 	spin_lock(&cmm_lock);
 	pa = *list;
@@ -116,7 +116,7 @@ static long cmm_free_pages(long nr, long *counter, struct cmm_page_array **list)
 			free_page(*list);
 			*list = pa;
 		}
-		free_page((void *)addr);
+		free_page(addr);
 		(*counter)--;
 		nr--;
 	}
Signature · 1 line
2.1.4
author maintainer
#51 lore raw

PATCH 51/83 microblaze consistent_alloc(): get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/microblaze/mm/consistent.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
arch/microblaze/mm/consistent.c +9 -9
index a4b587a..bdeb2cb 100644
@@ -61,8 +61,8 @@
  */
 void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 {
-	unsigned long order, vaddr;
-	void *ret;
+	unsigned long order;
+	void *vaddr, *ret;
 	unsigned int i, err = 0;
 	struct page *page, *end;
 
@@ -79,7 +79,7 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 	size = PAGE_ALIGN(size);
 	order = get_order(size);
 
-	vaddr = __get_free_pages(gfp, order);
+	vaddr = (void *)__get_free_pages(gfp, order);
 	if (!vaddr)
 		return NULL;
 
@@ -87,11 +87,11 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 	 * we need to ensure that there are no cachelines in use,
 	 * or worse dirty in this area.
 	 */
-	flush_dcache_range(virt_to_phys((void *)vaddr),
-					virt_to_phys((void *)vaddr) + size);
+	flush_dcache_range(virt_to_phys(vaddr),
+					virt_to_phys(vaddr) + size);
 
 #ifndef CONFIG_MMU
-	ret = (void *)vaddr;
+	ret = vaddr;
 	/*
 	 * Here's the magic!  Note if the uncached shadow is not implemented,
 	 * it's up to the calling code to also test that condition and make
@@ -110,14 +110,14 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 	/* Allocate some common virtual space to map the new pages. */
 	area = get_vm_area(size, VM_ALLOC);
 	if (!area) {
-		free_pages((void *)vaddr, order);
+		free_pages(vaddr, order);
 		return NULL;
 	}
 	va = (unsigned long) area->addr;
 	ret = (void *)va;
 
 	/* This gives us the real physical address of the first page. */
-	*dma_handle = pa = __virt_to_phys(vaddr);
+	*dma_handle = pa = __pa(vaddr);
 #endif
 
 	/*
@@ -148,7 +148,7 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 	}
 
 	if (err) {
-		free_pages((void *)vaddr, order);
+		free_pages(vaddr, order);
 		return NULL;
 	}
 
Signature · 1 line
2.1.4
author maintainer
#52 lore raw

PATCH 52/83 devm_{get_}free_pages(): switch to pointers

In reply to Al Viro

From: Al Viro <[email protected]>

the only caller of devm_get_free_pages() casts anyway

---
 drivers/base/devres.c                 | 14 ++++++--------
 drivers/char/xillybus/xillybus_core.c |  2 +-
 include/linux/device.h                |  4 ++--
 3 files changed, 9 insertions(+), 11 deletions(-)
drivers/base/devres.c +6 -8
index 854f7ae..414ac33 100644
@@ -911,7 +911,7 @@ void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
 EXPORT_SYMBOL_GPL(devm_kmemdup);
 
 struct pages_devres {
-	unsigned long addr;
+	void *addr;
 	unsigned int order;
 };
 
@@ -927,7 +927,7 @@ static void devm_pages_release(struct device *dev, void *res)
 {
 	struct pages_devres *devres = res;
 
-	free_pages((void *)devres->addr, devres->order);
+	free_pages(devres->addr, devres->order);
 }
 
 /**
@@ -943,13 +943,11 @@ static void devm_pages_release(struct device *dev, void *res)
  * Address of allocated memory on success, 0 on failure.
  */
 
-unsigned long devm_get_free_pages(struct device *dev,
+void *devm_get_free_pages(struct device *dev,
 				  gfp_t gfp_mask, unsigned int order)
 {
 	struct pages_devres *devres;
-	unsigned long addr;
-
-	addr = __get_free_pages(gfp_mask, order);
+	void *addr = (void *)__get_free_pages(gfp_mask, order);
 
 	if (unlikely(!addr))
 		return 0;
@@ -957,7 +955,7 @@ unsigned long devm_get_free_pages(struct device *dev,
 	devres = devres_alloc(devm_pages_release,
 			      sizeof(struct pages_devres), GFP_KERNEL);
 	if (unlikely(!devres)) {
-		free_pages((void *)addr, order);
+		free_pages(addr, order);
 		return 0;
 	}
 
@@ -977,7 +975,7 @@ EXPORT_SYMBOL_GPL(devm_get_free_pages);
  * Free memory allocated with devm_get_free_pages(). Unlike free_pages,
  * there is no need to supply the @order.
  */
-void devm_free_pages(struct device *dev, unsigned long addr)
+void devm_free_pages(struct device *dev, void *addr)
 {
 	struct pages_devres devres = { .addr = addr };
 
drivers/char/xillybus/xillybus_core.c +1 -1
index 77d6c12..28cd936 100644
@@ -359,7 +359,7 @@ static int xilly_get_dma_buffers(struct xilly_endpoint *ep,
 				allocorder++;
 			}
 
-			s->salami = (void *) devm_get_free_pages(
+			s->salami = devm_get_free_pages(
 				dev,
 				GFP_KERNEL | __GFP_DMA32 | __GFP_ZERO,
 				allocorder);
include/linux/device.h +2 -2
index b8f411b..24d957d 100644
@@ -671,9 +671,9 @@ extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
 extern void *devm_kmemdup(struct device *dev, const void *src, size_t len,
 			  gfp_t gfp);
 
-extern unsigned long devm_get_free_pages(struct device *dev,
+extern void *devm_get_free_pages(struct device *dev,
 					 gfp_t gfp_mask, unsigned int order);
-extern void devm_free_pages(struct device *dev, unsigned long addr);
+extern void devm_free_pages(struct device *dev, void *addr);
 
 void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
 
Signature · 1 line
2.1.4
author maintainer
#53 lore raw

PATCH 53/83 cavium: (partially) get rid of cargo-culting in allocator

In reply to Al Viro

From: Al Viro <[email protected]>

AFAICS, it's a rudiment of a different allocator used at some earlier point; __get_free_pages() *never* returns a pointer that wouldn't be at least 8 bytes aligned - we don't support architectures with 4-byte pages, TYVM...

---
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c |  4 +---
 drivers/net/ethernet/cavium/liquidio/octeon_droq.h |  3 ---
 drivers/net/ethernet/cavium/liquidio/octeon_main.h | 17 ++---------------
 3 files changed, 3 insertions(+), 21 deletions(-)
drivers/net/ethernet/cavium/liquidio/octeon_droq.c +1 -3
index 4dba86e..7b0e1ac 100644
@@ -218,10 +218,9 @@ int octeon_delete_droq(struct octeon_device *oct, u32 q_no)
 	octeon_droq_destroy_ring_buffers(oct, droq);
 	vfree(droq->recv_buf_list);
 
-	if (droq->info_base_addr)
+	if (droq->info_list)
 		cnnic_free_aligned_dma(oct->pci_dev, droq->info_list,
 				       droq->info_alloc_size,
-				       droq->info_base_addr,
 				       droq->info_list_dma);
 
 	if (droq->desc_ring)
@@ -286,7 +285,6 @@ int octeon_init_droq(struct octeon_device *oct,
 		cnnic_alloc_aligned_dma(oct->pci_dev,
 					(droq->max_count * OCT_DROQ_INFO_SIZE),
 					&droq->info_alloc_size,
-					&droq->info_base_addr,
 					&droq->info_list_dma);
 
 	if (!droq->info_list) {
drivers/net/ethernet/cavium/liquidio/octeon_droq.h +0 -3
index 7940cce..95a145c 100644
@@ -306,9 +306,6 @@ struct octeon_droq {
 	/** DMA mapped address of the DROQ descriptor ring. */
 	size_t desc_ring_dma;
 
-	/** Info ptr list are allocated at this virtual address. */
-	size_t info_base_addr;
-
 	/** DMA mapped address of the info list */
 	size_t info_list_dma;
 
drivers/net/ethernet/cavium/liquidio/octeon_main.h +2 -15
index 61dbccc..b6a90a9 100644
@@ -129,7 +129,6 @@ static inline void *
 cnnic_alloc_aligned_dma(struct pci_dev *pci_dev,
 			u32 size,
 			u32 *alloc_size,
-			size_t *orig_ptr,
 			size_t *dma_addr __attribute__((unused)))
 {
 	int retries = 0;
@@ -140,27 +139,15 @@ cnnic_alloc_aligned_dma(struct pci_dev *pci_dev,
 		ptr =
 		    (void *)__get_free_pages(GFP_KERNEL,
 					     get_order(size));
-		if ((unsigned long)ptr & 0x07) {
-			free_pages(ptr, get_order(size));
-			ptr = NULL;
-			/* Increment the size required if the first
-			 * attempt failed.
-			 */
-			if (!retries)
-				size += 7;
-		}
 		retries++;
 	} while ((retries <= OCTEON_MAX_ALLOC_RETRIES) && !ptr);
 
 	*alloc_size = size;
-	*orig_ptr = (unsigned long)ptr;
-	if ((unsigned long)ptr & 0x07)
-		ptr = (void *)(((unsigned long)ptr + 7) & ~(7UL));
 	return ptr;
 }
 
-#define cnnic_free_aligned_dma(pci_dev, ptr, size, orig_ptr, dma_addr) \
-		free_pages((void *)orig_ptr, get_order(size))
+#define cnnic_free_aligned_dma(pci_dev, ptr, size, dma_addr) \
+		free_pages(ptr, get_order(size))
 
 static inline void
 sleep_cond(wait_queue_head_t *wait_queue, int *condition)
Signature · 1 line
2.1.4
#54 lore raw
In reply to Al Viro
Quoted 7 lines · Al Viro

FWIW, I'd done a proof-of-concept patch series converting the things
to
* free_page() and free_pages() taking the address to free as a pointer
* get_zeroed_page() returning a pointer
* get_free_page()/get_free_pages() added, both returning a pointer
* __get_dma_pages() replaced with get_dma_page() (again, returns
a pointer)

Absolutely not.

I will not take this, and it's stupid in the extreme.

No way in hell do we suddenly change the semantics of an interface that has been around from basically day #1. That's just crazy talk.

Just looking at the diffstat should have made you realize that this is stupid. The confusion it causes, the pain it causes for backports, and just the fundamental idiocy of changing an long-standing interface without changing the name is just not acceptable.

If you want to have versions of the function that return pointers, you had damn well better give them new names. Not use the same name for a different function, causing confusion and forcing this kind of crazy "change everything at once" flag-day patches, and pain for backporting.

And quite frankly, even the "new name" is likely a bad idea. If you want to allocate a page, and get a pointer, just use "kmalloc()". Boom, done!

So I don't know how many ways I can say "NO", but I'll not take anythign like this. It's *completely* wrong.

Linus

author maintainer
#55 lore raw
Quoted 5 lines · Linus Torvalds

If you want to have versions of the function that return pointers, you had damn well better give them new names. Not use the same name for a different function, causing confusion and forcing this kind of crazy "change everything at once" flag-day patches, and pain for backporting.

*shrug*

Up to you. I'll cherry-pick the fixes for bugs found in process and leave the rest alone.

Quoted 3 lines

And quite frankly, even the "new name" is likely a bad idea. If you want to allocate a page, and get a pointer, just use "kmalloc()". Boom, done!

Erm... You've just described the absolute majority of callers. Really. Counting typecasts demonstrates _that_ very clearly. Any place that wanted to allocate a page and get a pointer needs a typecast in mainline; any place that wanted to allocate a page and get a number would need one after this series. Similar for freeing something that is a pointer and is a number respectively.

The total after that series was 70 typecasts added and 1408 removed. In other words, "want to allocate a page and get a pointer" outnumbers the "want to allocate a page and get a number" a _lot_.

Do you really mean that we are overusing __get_free_page() and friends that much and that we should simply use kmalloc() instead? I'm not saying that it's wrong - a lot of places clearly would be fine with kmalloc/kfree. For something like page table allocations kmalloc() is obviously wrong (and they also are of "get a pointer" sort), but that's a very small fraction.

Quoted 2 lines

So I don't know how many ways I can say "NO", but I'll not take anythign like this. It's *completely* wrong.

OK. Don't get me wrong - I'm not fond of all-over-the-tree changes either; I wanted to figure out how the damn thing is actually used and I have found that. What (if anything) to do with that is a separate question.

For me the bottom line so far is that we have a lot of places where page allocator is used and the majority of those uses the result as a pointer. That, with the calling conventions we have (and had all along), means tons of boilerplate. It also means a lot of opportunities to mix physical, virtual and DMA addresses, since typechecking is completely bypassed by those typecasts.

If I understood you correctly, in a lot of those cases the answer should've been "just use kmalloc() and be done with that". And something like e.g. debugfs read and write methods of some wireless NIC driver certainly could use kmalloc(); any concerns about extra overhead are ridiculous there. The same goes for e.g. sysfs symlink body generated when we run into one, etc. I'm not suggesting to start converting existing code to kmalloc; that only goes for new code being written, obviously.

PS: in case you've said that "NO" earlier and I'd missed your replies, my apologies for keeping that up; this is really the first response from you I've seen on this topic.

A message that is not in the archive (sent off-list or not yet received): CA+55aFy9NrV_RnziN9z3p5O6rv1A0mirhLD0hL7Wrb77+YyBeg@mail.gmail.com

#57 lore raw

[ Grr. Resending because the stupid android gmail app still can't do text emails ]

Quoted 6 lines · Al Viro
Quoted 4 lines

And quite frankly, even the "new name" is likely a bad idea. If you want to allocate a page, and get a pointer, just use "kmalloc()". Boom, done!

Erm... You've just described the absolute majority of callers. Really.

That wasn't my point.

I totally believe that most of the legacy users actually wanted a pointer.

But that doesn't mean that we should just convert a legacy interface. We should either just create a new interface and leave old users alone, or if we care about that code and really want to remove the cast, maybe it should just use kmalloc() instead.

Long ago, allocating a page using kmalloc() was a bad idea, because there was overhead for it in the allocation and the code.

These days, kmalloc() not only doesn't have the allocation overhead, but may actually scale better too, thanks to percpu caches etc.

So my point here is that not only is it wrong to change the calling convention for a legacy function (and it really probably doesn't get much more legacy than get_free_page - I think it's been around forever), but even the "let's make up a new name" conversion may be wrong, because it's entirely possible that the code in question should just be using kmalloc().

So I don't think an automatic conversion is a good idea. I suspect that old code that somebody isn't actively working on should just be left alone, and code that *is* actively worked on should maybe consider kmalloc().

And if the code really explicitly wants a page (or set of aligned pages) for some vm reason, I suspect having the cast there isn't a bad thing. It's clearly not just a random pointer allocation if the bit pattern of the pointer matters.

And yes, most of the people who used to want "unsigned long" have long since been converted to take "struct page *" instead, since things like the VM wants highmem pages etc. There's a reason why the historical interface returns "unsigned long": it _used_ to be the right thing for a lot of code. The fact that there now are more casts than not are about changing use patterns, but I don't think that means that we should change the calling convention that has a historical reason for it.

Linus

author maintainer
#58 lore raw
Quoted 5 lines · Linus Torvalds

And if the code really explicitly wants a page (or set of aligned pages) for some vm reason, I suspect having the cast there isn't a bad thing. It's clearly not just a random pointer allocation if the bit pattern of the pointer matters.

Quoted 8 lines

And yes, most of the people who used to want "unsigned long" have long since been converted to take "struct page *" instead, since things like the VM wants highmem pages etc. There's a reason why the historical interface returns "unsigned long": it _used_ to be the right thing for a lot of code. The fact that there now are more casts than not are about changing use patterns, but I don't think that means that we should change the calling convention that has a historical reason for it.

Umm... Depends on how early you look. In 0.01:
fs/exec.c:179: if (!(page[i]=get_free_page()))
fs/inode.c:208: if (!(inode->i_size=get_free_page())) {
kernel/fork.c:70: p = (struct task_struct *) get_free_page();
mm/memory.c:143: if (!(to_page_table = (unsigned long *) get_free_page()))
mm/memory.c:185: if (!(tmp=get_free_page()))
mm/memory.c:203: if (!(new_page=get_free_page()))
mm/memory.c:241: if (tmp=get_free_page())

the last 3 are "we want struct page *" variety, the rest is "want a pointer" stuff (exec.c one is copy_strings() and the only use of pages[...] is a cast to char *, inode.c one is get_pipe_inode() - I guess you didn't want to bother with adding pipe-specific fields to struct inode at that point and since ->i_size is unused for pipes anyway reused it to keep a pointer to pipe buffer). Even then it wasn't the majority.

By 2.0 (still before highmem) the fraction was already _way_ below 50%...

author maintainer
#59 lore raw
In reply to a message not in the archive
Quoted 20 lines · Linus Torvalds
Quoted 6 lines · Al Viro
Quoted 4 lines

And quite frankly, even the "new name" is likely a bad idea. If you want to allocate a page, and get a pointer, just use "kmalloc()". Boom, done!

Erm... You've just described the absolute majority of callers. Really.

That wasn't my point.

I totally believe that most of the legacy users actually wanted a pointer.

But that doesn't mean that we should just convert a legacy interface. We should either just create a new interface and leave old users alone, or if we care about that code and really want to remove the cast, maybe it should just use kmalloc() instead.

Long ago, allocating a page using kmalloc() was a bad idea, because there was overhead for it in the allocation and the code.

Quoted 6 lines

These days, kmalloc() not only doesn't have the allocation overhead, but may actually scale better too, thanks to percpu caches etc.

So my point here is that not only is it wrong to change the calling convention for a legacy function (and it really probably doesn't get much more legacy than get_free_page - I think it's been around forever), but

Yes - present in v0.01, with similar situation re callers even back then ;-)

Quoted 6 lines

even the "let's make up a new name" conversion may be wrong, because it's entirely possible that the code in question should just be using kmalloc().

So I don't think an automatic conversion is a good idea. I suspect that old code that somebody isn't actively working on should just be left alone, and code that *is* actively worked on should maybe consider kmalloc().

Agreed. Again, what I really wanted was to get the clear picture of what uses _are_ there. In more details than just "grepping seems to indicate that...". It's really pretty much all of them.

Quoted 4 lines

And if the code really explicitly wants a page (or set of aligned pages) for some vm reason, I suspect having the cast there isn't a bad thing. It's clearly not just a random pointer allocation if the bit pattern of the pointer matters.

BTW, I'm not sure we don't have code that would assume that kmalloc(PAGE_SIZE,...) always returns something PAGE_SIZE-aligned.

FWIW, pointer-returning get_free_page() would not be a flagday change at all - we only have __get_free_page()/__get_free_pages() right now. And I'm not sure that it wouldn't make sense to add void *-returning variants without underscores - not for bulk conversion of existing callers, but for new places that want a page. Because most of the new ones (and new ones keep appearing; it's not just ancient code) still want a pointer. And yes, quite a few of those should be using something else.

Example (went into the tree just three months ago):
static inline void *scif_zalloc(size_t size)

{
        void *ret = NULL;
        size_t align = ALIGN(size, PAGE_SIZE);

        if (align && get_order(align) < MAX_ORDER)
                ret = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
                                               get_order(align));
        return ret ? ret : vzalloc(align);
}

This clearly should be using kzalloc() instead of __get_free_pages() (and I'm not sure whether the cutoff is right - similar "kmalloc if not too large, vmalloc otherwise" tends to have cutoff lower than MAX_ORDER; PAGE_ALLOC_COSTLY_ORDER is more common). The callers do not look like they would care about page alignment - at least quite a few of them do not.

Incidentally, those caller include the following example of lousy naming:

        (*pages)->phys_addr = scif_zalloc(nr_pages * sizeof(dma_addr_t));
First of all, the address is clearly virtual - it's an array!  What's more,
I really wonder whether it's DMA or physical addresses that are stored there.
It's declared as an array of dma_addr_t, but...
                (*pages)->phys_addr[i] =
                        __scif_off_to_dma_addr(window, offset +
                                               (i * PAGE_SIZE));
                (*pages)->phys_addr[i] = scif_get_phys((*pages)->phys_addr[i],
                                                        ep);

and
static phys_addr_t scif_get_phys(phys_addr_t phys, struct scif_endpt *ep) seems to indicate something fishy going on.

Typechecking for different kinds of addresses is really too weak, and the amount of casts we have around them doesn't help either ;-/

#60 lore raw
Quoted 7 lines · Al Viro
Quoted 4 lines

And if the code really explicitly wants a page (or set of aligned pages) for some vm reason, I suspect having the cast there isn't a bad thing. It's clearly not just a random pointer allocation if the bit pattern of the pointer matters.

BTW, I'm not sure we don't have code that would assume that kmalloc(PAGE_SIZE,...) always returns something PAGE_SIZE-aligned.

Yeah, needs-to-be-PAGE_SIZE-aligned is probably one of the main reasons of not calling kmalloc().

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#61 lore raw
Quoted 11 lines · Geert Uytterhoeven
Quoted 7 lines · Al Viro
Quoted 4 lines

And if the code really explicitly wants a page (or set of aligned pages) for some vm reason, I suspect having the cast there isn't a bad thing. It's clearly not just a random pointer allocation if the bit pattern of the pointer matters.

BTW, I'm not sure we don't have code that would assume that kmalloc(PAGE_SIZE,...) always returns something PAGE_SIZE-aligned.

Yeah, needs-to-be-PAGE_SIZE-aligned is probably one of the main reasons of not calling kmalloc().

FWIW, looking through the fs/* uses of __get_free_pages() and its wrappers...
* affs_grow_extcache() - might as well have been kmalloc (and
I'm not sure that fixed PAGE_SIZE is the best size there, actually).
* afs_mntpt_do_automount() - kmalloc().
* bfs_dump_imap() - kmalloc().
* bm_entry_read() - kmalloc(), and might be better off with
single_open-style seqfile.
* ceph_alloc_readdir_reply_buffer() - kmalloc().
* configfs fill_write_buffer() - kmalloc(), and it might be worth
a helper similar to memdup_user() that would allocate size + 1 bytes, copy size bytes from user and put '\0' after them. There's a lot of ->write() instances open-coding that.
* configfs fill_read_buffer() - kmalloc().
* configfs_follow_link() - kmalloc().
* ext4_calculate_overhead() - kmalloc().
* fuse_follow_link() - kmalloc().
* fuse_do_ioctl() - kmalloc(), and it might as well do more accurate
size calculation
* hfs_mdb_get() - 8Kb kmalloc().
* isofs_readdir() - kmalloc().
* jbd2_alloc() - really wants alignment; might make sense to have
3 more private slabs there (they are using kmem_cache_alloc() for sub-page allocation, with explicit alignments set when creating those; anything from 8 pages and up goes to vmalloc()).
* jfs_readdir() - kmalloc().
* jfs lbmLogInit() - alloc_page(). _This_ is one that really wants
struct page (and uses virt_to_page() to get it after get_zeroed_page()).
* kernfs_iop_follow_link() - kmalloc().
* simple_transaction_get() - kmalloc().
* copy_mount_options() - kmalloc().
* nfs_do_submount() - kmalloc().
* nfs_follow_referral() - kmalloc().
* nfs4_replace_transport() - kmalloc().
* nfs_show_devname() - kmalloc().
* nfsd_buffered_readdir() - kmalloc().
* nilfs_ioctl_wrap_copy() - kmalloc() (and I'm not sure that PAGE_SIZE
is the best possible variant there).
* fs/ocfs2/dlm/dlmdebug.c ones - kmalloc(), all of them.
* dlm_alloc_pagevec() - used to allocate hash tables. kmalloc() will
definitely do, but I would consider using a single kmalloc or vmalloc instead of an array of page-sized blocks. Guaranteed extra dereference on every hash lookup is potentially painful.
* dlm_migrate_lockres() - kmalloc().
* dlm_request_all_locks_handler() - kmalloc().
* ovl_read_symlink() - kmalloc().
* do_proc_readlink() - kmalloc().
* proc_pid_cmdline_read() - kmalloc().
* proc_pid_attr_write() - memdup_user().
* mem_rw() - kmalloc().
* environ_read() - kmalloc().
* dquot_init() - hash allocation; alloc_large_system_hash(), unless
there's something I'm missing...
* poll_get_entry() - kmalloc(), probably.
* fs/proc/vmcore.c - interesting one; it allocates a buffer to
store elf headers from crashdump, and everything would be simple, expect for mmap() support in there. Which wants it to be page-aligned and uses remap_pfn_range() from that sucker.

IOW, there is one place that can't live with kmalloc() due to alignment requirements (jbd2_alloc()), one place that wants struct page * (in jfs) and one place that wants page-aligned buffer it will feed to remap_pfn_range(). And 35 places that have no good reason for using __get_free_pages() or its wrappers.

So at least for fs/* the answer is definitely "almost all places where we are using page allocator would be better off with something else".

Documentation/which-allocator-should-I-use might be a good idea... Notes below are just a skeleton - a lot of details need to be added; in particular, there should be a part on "I have this kind of address and I want that; when and how should that be done?", completely missing here. And there should be a big scary warning along the lines of "this is NOT an invitation for a flood of checkpatch-inspired patches"...

Comments, corrections and additions would be very welcome.

1) Most of the time kmalloc() is the right thing to use.
Limitations: alignment is no better than word, not available very early in bootstrap, allocated memory is physically contiguous, so large allocations are best avoided.

2) kmem_cache_alloc() allows to specify the alignment at cache creation time. Otherwise it's similar to kmalloc(). Normally it's used for situations where we have a lot of instances of some type and want dynamic allocation of those.

3) vmalloc() is for large allocations. They will be page-aligned, but *not* physically contiguous. OTOH, large physically contiguous allocations are generally a bad idea. Unlike other allocators, there's no variant that could be used in interrupt; freeing is possible there, but allocation is not. Note that non-blocking variant *does* exist - __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL) can be used in atomic contexts; it's the interrupt ones that are no-go.

4) if it's very early in bootstrap, alloc_bootmem() and friends may be the only option. Rule of the thumb: if it's already printed
Memory: ...../..... available.....
you shouldn't be using that one. Allocations are physically contiguous and at that point large physically contiguous allocations are still OK.

5) if you need to allocate memory for DMA, use dma_alloc_coherent() and friends. They'll give you both the virtual address for your use and DMA address refering to the same memory for use by device; do *NOT* try to derive the latter from the former; use of virt_to_bus() et.al. is a Bloody Bad Idea(tm).

6) if you need a reference to struct page, use alloc_page/alloc_pages.

7) in some cases (page tables, for the most obvious example), __get_free_page() and friends might be the right answer. In principle, it's case (6), but it returns page_address(page) instead of the page itself. Historically that was the first API introduced, so a _lot_ of places that should've been using something else ended up using that. Do not assume that being lower level makes it faster than e.g. kmalloc() - this is simply not true.

#62 lore raw

[CCing linux-mm]

On Tue 22-12-15 21:04:35, Al Viro wrote:
[...]

Quoted 8 lines

Documentation/which-allocator-should-I-use might be a good idea... Notes below are just a skeleton - a lot of details need to be added; in particular, there should be a part on "I have this kind of address and I want that; when and how should that be done?", completely missing here. And there should be a big scary warning along the lines of "this is NOT an invitation for a flood of checkpatch-inspired patches"...

Comments, corrections and additions would be very welcome.

FWIW I think this is a very good idea. The current form is good enough IMHO.

Quoted 10 lines

1) Most of the time kmalloc() is the right thing to use.
Limitations: alignment is no better than word, not available very early in bootstrap, allocated memory is physically contiguous, so large allocations are best avoided.

2) kmem_cache_alloc() allows to specify the alignment at cache creation time. Otherwise it's similar to kmalloc(). Normally it's used for situations where we have a lot of instances of some type and want dynamic allocation of those.

Quoted 7 lines

3) vmalloc() is for large allocations. They will be page-aligned, but *not* physically contiguous. OTOH, large physically contiguous allocations are generally a bad idea. Unlike other allocators, there's no variant that could be used in interrupt; freeing is possible there, but allocation is not. Note that non-blocking variant *does* exist - __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL) can be used in atomic contexts; it's the interrupt ones that are no-go.

It is also hardcoded GFP_KERNEL context so a usage from NOFS context needs a special treatment.

Quoted 20 lines

4) if it's very early in bootstrap, alloc_bootmem() and friends may be the only option. Rule of the thumb: if it's already printed
Memory: ...../..... available.....
you shouldn't be using that one. Allocations are physically contiguous and at that point large physically contiguous allocations are still OK.

5) if you need to allocate memory for DMA, use dma_alloc_coherent() and friends. They'll give you both the virtual address for your use and DMA address refering to the same memory for use by device; do *NOT* try to derive the latter from the former; use of virt_to_bus() et.al. is a Bloody Bad Idea(tm).

6) if you need a reference to struct page, use alloc_page/alloc_pages.

7) in some cases (page tables, for the most obvious example), __get_free_page() and friends might be the right answer. In principle, it's case (6), but it returns page_address(page) instead of the page itself. Historically that was the first API introduced, so a _lot_ of places that should've been using something else ended up using that. Do not assume that being lower level makes it faster than e.g. kmalloc() - this is simply not true.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author maintainer
#63 lore raw
Quoted 7 lines · Michal Hocko
Quoted 7 lines

3) vmalloc() is for large allocations. They will be page-aligned, but *not* physically contiguous. OTOH, large physically contiguous allocations are generally a bad idea. Unlike other allocators, there's no variant that could be used in interrupt; freeing is possible there, but allocation is not. Note that non-blocking variant *does* exist - __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL) can be used in atomic contexts; it's the interrupt ones that are no-go.

The last sentence I'd put into that part was complete crap...

Quoted 2 lines

It is also hardcoded GFP_KERNEL context so a usage from NOFS context needs a special treatment.

... in part because of this. GFP_ATOMIC __vmalloc() will be anything but, and the only caller passing that is almost certainly bogus. As for NOFS/NOIO, I wonder if we should apply that special treatment inside __vmalloc_area_node rather than in callers; see the current thread on linux-mm for details...

Another interesting issue is __GFP_HIGHMEM meaning for kmalloc and __vmalloc resp. (should never be passed to kmalloc, should almost always be passed to __vmalloc - the former needs pages mapped in kernel space, the latter probably never needs a separate kernel alias for the data pages, to such degree that I'm not sure if we shouldn't _force_ __GFP_HIGHMEM for data pages allocation in __vmalloc_area_node())

Quoted 5 lines
Quoted 5 lines

4) if it's very early in bootstrap, alloc_bootmem() and friends may be the only option. Rule of the thumb: if it's already printed
Memory: ...../..... available.....
you shouldn't be using that one. Allocations are physically contiguous and at that point large physically contiguous allocations are still OK.

Probably needs at least some discussion of memblock vs. bootmem APIs.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#64 lore raw
Quoted 10 lines · Al Viro
Quoted 7 lines · Michal Hocko
Quoted 7 lines

3) vmalloc() is for large allocations. They will be page-aligned, but *not* physically contiguous. OTOH, large physically contiguous allocations are generally a bad idea. Unlike other allocators, there's no variant that could be used in interrupt; freeing is possible there, but allocation is not. Note that non-blocking variant *does* exist - __vmalloc(size, GFP_ATOMIC, PAGE_KERNEL) can be used in atomic contexts; it's the interrupt ones that are no-go.

Quoted 7 lines

The last sentence I'd put into that part was complete crap...

Quoted 2 lines

It is also hardcoded GFP_KERNEL context so a usage from NOFS context needs a special treatment.

... in part because of this. GFP_ATOMIC __vmalloc() will be anything but, and the only caller passing that is almost certainly bogus.

Agreed as just replied in the other email thread which I have noticed only now.

Quoted 3 lines

As for NOFS/NOIO,
I wonder if we should apply that special treatment inside __vmalloc_area_node rather than in callers; see the current thread on linux-mm for details...

That would make a lot of sense to me. Spreading the _special_ treatment all over the kernel is certainly worse.

Quoted 6 lines

Another interesting issue is __GFP_HIGHMEM meaning for kmalloc and __vmalloc resp. (should never be passed to kmalloc, should almost always be passed to __vmalloc - the former needs pages mapped in kernel space, the latter probably never needs a separate kernel alias for the data pages, to such degree that I'm not sure if we shouldn't _force_ __GFP_HIGHMEM for data pages allocation in __vmalloc_area_node())

I would have to think about this one some more. Let's not fragment the discussion and continue in that email thread:
http://lkml.kernel.org/r/20160103071246.GK9938%40ZenIV.linux.org.uk

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author maintainer
#65 lore raw

PATCH 54/83 um: store stacks as pointers

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/um/drivers/chan_user.c         |  6 +++---
 arch/um/drivers/chan_user.h         |  2 +-
 arch/um/drivers/line.c              |  8 ++++----
 arch/um/drivers/ubd.h               |  2 +-
 arch/um/drivers/ubd_kern.c          |  2 +-
 arch/um/drivers/ubd_user.c          |  4 ++--
 arch/um/include/shared/kern_util.h  |  4 ++--
 arch/um/include/shared/os.h         |  6 +++---
 arch/um/include/shared/skas/mm_id.h |  2 +-
 arch/um/include/shared/skas/skas.h  |  2 +-
 arch/um/kernel/process.c            | 11 ++++-------
 arch/um/kernel/skas/mmu.c           | 17 ++++++++---------
 arch/um/kernel/skas/process.c       |  4 ++--
 arch/um/os-Linux/aio.c              |  2 +-
 arch/um/os-Linux/helper.c           | 14 +++++++-------
 arch/um/os-Linux/sigio.c            |  2 +-
 arch/um/os-Linux/skas/process.c     | 19 +++++++++----------
 17 files changed, 51 insertions(+), 56 deletions(-)
arch/um/drivers/chan_user.c +3 -3
index 3fd7c3e..bbda889 100644
@@ -217,7 +217,7 @@ static int winch_thread(void *arg)
 }
 
 static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
-		       unsigned long *stack_out)
+		       void **stack_out)
 {
 	struct winch_data data;
 	int fds[2], n, err;
@@ -273,7 +273,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
 
 void register_winch(int fd, struct tty_port *port)
 {
-	unsigned long stack;
+	void *stack;
 	int pid, thread, count, thread_fd = -1;
 	char c = 1;
 
@@ -282,7 +282,7 @@ void register_winch(int fd, struct tty_port *port)
 
 	pid = tcgetpgrp(fd);
 	if (is_skas_winch(pid, fd, port)) {
-		register_winch_irq(-1, fd, -1, port, 0);
+		register_winch_irq(-1, fd, -1, port, NULL);
 		return;
 	}
 
arch/um/drivers/chan_user.h +1 -1
index 03f1b56..9cc900b 100644
@@ -41,7 +41,7 @@ extern void generic_free(void *data);
 struct tty_port;
 extern void register_winch(int fd,  struct tty_port *port);
 extern void register_winch_irq(int fd, int tty_fd, int pid,
-			       struct tty_port *port, unsigned long stack);
+			       struct tty_port *port, void *stack);
 
 #define __channel_help(fn, prefix) \
 __uml_help(fn, prefix "[0-9]*=<channel description>\n" \
arch/um/drivers/line.c +4 -4
index 6208702..ae8a5b1 100644
@@ -598,7 +598,7 @@ struct winch {
 	int tty_fd;
 	int pid;
 	struct tty_port *port;
-	unsigned long stack;
+	void *stack;
 	struct work_struct work;
 };
 
@@ -609,7 +609,7 @@ static void __free_winch(struct work_struct *work)
 
 	if (winch->pid != -1)
 		os_kill_process(winch->pid, 1);
-	if (winch->stack != 0)
+	if (winch->stack)
 		free_stack(winch->stack, 0);
 	kfree(winch);
 }
@@ -672,7 +672,7 @@ static irqreturn_t winch_interrupt(int irq, void *data)
 }
 
 void register_winch_irq(int fd, int tty_fd, int pid, struct tty_port *port,
-			unsigned long stack)
+			void *stack)
 {
 	struct winch *winch;
 
@@ -707,7 +707,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_port *port,
  cleanup:
 	os_kill_process(pid, 1);
 	os_close_file(fd);
-	if (stack != 0)
+	if (stack)
 		free_stack(stack, 0);
 }
 
arch/um/drivers/ubd.h +1 -1
index 3b48cd2..5507e2c 100644
@@ -7,7 +7,7 @@
 #ifndef __UM_UBD_USER_H
 #define __UM_UBD_USER_H
 
-extern int start_io_thread(unsigned long sp, int *fds_out);
+extern int start_io_thread(void *sp, int *fds_out);
 extern int io_thread(void *arg);
 extern int kernel_fd;
 
arch/um/drivers/ubd_kern.c +1 -1
index e8ab93c..e88fe7c 100644
@@ -1082,7 +1082,7 @@ static int __init ubd_init(void)
 late_initcall(ubd_init);
 
 static int __init ubd_driver_init(void){
-	unsigned long stack;
+	void *stack;
 	int err;
 
 	/* Set by CONFIG_BLK_DEV_UBD_SYNC or ubd=sync.*/
arch/um/drivers/ubd_user.c +2 -2
index e376f9b..47791d4 100644
@@ -21,7 +21,7 @@
 #include "ubd.h"
 #include <os.h>
 
-int start_io_thread(unsigned long sp, int *fd_out)
+int start_io_thread(void *sp, int *fd_out)
 {
 	int pid, fds[2], err;
 
@@ -40,7 +40,7 @@ int start_io_thread(unsigned long sp, int *fd_out)
 		goto out_close;
 	}
 
-	pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM, NULL);
+	pid = clone(io_thread, sp, CLONE_FILES | CLONE_VM, NULL);
 	if(pid < 0){
 		err = -errno;
 		printk("start_io_thread - clone failed : errno = %d\n", errno);
arch/um/include/shared/kern_util.h +2 -2
index 35ab97e..886e362 100644
@@ -19,8 +19,8 @@ extern int kmalloc_ok;
 #define UML_ROUND_UP(addr) \
 	((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK)
 
-extern unsigned long alloc_stack(int order, int atomic);
-extern void free_stack(unsigned long stack, int order);
+extern void *alloc_stack(int order, int atomic);
+extern void free_stack(void *stack, int order);
 
 struct pt_regs;
 extern void do_signal(struct pt_regs *regs);
arch/um/include/shared/os.h +3 -3
index 868e6c3..fc47885 100644
@@ -210,7 +210,7 @@ extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
 /* helper.c */
 extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv);
 extern int run_helper_thread(int (*proc)(void *), void *arg,
-			     unsigned int flags, unsigned long *stack_out);
+			     unsigned int flags, void **stack_out);
 extern int helper_wait(int pid);
 
 
@@ -270,8 +270,8 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
 
 /* skas/process.c */
 extern int is_skas_winch(int pid, int fd, void *data);
-extern int start_userspace(unsigned long stub_stack);
-extern int copy_context_skas0(unsigned long stack, int pid);
+extern int start_userspace(void *stub_stack);
+extern int copy_context_skas0(void *stack, int pid);
 extern void userspace(struct uml_pt_regs *regs);
 extern int map_stub_pages(int fd, unsigned long code, unsigned long data,
 			  unsigned long stack);
arch/um/include/shared/skas/mm_id.h +1 -1
index 48dd098..b75c535 100644
@@ -11,7 +11,7 @@ struct mm_id {
 		int mm_fd;
 		int pid;
 	} u;
-	unsigned long stack;
+	void *stack;
 };
 
 #endif
arch/um/include/shared/skas/skas.h +1 -1
index 911f3c4..689d0c6 100644
@@ -14,6 +14,6 @@ extern int user_thread(unsigned long stack, int flags);
 extern void new_thread_handler(void);
 extern void handle_syscall(struct uml_pt_regs *regs);
 extern long execute_syscall_skas(void *r);
-extern unsigned long current_stub_stack(void);
+extern void *current_stub_stack(void);
 
 #endif
arch/um/kernel/process.c +4 -7
index b77685b..69c8d56 100644
@@ -55,21 +55,18 @@ int pid_to_processor_id(int pid)
 	return -1;
 }
 
-void free_stack(unsigned long stack, int order)
+void free_stack(void *stack, int order)
 {
-	free_pages((void *)stack, order);
+	free_pages(stack, order);
 }
 
-unsigned long alloc_stack(int order, int atomic)
+void *alloc_stack(int order, int atomic)
 {
-	unsigned long page;
 	gfp_t flags = GFP_KERNEL;
 
 	if (atomic)
 		flags = GFP_ATOMIC;
-	page = __get_free_pages(flags, order);
-
-	return page;
+	return (void *)__get_free_pages(flags, order);
 }
 
 static inline void set_current(struct task_struct *task)
arch/um/kernel/skas/mmu.c +8 -9
index 6898b23..a0e5758 100644
@@ -15,7 +15,7 @@
 #include <skas.h>
 
 static int init_stub_pte(struct mm_struct *mm, unsigned long proc,
-			 unsigned long kernel)
+			 void *kernel)
 {
 	pgd_t *pgd;
 	pud_t *pud;
@@ -51,11 +51,11 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
 {
  	struct mm_context *from_mm = NULL;
 	struct mm_context *to_mm = &mm->context;
-	unsigned long stack = 0;
+	void *stack;
 	int ret = -ENOMEM;
 
-	stack = (unsigned long)get_zeroed_page(GFP_KERNEL);
-	if (stack == 0)
+	stack = get_zeroed_page(GFP_KERNEL);
+	if (!stack)
 		goto out;
 
 	to_mm->id.stack = stack;
@@ -84,8 +84,8 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
 	return 0;
 
  out_free:
-	if (to_mm->id.stack != 0)
-		free_page((void *)to_mm->id.stack);
+	if (to_mm->id.stack)
+		free_page(to_mm->id.stack);
  out:
 	return ret;
 }
@@ -94,8 +94,7 @@ void uml_setup_stubs(struct mm_struct *mm)
 {
 	int err, ret;
 
-	ret = init_stub_pte(mm, STUB_CODE,
-			    (unsigned long) __syscall_stub_start);
+	ret = init_stub_pte(mm, STUB_CODE, __syscall_stub_start);
 	if (ret)
 		goto out;
 
@@ -153,6 +152,6 @@ void destroy_context(struct mm_struct *mm)
 	}
 	os_kill_ptraced_process(mmu->id.u.pid, 1);
 
-	free_page((void *)mmu->id.stack);
+	free_page(mmu->id.stack);
 	free_ldt(mmu);
 }
arch/um/kernel/skas/process.c +2 -2
index 527fa58..1a2d485 100644
@@ -43,10 +43,10 @@ int __init start_uml(void)
 				 &init_task.thread.switch_buf);
 }
 
-unsigned long current_stub_stack(void)
+void *current_stub_stack(void)
 {
 	if (current->mm == NULL)
-		return 0;
+		return NULL;
 
 	return current->mm->context.id.stack;
 }
arch/um/os-Linux/aio.c +1 -1
index 014eb35..e029471 100644
@@ -164,7 +164,7 @@ static int do_not_aio(struct aio_thread_req *req)
 static int aio_req_fd_r = -1;
 static int aio_req_fd_w = -1;
 static int aio_pid = -1;
-static unsigned long aio_stack;
+static void *aio_stack;
 
 static int not_aio_thread(void *arg)
 {
arch/um/os-Linux/helper.c +7 -7
index 3f02d42..8653db7 100644
@@ -42,11 +42,11 @@ static int helper_child(void *arg)
 int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
 {
 	struct helper_data data;
-	unsigned long stack, sp;
+	void *stack, *sp;
 	int pid, fds[2], ret, n;
 
 	stack = alloc_stack(0, __cant_sleep());
-	if (stack == 0)
+	if (!stack)
 		return -ENOMEM;
 
 	ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
@@ -71,7 +71,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
 	data.fd = fds[1];
 	data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
 					uml_kmalloc(PATH_MAX, UM_GFP_KERNEL);
-	pid = clone(helper_child, (void *) sp, CLONE_VM, &data);
+	pid = clone(helper_child, sp, CLONE_VM, &data);
 	if (pid < 0) {
 		ret = -errno;
 		printk(UM_KERN_ERR "run_helper : clone failed, errno = %d\n",
@@ -111,17 +111,17 @@ out_free:
 }
 
 int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
-		      unsigned long *stack_out)
+		      void **stack_out)
 {
-	unsigned long stack, sp;
+	void *stack, *sp;
 	int pid, status, err;
 
 	stack = alloc_stack(0, __cant_sleep());
-	if (stack == 0)
+	if (!stack)
 		return -ENOMEM;
 
 	sp = stack + UM_KERN_PAGE_SIZE - sizeof(void *);
-	pid = clone(proc, (void *) sp, flags, arg);
+	pid = clone(proc, sp, flags, arg);
 	if (pid < 0) {
 		err = -errno;
 		printk(UM_KERN_ERR "run_helper_thread : clone failed, "
arch/um/os-Linux/sigio.c +1 -1
index 46e762f..a5f8fa5 100644
@@ -22,7 +22,7 @@
  * exitcall.
  */
 static int write_sigio_pid = -1;
-static unsigned long write_sigio_stack;
+static void *write_sigio_stack;
 
 /*
  * These arrays are initialized before the sigio thread is started, and
arch/um/os-Linux/skas/process.c +9 -10
index b856c66..ec32886 100644
@@ -85,7 +85,7 @@ bad_wait:
 	fatal_sigsegv();
 }
 
-extern unsigned long current_stub_stack(void);
+extern void *current_stub_stack(void);
 
 static void get_skas_faultinfo(int pid, struct faultinfo *fi)
 {
@@ -110,7 +110,7 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi)
 	 * faultinfo is prepared by the stub-segv-handler at start of
 	 * the stub stack page. We just have to copy it.
 	 */
-	memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
+	memcpy(fi, current_stub_stack(), sizeof(*fi));
 
 	err = put_fp_registers(pid, fpregs);
 	if (err < 0) {
@@ -245,10 +245,9 @@ static int userspace_tramp(void *stack)
 #define NR_CPUS 1
 int userspace_pid[NR_CPUS];
 
-int start_userspace(unsigned long stub_stack)
+int start_userspace(void *stub_stack)
 {
-	void *stack;
-	unsigned long sp;
+	void *stack, *sp;
 	int pid, status, n, flags, err;
 
 	stack = mmap(NULL, UM_KERN_PAGE_SIZE,
@@ -261,11 +260,11 @@ int start_userspace(unsigned long stub_stack)
 		return err;
 	}
 
-	sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
+	sp = stack + UM_KERN_PAGE_SIZE - sizeof(void *);
 
 	flags = CLONE_FILES | SIGCHLD;
 
-	pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack);
+	pid = clone(userspace_tramp, sp, flags, stub_stack);
 	if (pid < 0) {
 		err = -errno;
 		printk(UM_KERN_ERR "start_userspace : clone failed, "
@@ -439,14 +438,14 @@ static int __init init_thread_regs(void)
 
 __initcall(init_thread_regs);
 
-int copy_context_skas0(unsigned long new_stack, int pid)
+int copy_context_skas0(void *new_stack, int pid)
 {
 	int err;
-	unsigned long current_stack = current_stub_stack();
+	void *current_stack = current_stub_stack();
 	struct stub_data *data = (struct stub_data *) current_stack;
 	struct stub_data *child_data = (struct stub_data *) new_stack;
 	unsigned long long new_offset;
-	int new_fd = phys_mapping(to_phys((void *)new_stack), &new_offset);
+	int new_fd = phys_mapping(to_phys(new_stack), &new_offset);
 
 	/*
 	 * prepare offset and fd of child's stack as argument for parent's
Signature · 1 line
2.1.4
author maintainer
#66 lore raw

PATCH 55/83 sh: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/sh/boards/mach-hp6xx/pm.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/sh/boards/mach-hp6xx/pm.c +5 -4
index 1a8aacd..b792c76 100644
@@ -41,7 +41,8 @@ static void pm_enter(void)
 {
 	u8 stbcr, csr;
 	u16 frqcr, mcr;
-	u32 vbr_new, vbr_old;
+	void *vbr_new;
+	u32 vbr_old;
 
 	set_bl_bit();
 
@@ -68,9 +69,9 @@ static void pm_enter(void)
 
 	/* set interrupt handler */
 	asm volatile("stc vbr, %0" : "=r" (vbr_old));
-	vbr_new = (unsigned long)get_zeroed_page(GFP_ATOMIC);
+	vbr_new = get_zeroed_page(GFP_ATOMIC);
 	udelay(50);
-	memcpy((void*)(vbr_new + INTR_OFFSET),
+	memcpy(vbr_new + INTR_OFFSET,
 	       &wakeup_start, &wakeup_end - &wakeup_start);
 	asm volatile("ldc %0, vbr" : : "r" (vbr_new));
 
@@ -81,7 +82,7 @@ static void pm_enter(void)
 
 	asm volatile("ldc %0, vbr" : : "r" (vbr_old));
 
-	free_page((void *)vbr_new);
+	free_page(vbr_new);
 
 	/* enable PLL1 */
 	frqcr = __raw_readw(FRQCR);
Signature · 1 line
2.1.4
author maintainer
#67 lore raw

PATCH 56/83 amd_gart_64: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/x86/kernel/amd_gart_64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/amd_gart_64.c +2 -2
index 2ef2933..94da9dd 100644
@@ -736,7 +736,7 @@ int __init gart_iommu_init(void)
 	unsigned long iommu_start;
 	unsigned long aper_base, aper_size;
 	unsigned long start_pfn, end_pfn;
-	unsigned long scratch;
+	void *scratch;
 	long i;
 
 	if (!amd_nb_has_feature(AMD_NB_GART))
@@ -841,7 +841,7 @@ int __init gart_iommu_init(void)
 	 * Any prefetches that hit unmapped entries won't get an bus abort
 	 * then. (P2P bridge may be prefetching on DMA reads).
 	 */
-	scratch = (unsigned long)get_zeroed_page(GFP_KERNEL);
+	scratch = get_zeroed_page(GFP_KERNEL);
 	if (!scratch)
 		panic("Cannot allocate iommu scratch page");
 	gart_unmapped_entry = GPTE_ENCODE(__pa(scratch));
Signature · 1 line
2.1.4
author maintainer
#68 lore raw

PATCH 57/83 iwlegacy: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 drivers/net/wireless/iwlegacy/3945-mac.c |  2 +-
 drivers/net/wireless/iwlegacy/3945.c     |  2 +-
 drivers/net/wireless/iwlegacy/common.c   | 10 +++++-----
 drivers/net/wireless/iwlegacy/common.h   |  4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/wireless/iwlegacy/3945-mac.c +1 -1
index af1b3e6..d073676 100644
@@ -710,7 +710,7 @@ il3945_get_measurement(struct il_priv *il,
 	if (rc)
 		return rc;
 
-	pkt = (struct il_rx_pkt *)cmd.reply_page;
+	pkt = cmd.reply_page;
 	if (pkt->hdr.flags & IL_CMD_FAILED_MSK) {
 		IL_ERR("Bad return from N_RX_ON_ASSOC command\n");
 		rc = -EIO;
drivers/net/wireless/iwlegacy/3945.c +1 -1
index 93bdf68..1529bd6 100644
@@ -1704,7 +1704,7 @@ il3945_send_rxon_assoc(struct il_priv *il)
 	if (rc)
 		return rc;
 
-	pkt = (struct il_rx_pkt *)cmd.reply_page;
+	pkt = cmd.reply_page;
 	if (pkt->hdr.flags & IL_CMD_FAILED_MSK) {
 		IL_ERR("Bad return from C_RXON_ASSOC command\n");
 		rc = -EIO;
drivers/net/wireless/iwlegacy/common.c +5 -5
index 8871145..ebdd041 100644
@@ -384,7 +384,7 @@ cancel:
 fail:
 	if (cmd->reply_page) {
 		il_free_pages(il, cmd->reply_page);
-		cmd->reply_page = 0;
+		cmd->reply_page = NULL;
 	}
 out:
 	return ret;
@@ -1288,7 +1288,7 @@ il_send_scan_abort(struct il_priv *il)
 	if (ret)
 		return ret;
 
-	pkt = (struct il_rx_pkt *)cmd.reply_page;
+	pkt = cmd.reply_page;
 	if (pkt->u.status != CAN_ABORT_STATUS) {
 		/* The scan abort will return 1 for success or
 		 * 2 for "failure".  A failure condition can be
@@ -1870,7 +1870,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
 		return ret;
 
 	if (ret == 0) {
-		pkt = (struct il_rx_pkt *)cmd.reply_page;
+		pkt = cmd.reply_page;
 		ret = il_process_add_sta_resp(il, sta, pkt, true);
 	}
 	il_free_pages(il, cmd.reply_page);
@@ -2124,7 +2124,7 @@ il_send_remove_station(struct il_priv *il, const u8 * addr, int sta_id,
 	if (ret)
 		return ret;
 
-	pkt = (struct il_rx_pkt *)cmd.reply_page;
+	pkt = cmd.reply_page;
 	if (pkt->hdr.flags & IL_CMD_FAILED_MSK) {
 		IL_ERR("Bad return from C_REM_STA (0x%08X)\n", pkt->hdr.flags);
 		ret = -EIO;
@@ -3319,7 +3319,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb)
 
 	/* Input error checking is done when commands are added to queue. */
 	if (meta->flags & CMD_WANT_SKB) {
-		meta->source->reply_page = (unsigned long)rxb_addr(rxb);
+		meta->source->reply_page = rxb_addr(rxb);
 		rxb->page = NULL;
 	} else if (meta->callback)
 		meta->callback(il, cmd, pkt);
drivers/net/wireless/iwlegacy/common.h +2 -2
index 555bf02..6581df1 100644
@@ -576,7 +576,7 @@ struct il_device_cmd {
 
 struct il_host_cmd {
 	const void *data;
-	unsigned long reply_page;
+	struct il_rx_pkt *reply_page;
 	void (*callback) (struct il_priv *il, struct il_device_cmd *cmd,
 			  struct il_rx_pkt *pkt);
 	u32 flags;
@@ -1502,7 +1502,7 @@ __il_free_pages(struct il_priv *il, struct page *page)
 }
 
 static inline void
-il_free_pages(struct il_priv *il, unsigned long page)
+il_free_pages(struct il_priv *il, void *page)
 {
 	free_pages((void *)page, il->hw_params.rx_page_order);
 	il->alloc_rxb_page--;
Signature · 1 line
2.1.4
author maintainer
#69 lore raw

PATCH 58/83 iwlwifi: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 drivers/net/wireless/iwlwifi/iwl-trans.h | 4 ++--
 drivers/net/wireless/iwlwifi/pcie/tx.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/iwlwifi/iwl-trans.h +2 -2
index 8ccbda2..94d3c5b 100644
@@ -331,7 +331,7 @@ enum iwl_hcmd_dataflag {
 struct iwl_host_cmd {
 	const void *data[IWL_MAX_CMD_TBS_PER_TFD];
 	struct iwl_rx_packet *resp_pkt;
-	unsigned long _rx_page_addr;
+	void *_rx_page_addr;
 	u32 _rx_page_order;
 
 	u32 flags;
@@ -342,7 +342,7 @@ struct iwl_host_cmd {
 
 static inline void iwl_free_resp(struct iwl_host_cmd *cmd)
 {
-	free_pages((void *)cmd->_rx_page_addr, cmd->_rx_page_order);
+	free_pages(cmd->_rx_page_addr, cmd->_rx_page_order);
 }
 
 struct iwl_rx_cmd_buffer {
drivers/net/wireless/iwlwifi/pcie/tx.c +1 -1
index a8c8a4a..53f1380 100644
@@ -1634,7 +1634,7 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans,
 		struct page *p = rxb_steal_page(rxb);
 
 		meta->source->resp_pkt = pkt;
-		meta->source->_rx_page_addr = (unsigned long)page_address(p);
+		meta->source->_rx_page_addr = page_address(p);
 		meta->source->_rx_page_order = trans_pcie->rx_page_order;
 	}
 
Signature · 1 line
2.1.4
author maintainer
#70 lore raw

PATCH 59/83 add pointer-returning variants of __get_free_pages/__get_free_page

In reply to Al Viro

From: Al Viro <[email protected]>

---
 drivers/block/xen-blkback/blkback.c | 4 ++--
 drivers/xen/xen-scsiback.c          | 6 +++---
 include/linux/gfp.h                 | 9 +++++++--
 mm/page_alloc.c                     | 8 ++++----
 4 files changed, 16 insertions(+), 11 deletions(-)
drivers/block/xen-blkback/blkback.c +2 -2
index f909994..aa1c52a 100644
@@ -113,7 +113,7 @@ module_param(log_stats, int, 0644);
 /* Number of free pages to remove on each call to gnttab_free_pages */
 #define NUM_BATCH_FREE_PAGES 10
 
-static inline int get_free_page(struct xen_blkif *blkif, struct page **page)
+static inline int xen_get_free_page(struct xen_blkif *blkif, struct page **page)
 {
 	unsigned long flags;
 
@@ -819,7 +819,7 @@ again:
 			pages[i]->page = persistent_gnt->page;
 			pages[i]->persistent_gnt = persistent_gnt;
 		} else {
-			if (get_free_page(blkif, &pages[i]->page))
+			if (xen_get_free_page(blkif, &pages[i]->page))
 				goto out_of_memory;
 			addr = vaddr(pages[i]->page);
 			pages_to_gnt[segs_to_map] = pages[i]->page;
drivers/xen/xen-scsiback.c +3 -3
index 43bcae8..ebd2321 100644
@@ -229,7 +229,7 @@ static void put_free_pages(struct page **page, int num)
 	spin_unlock_irqrestore(&free_pages_lock, flags);
 }
 
-static int get_free_page(struct page **page)
+static int xen_get_free_page(struct page **page)
 {
 	unsigned long flags;
 
@@ -439,7 +439,7 @@ static int scsiback_gnttab_data_map_list(struct vscsibk_pend *pending_req,
 	struct vscsibk_info *info = pending_req->info;
 
 	for (i = 0; i < cnt; i++) {
-		if (get_free_page(pg + mapcount)) {
+		if (xen_get_free_page(pg + mapcount)) {
 			put_free_pages(pg, mapcount);
 			pr_err("no grant page\n");
 			return -ENOMEM;
@@ -1902,7 +1902,7 @@ static void __exit scsiback_exit(void)
 	struct page *page;
 
 	while (free_pages_num) {
-		if (get_free_page(&page))
+		if (xen_get_free_page(&page))
 			BUG();
 		gnttab_free_pages(1, &page);
 	}
include/linux/gfp.h +7 -2
index fc4529d..bb1626a 100644
@@ -473,18 +473,23 @@ extern struct page *alloc_kmem_pages(gfp_t gfp_mask, unsigned int order);
 extern struct page *alloc_kmem_pages_node(int nid, gfp_t gfp_mask,
 					  unsigned int order);
 
-extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order);
+extern void *get_free_pages(gfp_t gfp_mask, unsigned int order);
+#define __get_free_pages(gfp_mask, order) \
+	((unsigned long)get_free_pages(gfp_mask, order))
 extern void *get_zeroed_page(gfp_t gfp_mask);
 
 void *alloc_pages_exact(size_t size, gfp_t gfp_mask);
 void free_pages_exact(void *virt, size_t size);
 void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask);
 
+#define get_free_page(gfp_mask) \
+		get_free_pages((gfp_mask), 0)
+
 #define __get_free_page(gfp_mask) \
 		__get_free_pages((gfp_mask), 0)
 
 #define get_dma_pages(gfp_mask, order) \
-		((void *)__get_free_pages((gfp_mask) | GFP_DMA, (order)))
+		get_free_pages((gfp_mask) | GFP_DMA, (order))
 
 extern void __free_pages(struct page *page, unsigned int order);
 extern void free_pages(const void *addr, unsigned int order);
mm/page_alloc.c +4 -4
index a1aa8eb..9ab053f 100644
@@ -3257,7 +3257,7 @@ EXPORT_SYMBOL(__alloc_pages_nodemask);
 /*
  * Common helper functions.
  */
-unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
+void *get_free_pages(gfp_t gfp_mask, unsigned int order)
 {
 	struct page *page;
 
@@ -3269,10 +3269,10 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order)
 
 	page = alloc_pages(gfp_mask, order);
 	if (!page)
-		return 0;
-	return (unsigned long) page_address(page);
+		return NULL;
+	return page_address(page);
 }
-EXPORT_SYMBOL(__get_free_pages);
+EXPORT_SYMBOL(get_free_pages);
 
 void *get_zeroed_page(gfp_t gfp_mask)
 {
Signature · 1 line
2.1.4
author maintainer
#71 lore raw

PATCH 60/83 switch obvious cases to get_free_pages()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/alpha/include/asm/agp.h                       |  2 +-
 arch/alpha/kernel/pci-noop.c                       |  2 +-
 arch/alpha/kernel/pci_iommu.c                      |  2 +-
 arch/arc/include/asm/pgalloc.h                     |  6 +++---
 arch/arm/include/asm/tlb.h                         |  4 ++--
 arch/arm/kvm/mmu.c                                 |  4 ++--
 arch/arm/mm/pgd.c                                  |  2 +-
 arch/blackfin/include/asm/mmu_context.h            |  4 ++--
 arch/cris/arch-v32/drivers/pci/dma.c               |  2 +-
 arch/frv/mm/dma-alloc.c                            |  2 +-
 arch/h8300/kernel/dma.c                            |  2 +-
 arch/ia64/hp/common/sba_iommu.c                    | 10 ++++------
 arch/ia64/include/asm/agp.h                        |  2 +-
 arch/ia64/include/asm/tlb.h                        |  4 ++--
 arch/ia64/kernel/mca.c                             |  3 +--
 arch/ia64/sn/pci/pci_dma.c                         |  2 +-
 arch/m68k/kernel/dma.c                             |  2 +-
 arch/microblaze/include/asm/pgalloc.h              |  2 +-
 arch/microblaze/mm/consistent.c                    |  2 +-
 arch/mips/include/asm/pgalloc.h                    |  6 +++---
 arch/mips/jazz/jazzdma.c                           |  3 +--
 arch/mips/mm/dma-default.c                         |  2 +-
 arch/nios2/include/asm/pgalloc.h                   |  2 +-
 arch/nios2/mm/dma-mapping.c                        |  2 +-
 arch/nios2/mm/pgtable.c                            |  2 +-
 arch/parisc/include/asm/agp.h                      |  2 +-
 arch/parisc/include/asm/pgalloc.h                  |  6 ++----
 arch/parisc/kernel/pci-dma.c                       |  5 ++---
 arch/powerpc/include/asm/agp.h                     |  2 +-
 arch/powerpc/kernel/fadump.c                       |  2 +-
 arch/powerpc/kvm/book3s_64_mmu_hv.c                |  2 +-
 arch/powerpc/mm/pgtable_32.c                       |  2 +-
 arch/powerpc/platforms/cell/spufs/inode.c          |  2 +-
 arch/s390/hypfs/hypfs_diag.c                       |  2 +-
 arch/s390/include/asm/idals.h                      |  3 +--
 arch/s390/kernel/smp.c                             |  3 +--
 arch/s390/mm/vmem.c                                |  2 +-
 arch/s390/pci/pci_clp.c                            |  2 +-
 arch/score/include/asm/pgalloc.h                   |  4 ++--
 arch/sh/mm/consistent.c                            |  2 +-
 arch/sparc/include/asm/agp.h                       |  2 +-
 arch/sparc/kernel/ioport.c                         |  4 ++--
 arch/sparc/kernel/irq_64.c                         |  3 +--
 arch/sparc/kernel/ldc.c                            |  5 ++---
 arch/sparc/kernel/pci_fire.c                       |  2 +-
 arch/sparc/kernel/pci_sun4v.c                      |  2 +-
 arch/sparc/kernel/traps_64.c                       |  3 +--
 arch/um/drivers/net_kern.c                         |  2 +-
 arch/um/kernel/process.c                           |  2 +-
 arch/unicore32/mm/pgd.c                            |  2 +-
 arch/x86/include/asm/agp.h                         |  2 +-
 arch/x86/include/asm/xen/page-coherent.h           |  2 +-
 arch/x86/kernel/amd_gart_64.c                      |  4 ++--
 arch/x86/kernel/pci-calgary_64.c                   |  2 +-
 arch/x86/mm/init.c                                 |  2 +-
 arch/x86/platform/efi/efi.c                        |  2 +-
 arch/x86/um/ldt.c                                  |  3 +--
 arch/xtensa/include/asm/pgalloc.h                  |  2 +-
 crypto/xor.c                                       |  2 +-
 drivers/base/devres.c                              |  2 +-
 drivers/block/ps3vram.c                            |  3 +--
 drivers/block/xen-blkfront.c                       |  3 +--
 drivers/block/zram/zcomp.c                         |  2 +-
 drivers/char/agp/hp-agp.c                          |  2 +-
 drivers/char/agp/uninorth-agp.c                    |  2 +-
 drivers/crypto/atmel-aes.c                         |  4 ++--
 drivers/crypto/atmel-tdes.c                        |  4 ++--
 drivers/crypto/nx/nx-842.c                         |  4 ++--
 drivers/crypto/omap-aes.c                          |  4 ++--
 drivers/crypto/omap-des.c                          |  4 ++--
 drivers/dma/ste_dma40.c                            |  2 +-
 drivers/firmware/dell_rbu.c                        |  6 ++----
 drivers/gpu/drm/amd/amdkfd/kfd_events.c            |  2 +-
 drivers/hv/channel.c                               |  6 +++---
 drivers/hv/connection.c                            |  7 +++----
 drivers/iommu/amd_iommu_init.c                     | 16 ++++++++--------
 drivers/iommu/exynos-iommu.c                       |  4 ++--
 drivers/iommu/msm_iommu.c                          |  8 +++-----
 drivers/irqchip/irq-gic-v3-its.c                   |  2 +-
 drivers/md/bcache/bset.c                           |  8 ++++----
 drivers/md/bcache/btree.c                          |  3 +--
 drivers/md/bcache/journal.c                        |  4 ++--
 drivers/md/bcache/super.c                          |  2 +-
 drivers/md/dm-bufio.c                              |  3 +--
 drivers/media/pci/solo6x10/solo6x10-p2m.c          |  4 ++--
 drivers/media/platform/davinci/dm644x_ccdc.c       |  3 +--
 drivers/misc/cxl/native.c                          |  4 ++--
 drivers/misc/mic/card/mic_virtio.c                 |  2 +-
 drivers/misc/mic/host/mic_virtio.c                 |  5 ++---
 drivers/misc/mic/scif/scif_rma.h                   |  2 +-
 drivers/net/ethernet/cavium/liquidio/octeon_main.h |  4 +---
 drivers/net/ethernet/sgi/ioc3-eth.c                |  2 +-
 drivers/net/irda/au1k_ir.c                         |  2 +-
 drivers/net/rionet.c                               |  2 +-
 drivers/net/wireless/b43/debugfs.c                 |  2 +-
 drivers/net/wireless/b43legacy/debugfs.c           |  2 +-
 drivers/net/wireless/ti/wlcore/main.c              |  2 +-
 drivers/parisc/ccio-dma.c                          |  8 +++-----
 drivers/parisc/ccio-rm-dma.c                       |  2 +-
 drivers/parisc/sba_iommu.c                         |  7 +++----
 drivers/pci/host/pci-tegra.c                       |  2 +-
 drivers/pci/host/pcie-designware.c                 |  2 +-
 drivers/pci/host/pcie-rcar.c                       |  2 +-
 drivers/pci/host/pcie-xilinx.c                     |  2 +-
 drivers/s390/block/dasd.c                          |  2 +-
 drivers/s390/char/hmcdrv_cache.c                   |  2 +-
 drivers/s390/char/hmcdrv_ftp.c                     |  2 +-
 drivers/s390/char/tty3270.c                        |  4 ++--
 drivers/s390/char/vmcp.c                           |  2 +-
 drivers/s390/cio/cmf.c                             |  2 +-
 drivers/scsi/cxlflash/main.c                       |  2 +-
 drivers/scsi/libiscsi.c                            |  3 +--
 drivers/scsi/lpfc/lpfc_init.c                      |  6 ++----
 drivers/scsi/megaraid/megaraid_sas_base.c          |  2 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c        |  4 ++--
 drivers/scsi/mpt3sas/mpt3sas_base.c                |  5 ++---
 drivers/scsi/sym53c8xx_2/sym_hipd.h                |  2 +-
 drivers/scsi/vmw_pvscsi.c                          |  3 +--
 drivers/sh/maple/maple.c                           |  3 +--
 drivers/usb/core/devices.c                         |  2 +-
 drivers/video/fbdev/fb-puv3.c                      |  2 +-
 drivers/video/fbdev/ssd1307fb.c                    |  2 +-
 fs/ceph/mds_client.c                               |  3 +--
 fs/configfs/file.c                                 |  2 +-
 fs/hfs/mdb.c                                       |  2 +-
 fs/jbd2/journal.c                                  |  4 ++--
 fs/nilfs2/ioctl.c                                  |  2 +-
 fs/proc/vmcore.c                                   |  4 ++--
 fs/quota/dquot.c                                   |  2 +-
 kernel/trace/ftrace.c                              |  2 +-
 kernel/trace/trace_events.c                        |  6 ++----
 lib/percpu_ida.c                                   |  2 +-
 lib/raid6/algos.c                                  |  2 +-
 lib/swiotlb.c                                      | 12 +++++-------
 mm/memory.c                                        |  2 +-
 mm/page_alloc.c                                    |  4 ++--
 mm/slub.c                                          |  2 +-
 net/core/neighbour.c                               |  3 +--
 net/dccp/proto.c                                   |  8 ++++----
 net/decnet/dn_route.c                              |  3 +--
 net/ipv4/fib_semantics.c                           |  3 +--
 net/netfilter/nf_conntrack_core.c                  |  2 +-
 net/netlink/af_netlink.c                           |  4 ++--
 net/packet/af_packet.c                             |  4 ++--
 net/sched/sch_api.c                                |  3 +--
 net/sctp/protocol.c                                |  8 ++++----
 net/sctp/ssnmap.c                                  |  3 +--
 net/xfrm/xfrm_hash.c                               |  3 +--
 security/integrity/ima/ima_crypto.c                |  4 ++--
 sound/core/memalloc.c                              |  2 +-
 sound/oss/dmabuf.c                                 |  2 +-
 sound/usb/usx2y/usb_stream.c                       |  5 ++---
 152 files changed, 222 insertions(+), 269 deletions(-)
arch/alpha/include/asm/agp.h +1 -1
index 2fe5800..6179691 100644
@@ -11,7 +11,7 @@
 
 /* GATT allocation. Returns/accepts GATT kernel virtual address. */
 #define alloc_gatt_pages(order)		\
-	((char *)__get_free_pages(GFP_KERNEL, (order)))
+	((char *)get_free_pages(GFP_KERNEL, (order)))
 #define free_gatt_pages(table, order)	\
 	free_pages((table), (order))
 
arch/alpha/kernel/pci-noop.c +1 -1
index d3bcb88..543e3e7 100644
@@ -115,7 +115,7 @@ static void *alpha_noop_alloc_coherent(struct device *dev, size_t size,
 
 	if (!dev || *dev->dma_mask >= 0xffffffffUL)
 		gfp &= ~GFP_DMA;
-	ret = (void *)__get_free_pages(gfp, get_order(size));
+	ret = get_free_pages(gfp, get_order(size));
 	if (ret) {
 		memset(ret, 0, size);
 		*dma_handle = virt_to_phys(ret);
arch/alpha/kernel/pci_iommu.c +1 -1
index fb0b20ee..b9b910f 100644
@@ -442,7 +442,7 @@ static void *alpha_pci_alloc_coherent(struct device *dev, size_t size,
 	gfp &= ~GFP_DMA;
 
 try_again:
-	cpu_addr = (void *)__get_free_pages(gfp, order);
+	cpu_addr = get_free_pages(gfp, order);
 	if (! cpu_addr) {
 		printk(KERN_INFO "pci_alloc_consistent: "
 		       "get_free_pages failed from %pf\n",
arch/arc/include/asm/pgalloc.h +3 -3
index 1200117..a540e9b 100644
@@ -55,7 +55,7 @@ static inline int __get_order_pgd(void)
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	int num, num2;
-	pgd_t *ret = (pgd_t *) __get_free_pages(GFP_KERNEL, __get_order_pgd());
+	pgd_t *ret = get_free_pages(GFP_KERNEL, __get_order_pgd());
 
 	if (ret) {
 		num = USER_PTRS_PER_PGD + USER_KERNEL_GUTTER / PGDIR_SIZE;
@@ -95,7 +95,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_pages(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO,
+	pte = get_free_pages(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO,
 					 __get_order_pte());
 
 	return pte;
@@ -107,7 +107,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long address)
 	pgtable_t pte_pg;
 	struct page *page;
 
-	pte_pg = (pgtable_t)__get_free_pages(GFP_KERNEL | __GFP_REPEAT, __get_order_pte());
+	pte_pg = get_free_pages(GFP_KERNEL | __GFP_REPEAT, __get_order_pte());
 	if (!pte_pg)
 		return 0;
 	memzero((void *)pte_pg, PTRS_PER_PTE * sizeof(pte_t));
arch/arm/include/asm/tlb.h +2 -2
index c8611f2..21300f4 100644
@@ -117,10 +117,10 @@ static inline void tlb_add_flush(struct mmu_gather *tlb, unsigned long addr)
 
 static inline void __tlb_alloc_page(struct mmu_gather *tlb)
 {
-	unsigned long addr = __get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
+	void *addr = get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
 
 	if (addr) {
-		tlb->pages = (void *)addr;
+		tlb->pages = addr;
 		tlb->max = PAGE_SIZE / sizeof(struct page *);
 	}
 }
arch/arm/kvm/mmu.c +2 -2
index 190e9fb..429b673 100644
@@ -1657,8 +1657,8 @@ int kvm_mmu_init(void)
 	 */
 	BUG_ON((hyp_idmap_start ^ (hyp_idmap_end - 1)) & PAGE_MASK);
 
-	hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, hyp_pgd_order);
-	boot_hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, hyp_pgd_order);
+	hyp_pgd = get_free_pages(GFP_KERNEL | __GFP_ZERO, hyp_pgd_order);
+	boot_hyp_pgd = get_free_pages(GFP_KERNEL | __GFP_ZERO, hyp_pgd_order);
 
 	if (!hyp_pgd || !boot_hyp_pgd) {
 		kvm_err("Hyp mode PGD not allocated\n");
arch/arm/mm/pgd.c +1 -1
index b8799fa..f65e684 100644
@@ -23,7 +23,7 @@
 #define __pgd_alloc()	kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL)
 #define __pgd_free(pgd)	kfree(pgd)
 #else
-#define __pgd_alloc()	(pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_REPEAT, 2)
+#define __pgd_alloc()	get_free_pages(GFP_KERNEL | __GFP_REPEAT, 2)
 #define __pgd_free(pgd)	free_pages(pgd, 2)
 #endif
 
arch/blackfin/include/asm/mmu_context.h +2 -2
index 198cb70..75147aa 100644
@@ -173,8 +173,8 @@ static inline int
 init_new_context(struct task_struct *tsk, struct mm_struct *mm)
 {
 #ifdef CONFIG_MPU
-	unsigned long p = __get_free_pages(GFP_KERNEL, page_mask_order);
-	mm->context.page_rwx_mask = (unsigned long *)p;
+	unsigned long *p = get_free_pages(GFP_KERNEL, page_mask_order);
+	mm->context.page_rwx_mask = p;
 	memset(mm->context.page_rwx_mask, 0,
 	       page_mask_nelts * 3 * sizeof(long));
 #endif
arch/cris/arch-v32/drivers/pci/dma.c +1 -1
index 9b43cec..979a2c7 100644
@@ -30,7 +30,7 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
 
-	ret = (void *)__get_free_pages(gfp, order);
+	ret = get_free_pages(gfp, order);
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
arch/frv/mm/dma-alloc.c +1 -1
index 62268e1..60dea14 100644
@@ -93,7 +93,7 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 	size = PAGE_ALIGN(size);
 	order = get_order(size);
 
-	page = (void *)__get_free_pages(gfp, order);
+	page = get_free_pages(gfp, order);
 	if (!page) {
 		BUG();
 		return NULL;
arch/h8300/kernel/dma.c +1 -1
index 063a0f5..3092f45 100644
@@ -21,7 +21,7 @@ static void *dma_alloc(struct device *dev, size_t size,
 
 	if (dev == NULL || (*dev->dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
-	ret = (void *)__get_free_pages(gfp, get_order(size));
+	ret = get_free_pages(gfp, get_order(size));
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
arch/ia64/hp/common/sba_iommu.c +4 -6
index 2988500..c721949 100644
@@ -1149,7 +1149,7 @@ sba_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
 		addr = page_address(page);
 	}
 #else
-	addr = (void *) __get_free_pages(flags, get_order(size));
+	addr = get_free_pages(flags, get_order(size));
 #endif
 	if (unlikely(!addr))
 		return NULL;
@@ -1631,8 +1631,7 @@ ioc_iova_init(struct ioc *ioc)
 	WRITE_REG(tcnfg, ioc->ioc_hpa + IOC_TCNFG);
 
 	ioc->pdir_size = (ioc->iov_size / iovp_size) * PDIR_ENTRY_SIZE;
-	ioc->pdir_base = (void *) __get_free_pages(GFP_KERNEL,
-						   get_order(ioc->pdir_size));
+	ioc->pdir_base = get_free_pages(GFP_KERNEL, get_order(ioc->pdir_size));
 	if (!ioc->pdir_base)
 		panic(PFX "Couldn't allocate I/O Page Table\n");
 
@@ -1671,7 +1670,7 @@ ioc_iova_init(struct ioc *ioc)
 		int poison_size = 16;
 		void *poison_addr, *addr;
 
-		addr = (void *)__get_free_pages(GFP_KERNEL, get_order(iovp_size));
+		addr = get_free_pages(GFP_KERNEL, get_order(iovp_size));
 		if (!addr)
 			panic(PFX "Couldn't allocate PDIR spill page\n");
 
@@ -1712,8 +1711,7 @@ ioc_resource_init(struct ioc *ioc)
 	ioc->res_size >>= 3;  /* convert bit count to byte count */
 	DBG_INIT("%s() res_size 0x%x\n", __func__, ioc->res_size);
 
-	ioc->res_map = (char *) __get_free_pages(GFP_KERNEL,
-						 get_order(ioc->res_size));
+	ioc->res_map = get_free_pages(GFP_KERNEL, get_order(ioc->res_size));
 	if (!ioc->res_map)
 		panic(PFX "Couldn't allocate resource map\n");
 
arch/ia64/include/asm/agp.h +1 -1
index 80c30d4..4f360b9 100644
@@ -19,7 +19,7 @@
 
 /* GATT allocation. Returns/accepts GATT kernel virtual address. */
 #define alloc_gatt_pages(order)		\
-	((char *)__get_free_pages(GFP_KERNEL, (order)))
+	((char *)get_free_pages(GFP_KERNEL, (order)))
 #define free_gatt_pages(table, order)	\
 	free_pages((table), (order))
 
arch/ia64/include/asm/tlb.h +2 -2
index 52ab3a9..06dc9e3 100644
@@ -158,10 +158,10 @@ ia64_tlb_flush_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long e
 
 static inline void __tlb_alloc_page(struct mmu_gather *tlb)
 {
-	unsigned long addr = __get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
+	void *addr = get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
 
 	if (addr) {
-		tlb->pages = (void *)addr;
+		tlb->pages = addr;
 		tlb->max = PAGE_SIZE / sizeof(void *);
 	}
 }
arch/ia64/kernel/mca.c +1 -2
index 2889412..2648a6f 100644
@@ -1858,8 +1858,7 @@ ia64_mca_cpu_init(void *cpu_data)
 			data = mca_bootmem();
 			first_time = 0;
 		} else
-			data = (void *)__get_free_pages(GFP_KERNEL,
-							get_order(sz));
+			data = get_free_pages(GFP_KERNEL, get_order(sz));
 		if (!data)
 			panic("Could not allocate MCA memory for cpu %d\n",
 					cpu);
arch/ia64/sn/pci/pci_dma.c +1 -1
index f25c898..2126b54 100644
@@ -100,7 +100,7 @@ static void *sn_dma_alloc_coherent(struct device *dev, size_t size,
 		else
 			return NULL;
 	} else
-		cpuaddr = (void *)__get_free_pages(flags, get_order(size));
+		cpuaddr = get_free_pages(flags, get_order(size));
 
 	if (unlikely(!cpuaddr))
 		return NULL;
arch/m68k/kernel/dma.c +1 -1
index 2bdf7bf..da443983 100644
@@ -81,7 +81,7 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 
 	if (dev == NULL || (*dev->dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
-	ret = (void *)__get_free_pages(gfp, get_order(size));
+	ret = get_free_pages(gfp, get_order(size));
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
arch/microblaze/include/asm/pgalloc.h +1 -1
index 5e3fc6c..13030db 100644
@@ -64,7 +64,7 @@ static inline pgd_t *get_pgd_slow(void)
 {
 	pgd_t *ret;
 
-	ret = (pgd_t *)__get_free_pages(GFP_KERNEL, PGDIR_ORDER);
+	ret = get_free_pages(GFP_KERNEL, PGDIR_ORDER);
 	if (ret != NULL)
 		clear_page(ret);
 	return ret;
arch/microblaze/mm/consistent.c +1 -1
index bdeb2cb..335f006 100644
@@ -79,7 +79,7 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 	size = PAGE_ALIGN(size);
 	order = get_order(size);
 
-	vaddr = (void *)__get_free_pages(gfp, order);
+	vaddr = get_free_pages(gfp, order);
 	if (!vaddr)
 		return NULL;
 
arch/mips/include/asm/pgalloc.h +3 -3
index e29cc40..820ca21 100644
@@ -48,7 +48,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = get_free_pages(GFP_KERNEL, PGD_ORDER);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init((unsigned long)ret);
@@ -69,7 +69,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
+	pte = get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, PTE_ORDER);
 
 	return pte;
 }
@@ -113,7 +113,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
 	pmd_t *pmd;
 
-	pmd = (pmd_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT, PMD_ORDER);
+	pmd = get_free_pages(GFP_KERNEL|__GFP_REPEAT, PMD_ORDER);
 	if (pmd)
 		pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
 	return pmd;
arch/mips/jazz/jazzdma.c +1 -2
index db6f5af..8f65436 100644
@@ -67,8 +67,7 @@ static int __init vdma_init(void)
 	 * aligned and should be uncached to avoid cache flushing after every
 	 * update.
 	 */
-	pgtbl = (VDMA_PGTBL_ENTRY *)__get_free_pages(GFP_KERNEL | GFP_DMA,
-						    get_order(VDMA_PGTBL_SIZE));
+	pgtbl = get_free_pages(GFP_KERNEL | GFP_DMA, get_order(VDMA_PGTBL_SIZE));
 	BUG_ON(!pgtbl);
 	dma_cache_wback_inv((unsigned long)pgtbl, VDMA_PGTBL_SIZE);
 	pgtbl = (VDMA_PGTBL_ENTRY *)KSEG1ADDR(pgtbl);
arch/mips/mm/dma-default.c +1 -1
index d3c1cec..c0863e9 100644
@@ -119,7 +119,7 @@ static void *mips_dma_alloc_noncoherent(struct device *dev, size_t size,
 
 	gfp = massage_gfp_flags(dev, gfp);
 
-	ret = (void *) __get_free_pages(gfp, get_order(size));
+	ret = get_free_pages(gfp, get_order(size));
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
arch/nios2/include/asm/pgalloc.h +1 -1
index 91cd323..12cfc5e 100644
@@ -42,7 +42,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO,
+	pte = get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO,
 					PTE_ORDER);
 
 	return pte;
arch/nios2/mm/dma-mapping.c +1 -1
index 0195f8f..7efef15 100644
@@ -35,7 +35,7 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 	if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
 		gfp |= GFP_DMA;
 
-	ret = (void *) __get_free_pages(gfp, get_order(size));
+	ret = get_free_pages(gfp, get_order(size));
 	if (ret != NULL) {
 		*dma_handle = virt_to_phys(ret);
 		flush_dcache_range((unsigned long) ret,
arch/nios2/mm/pgtable.c +1 -1
index 61e24a2..9af52c7 100644
@@ -55,7 +55,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = get_free_pages(GFP_KERNEL, PGD_ORDER);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init(ret);
arch/parisc/include/asm/agp.h +1 -1
index 31f67a5..4ecd394 100644
@@ -13,7 +13,7 @@
 
 /* GATT allocation. Returns/accepts GATT kernel virtual address. */
 #define alloc_gatt_pages(order)		\
-	((char *)__get_free_pages(GFP_KERNEL, (order)))
+	((char *)get_free_pages(GFP_KERNEL, (order)))
 #define free_gatt_pages(table, order)	\
 	free_pages((table), (order))
 
arch/parisc/include/asm/pgalloc.h +2 -4
index 51cb827..5c10934 100644
@@ -20,8 +20,7 @@
  * kernel for machines with under 4GB of memory) */
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-	pgd_t *pgd = (pgd_t *)__get_free_pages(GFP_KERNEL,
-					       PGD_ALLOC_ORDER);
+	pgd_t *pgd = get_free_pages(GFP_KERNEL, PGD_ALLOC_ORDER);
 	pgd_t *actual_pgd = pgd;
 
 	if (likely(pgd != NULL)) {
@@ -63,8 +62,7 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
-					       PMD_ORDER);
+	pmd_t *pmd = get_free_pages(GFP_KERNEL|__GFP_REPEAT, PMD_ORDER);
 	if (pmd)
 		memset(pmd, 0, PAGE_SIZE<<PMD_ORDER);
 	return pmd;
arch/parisc/kernel/pci-dma.c +2 -3
index 3c4ebba..6f15633 100644
@@ -393,8 +393,7 @@ pcxl_dma_init(void)
 	spin_lock_init(&pcxl_res_lock);
 	pcxl_res_size = PCXL_DMA_MAP_SIZE >> (PAGE_SHIFT + 3);
 	pcxl_res_hint = 0;
-	pcxl_res_map = (char *)__get_free_pages(GFP_KERNEL,
-					    get_order(pcxl_res_size));
+	pcxl_res_map = get_free_pages(GFP_KERNEL, get_order(pcxl_res_size));
 	memset(pcxl_res_map, 0, pcxl_res_size);
 	proc_gsc_root = proc_mkdir("gsc", NULL);
 	if (!proc_gsc_root)
@@ -571,7 +570,7 @@ static void *pa11_dma_alloc_noncoherent(struct device *dev, size_t size,
 {
 	void *addr;
 
-	addr = (void *)__get_free_pages(flag, get_order(size));
+	addr = get_free_pages(flag, get_order(size));
 	if (addr)
 		*dma_handle = (dma_addr_t)virt_to_phys(addr);
 
arch/powerpc/include/asm/agp.h +1 -1
index 06df165..3c16089 100644
@@ -10,7 +10,7 @@
 
 /* GATT allocation. Returns/accepts GATT kernel virtual address. */
 #define alloc_gatt_pages(order)		\
-	((char *)__get_free_pages(GFP_KERNEL, (order)))
+	((char *)get_free_pages(GFP_KERNEL, (order)))
 #define free_gatt_pages(table, order)	\
 	free_pages((table), (order))
 
arch/powerpc/kernel/fadump.c +1 -1
index 26d091a..63fdb91 100644
@@ -551,7 +551,7 @@ static void *fadump_cpu_notes_buf_alloc(unsigned long size)
 	unsigned long order, count, i;
 
 	order = get_order(size);
-	vaddr = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
+	vaddr = get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
 	if (!vaddr)
 		return NULL;
 
arch/powerpc/kvm/book3s_64_mmu_hv.c +1 -1
index 3dd6f8e..3e5c71c 100644
@@ -72,7 +72,7 @@ long kvmppc_alloc_hpt(struct kvm *kvm, u32 *htab_orderp)
 	/* Lastly try successively smaller sizes from the page allocator */
 	/* Only do this if userspace didn't specify a size via ioctl */
 	while (!hpt && order > PPC_MIN_HPT_ORDER && !htab_orderp) {
-		hpt = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO|
+		hpt = get_free_pages(GFP_KERNEL|__GFP_ZERO|
 					__GFP_REPEAT| __GFP_NOWARN,
 					order - PAGE_SHIFT);
 		if (!hpt)
arch/powerpc/mm/pgtable_32.c +1 -1
index 89bfc17..6e6c311 100644
@@ -89,7 +89,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
 #ifndef CONFIG_PPC_4K_PAGES
 	ret = kmem_cache_alloc(pgtable_cache, GFP_KERNEL | __GFP_ZERO);
 #else
-	ret = (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
+	ret = get_free_pages(GFP_KERNEL|__GFP_ZERO,
 			PGDIR_ORDER - PAGE_SHIFT);
 #endif
 	return ret;
arch/powerpc/platforms/cell/spufs/inode.c +1 -1
index 14a47f9..9ef5a940 100644
@@ -668,7 +668,7 @@ spufs_init_isolated_loader(void)
 		return;
 
 	/* the loader must be align on a 16 byte boundary */
-	isolated_loader = (char *)__get_free_pages(GFP_KERNEL, get_order(size));
+	isolated_loader = get_free_pages(GFP_KERNEL, get_order(size));
 	if (!isolated_loader)
 		return;
 
arch/s390/hypfs/hypfs_diag.c +1 -1
index 08f71f8..dda5bf0 100644
@@ -396,7 +396,7 @@ static void *diag204_alloc_vbuf(int pages)
 
 static void *diag204_alloc_rbuf(void)
 {
-	diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0);
+	diag204_buf = get_free_pages(GFP_KERNEL,0);
 	if (!diag204_buf)
 		return ERR_PTR(-ENOMEM);
 	diag204_buf_pages = 1;
arch/s390/include/asm/idals.h +1 -2
index 56b1baf..cdbf89a 100644
@@ -132,8 +132,7 @@ idal_buffer_alloc(size_t size, int page_order)
 			ib->data[i] = ib->data[i-1] + IDA_BLOCK_SIZE;
 			continue;
 		}
-		ib->data[i] = (void *)
-			__get_free_pages(GFP_KERNEL, page_order);
+		ib->data[i] = get_free_pages(GFP_KERNEL, page_order);
 		if (ib->data[i] != NULL)
 			continue;
 		// Not enough memory
arch/s390/kernel/smp.c +1 -2
index 63c1c8c..34a5041 100644
@@ -183,8 +183,7 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
 	struct _lowcore *lc;
 
 	if (pcpu != &pcpu_devices[0]) {
-		pcpu->lowcore =	(struct _lowcore *)
-			__get_free_pages(GFP_KERNEL | GFP_DMA, LC_ORDER);
+		pcpu->lowcore =	get_free_pages(GFP_KERNEL | GFP_DMA, LC_ORDER);
 		async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
 		panic_stack = __get_free_page(GFP_KERNEL);
 		if (!pcpu->lowcore || !panic_stack || !async_stack)
arch/s390/mm/vmem.c +1 -1
index ef7d6c8..44cb4af 100644
@@ -30,7 +30,7 @@ static LIST_HEAD(mem_segs);
 static void __ref *vmem_alloc_pages(unsigned int order)
 {
 	if (slab_is_available())
-		return (void *)__get_free_pages(GFP_KERNEL, order);
+		return get_free_pages(GFP_KERNEL, order);
 	return alloc_bootmem_pages((1 << order) * PAGE_SIZE);
 }
 
arch/s390/pci/pci_clp.c +1 -1
index 5914a16..162d9b6 100644
@@ -48,7 +48,7 @@ static inline u8 clp_instr(void *data)
 
 static void *clp_alloc_block(gfp_t gfp_mask)
 {
-	return (void *) __get_free_pages(gfp_mask, get_order(CLP_BLK_SIZE));
+	return get_free_pages(gfp_mask, get_order(CLP_BLK_SIZE));
 }
 
 static void clp_free_block(void *ptr)
arch/score/include/asm/pgalloc.h +2 -2
index 55fb080..6e07805 100644
@@ -21,7 +21,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
+	ret = get_free_pages(GFP_KERNEL, PGD_ORDER);
 	if (ret) {
 		init = pgd_offset(&init_mm, 0UL);
 		pgd_init((unsigned long)ret);
@@ -42,7 +42,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO,
+	pte = get_free_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO,
 					PTE_ORDER);
 
 	return pte;
arch/sh/mm/consistent.c +1 -1
index 4721e24..6324c40 100644
@@ -41,7 +41,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
 
 	gfp |= __GFP_ZERO;
 
-	ret = (void *)__get_free_pages(gfp, order);
+	ret = get_free_pages(gfp, order);
 	if (!ret)
 		return NULL;
 
arch/sparc/include/asm/agp.h +1 -1
index 363d3e6..dd31037 100644
@@ -9,7 +9,7 @@
 
 /* GATT allocation. Returns/accepts GATT kernel virtual address. */
 #define alloc_gatt_pages(order)		\
-	((char *)__get_free_pages(GFP_KERNEL, (order)))
+	((char *)get_free_pages(GFP_KERNEL, (order)))
 #define free_gatt_pages(table, order)	\
 	free_pages((table), (order))
 
arch/sparc/kernel/ioport.c +2 -2
index 3bd3481..1ff0516 100644
@@ -278,7 +278,7 @@ static void *sbus_alloc_coherent(struct device *dev, size_t len,
 	}
 
 	order = get_order(len_total);
-	va = (void *)__get_free_pages(gfp, order);
+	va = get_free_pages(gfp, order);
 	if (!va)
 		goto err_nopages;
 
@@ -444,7 +444,7 @@ static void *pci32_alloc_coherent(struct device *dev, size_t len,
 	}
 
 	order = get_order(len_total);
-	va = (void *) __get_free_pages(gfp, order);
+	va = get_free_pages(gfp, order);
 	if (va == NULL) {
 		printk("pci_alloc_consistent: no %ld pages\n", len_total>>PAGE_SHIFT);
 		goto err_nopages;
arch/sparc/kernel/irq_64.c +1 -2
index e2d198d..8858bb0 100644
@@ -1095,8 +1095,7 @@ static void __init irq_ivector_init(void)
 	ivecs = size_nr_ivec();
 	size = sizeof(struct ino_bucket) * ivecs;
 	order = get_order(size);
-	ivector_table = (struct ino_bucket *)
-		__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
+	ivector_table = get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 	if (!ivector_table) {
 		prom_printf("Fatal error, cannot allocate ivector_table\n");
 		prom_halt();
arch/sparc/kernel/ldc.c +2 -3
index 1cba9b7..05fe8eb 100644
@@ -975,7 +975,7 @@ static int alloc_queue(const char *name, unsigned long num_entries,
 	size = num_entries * LDC_PACKET_SIZE;
 	order = get_order(size);
 
-	q = (void *) __get_free_pages(GFP_KERNEL, order);
+	q = get_free_pages(GFP_KERNEL, order);
 	if (!q) {
 		printk(KERN_ERR PFX "Alloc of %s queue failed with "
 		       "size=%lu order=%lu\n", name, size, order);
@@ -1059,8 +1059,7 @@ static int ldc_iommu_init(const char *name, struct ldc_channel *lp)
 
 	order = get_order(tsbsize);
 
-	table = (struct ldc_mtable_entry *)
-		__get_free_pages(GFP_KERNEL, order);
+	table = get_free_pages(GFP_KERNEL, order);
 	err = -ENOMEM;
 	if (!table) {
 		printk(KERN_ERR PFX "Alloc of MTE table failed, "
arch/sparc/kernel/pci_fire.c +1 -1
index ff44386..59c96bf 100644
@@ -232,7 +232,7 @@ static int pci_fire_msiq_alloc(struct pci_pbm_info *pbm)
 	void *pages;
 
 	order = get_order(512 * 1024);
-	pages = (void *)__get_free_pages(GFP_KERNEL | __GFP_COMP, order);
+	pages = get_free_pages(GFP_KERNEL | __GFP_COMP, order);
 	if (!pages) {
 		printk(KERN_ERR "MSI: Cannot allocate MSI queues (o=%lu).\n",
 		       order);
arch/sparc/kernel/pci_sun4v.c +1 -1
index 9d84e4e..d700a73 100644
@@ -753,7 +753,7 @@ static int pci_sun4v_msiq_alloc(struct pci_pbm_info *pbm)
 	q_size = pbm->msiq_ent_count * sizeof(struct pci_sun4v_msiq_entry);
 	alloc_size = (pbm->msiq_num * q_size);
 	order = get_order(alloc_size);
-	pages = (void *)__get_free_pages(GFP_KERNEL | __GFP_COMP, order);
+	pages = get_free_pages(GFP_KERNEL | __GFP_COMP, order);
 	if (!pages) {
 		printk(KERN_ERR "MSI: Cannot allocate MSI queues (o=%lu).\n",
 		       order);
arch/sparc/kernel/traps_64.c +1 -2
index d21cd62..cc04b28 100644
@@ -872,8 +872,7 @@ void __init cheetah_ecache_flush_init(void)
 		if ((PAGE_SIZE << order) >= sz)
 			break;
 	}
-	cheetah_error_log = (struct cheetah_err_info *)
-		__get_free_pages(GFP_KERNEL, order);
+	cheetah_error_log = get_free_pages(GFP_KERNEL, order);
 	if (!cheetah_error_log) {
 		prom_printf("cheetah_ecache_flush_init: Failed to allocate "
 			    "error logging scoreboard (%d bytes).\n", sz);
arch/um/drivers/net_kern.c +1 -1
index 504f60b..3d2ced3 100644
@@ -880,7 +880,7 @@ void *get_output_buffer(int *len_out)
 {
 	void *ret;
 
-	ret = (void *) __get_free_pages(GFP_KERNEL, 0);
+	ret = get_free_pages(GFP_KERNEL, 0);
 	if (ret) *len_out = PAGE_SIZE;
 	else *len_out = 0;
 	return ret;
arch/um/kernel/process.c +1 -1
index 69c8d56..05826e3 100644
@@ -66,7 +66,7 @@ void *alloc_stack(int order, int atomic)
 
 	if (atomic)
 		flags = GFP_ATOMIC;
-	return (void *)__get_free_pages(flags, order);
+	return get_free_pages(flags, order);
 }
 
 static inline void set_current(struct task_struct *task)
arch/unicore32/mm/pgd.c +1 -1
index 9485183..cf141a1c 100644
@@ -30,7 +30,7 @@ pgd_t *get_pgd_slow(struct mm_struct *mm)
 	pmd_t *new_pmd, *init_pmd;
 	pte_t *new_pte, *init_pte;
 
-	new_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL, 0);
+	new_pgd = get_free_pages(GFP_KERNEL, 0);
 	if (!new_pgd)
 		goto no_pgd;
 
arch/x86/include/asm/agp.h +1 -1
index 4f98370..84a43f3 100644
@@ -24,7 +24,7 @@
 
 /* GATT allocation. Returns/accepts GATT kernel virtual address. */
 #define alloc_gatt_pages(order)		\
-	((char *)__get_free_pages(GFP_KERNEL, (order)))
+	((char *)get_free_pages(GFP_KERNEL, (order)))
 #define free_gatt_pages(table, order)	\
 	free_pages((table), (order))
 
arch/x86/include/asm/xen/page-coherent.h +1 -1
index 8a55a89..1de4d93 100644
@@ -9,7 +9,7 @@ static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size,
 		dma_addr_t *dma_handle, gfp_t flags,
 		struct dma_attrs *attrs)
 {
-	void *vstart = (void*)__get_free_pages(flags, get_order(size));
+	void *vstart = get_free_pages(flags, get_order(size));
 	*dma_handle = virt_to_phys(vstart);
 	return vstart;
 }
arch/x86/kernel/amd_gart_64.c +2 -2
index 94da9dd..5bc0312 100644
@@ -671,7 +671,7 @@ static __init int init_amd_gatt(struct agp_kern_info *info)
 	info->aper_size = aper_size >> 20;
 
 	gatt_size = (aper_size >> PAGE_SHIFT) * sizeof(u32);
-	gatt = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	gatt = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					get_order(gatt_size));
 	if (!gatt)
 		panic("Cannot allocate GATT table");
@@ -776,7 +776,7 @@ int __init gart_iommu_init(void)
 	iommu_size = check_iommu_size(info.aper_base, aper_size);
 	iommu_pages = iommu_size >> PAGE_SHIFT;
 
-	iommu_gart_bitmap = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	iommu_gart_bitmap = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 						      get_order(iommu_pages/8));
 	if (!iommu_gart_bitmap)
 		panic("Cannot allocate iommu bitmap\n");
arch/x86/kernel/pci-calgary_64.c +1 -1
index 97e092d..738ed3e 100644
@@ -446,7 +446,7 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size,
 	flag &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
 
 	/* alloc enough pages (and possibly more) */
-	ret = (void *)__get_free_pages(flag, order);
+	ret = get_free_pages(flag, order);
 	if (!ret)
 		goto error;
 	memset(ret, 0, size);
arch/x86/mm/init.c +1 -1
index 493f541..bce45cf 100644
@@ -89,7 +89,7 @@ __ref void *alloc_low_pages(unsigned int num)
 		unsigned int order;
 
 		order = get_order((unsigned long)num << PAGE_SHIFT);
-		return (void *)__get_free_pages(GFP_ATOMIC | __GFP_NOTRACK |
+		return get_free_pages(GFP_ATOMIC | __GFP_NOTRACK |
 						__GFP_ZERO, order);
 	}
 
arch/x86/platform/efi/efi.c +1 -1
index ed873dd..0478d9f 100644
@@ -687,7 +687,7 @@ static void *realloc_pages(void *old_memmap, int old_shift)
 {
 	void *ret;
 
-	ret = (void *)__get_free_pages(GFP_KERNEL, old_shift + 1);
+	ret = get_free_pages(GFP_KERNEL, old_shift + 1);
 	if (!ret)
 		goto out;
 
arch/x86/um/ldt.c +1 -2
index 52e173d..5264f55 100644
@@ -247,8 +247,7 @@ static void ldt_get_host_info(void)
 	for (i = LDT_PAGES_MAX-1, order=0; i; i>>=1, order++)
 		;
 
-	ldt = (struct ldt_entry *)
-	      __get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
+	ldt = get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
 	if (ldt == NULL) {
 		printk(KERN_ERR "ldt_get_host_info: couldn't allocate buffer "
 		       "for host ldt\n");
arch/xtensa/include/asm/pgalloc.h +1 -1
index 022b9b3..2a7631f 100644
@@ -30,7 +30,7 @@
 static inline pgd_t*
 pgd_alloc(struct mm_struct *mm)
 {
-	return (pgd_t*) __get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER);
+	return get_free_pages(GFP_KERNEL | __GFP_ZERO, PGD_ORDER);
 }
 
 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
crypto/xor.c +1 -1
index 20060f8..e25b834 100644
@@ -114,7 +114,7 @@ calibrate_xor_blocks(void)
 	 * test the XOR speed, we don't really want kmemcheck to warn about
 	 * reading uninitialized bytes here.
 	 */
-	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 2);
+	b1 = get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 2);
 	if (!b1) {
 		printk(KERN_WARNING "xor: Yikes!  No memory available.\n");
 		return -ENOMEM;
drivers/base/devres.c +1 -1
index 414ac33..16876fa 100644
@@ -947,7 +947,7 @@ void *devm_get_free_pages(struct device *dev,
 				  gfp_t gfp_mask, unsigned int order)
 {
 	struct pages_devres *devres;
-	void *addr = (void *)__get_free_pages(gfp_mask, order);
+	void *addr = get_free_pages(gfp_mask, order);
 
 	if (unlikely(!addr))
 		return 0;
drivers/block/ps3vram.c +1 -2
index db7ece5..9fbd9e8 100644
@@ -644,8 +644,7 @@ static int ps3vram_probe(struct ps3_system_bus_device *dev)
 	ps3_system_bus_set_drvdata(dev, priv);
 
 	/* Allocate XDR buffer (1MiB aligned) */
-	priv->xdr_buf = (void *)__get_free_pages(GFP_KERNEL,
-		get_order(XDR_BUF_SIZE));
+	priv->xdr_buf = get_free_pages(GFP_KERNEL, get_order(XDR_BUF_SIZE));
 	if (priv->xdr_buf == NULL) {
 		dev_err(&dev->core, "Could not allocate XDR buffer\n");
 		error = -ENOMEM;
drivers/block/xen-blkfront.c +1 -2
index c5873c2..fa97cc3 100644
@@ -1418,8 +1418,7 @@ static int setup_blkring(struct xenbus_device *dev,
 	for (i = 0; i < info->nr_ring_pages; i++)
 		info->ring_ref[i] = GRANT_INVALID_REF;
 
-	sring = (struct blkif_sring *)__get_free_pages(GFP_NOIO | __GFP_HIGH,
-						       get_order(ring_size));
+	sring = get_free_pages(GFP_NOIO | __GFP_HIGH, get_order(ring_size));
 	if (!sring) {
 		xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
 		return -ENOMEM;
drivers/block/zram/zcomp.c +1 -1
index efaa135..806546c 100644
@@ -85,7 +85,7 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
 	 * allocate 2 pages. 1 for compressed data, plus 1 extra for the
 	 * case when compressed size is larger than the original one
 	 */
-	zstrm->buffer = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
+	zstrm->buffer = get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
 	if (!zstrm->private || !zstrm->buffer) {
 		zcomp_strm_free(comp, zstrm);
 		zstrm = NULL;
drivers/char/agp/hp-agp.c +1 -1
index 9f83f13..5a7fe5f 100644
@@ -294,7 +294,7 @@ hp_zx1_create_gatt_table (struct agp_bridge_data *bridge)
 	int i;
 
 	if (hp->io_pdir_owner) {
-		hp->io_pdir = (u64 *) __get_free_pages(GFP_KERNEL,
+		hp->io_pdir = get_free_pages(GFP_KERNEL,
 						get_order(hp->io_pdir_size));
 		if (!hp->io_pdir) {
 			printk(KERN_ERR PFX "Couldn't allocate contiguous "
drivers/char/agp/uninorth-agp.c +1 -1
index bcbe6a5..71d3f1a 100644
@@ -390,7 +390,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
 		page_order = A_SIZE_32(temp)->page_order;
 		num_entries = A_SIZE_32(temp)->num_entries;
 
-		table = (char *) __get_free_pages(GFP_KERNEL, page_order);
+		table = get_free_pages(GFP_KERNEL, page_order);
 
 		if (table == NULL) {
 			i++;
drivers/crypto/atmel-aes.c +2 -2
index bf75457..dc99f80 100644
@@ -652,8 +652,8 @@ static int atmel_aes_buff_init(struct atmel_aes_dev *dd)
 {
 	int err = -ENOMEM;
 
-	dd->buf_in = (void *)__get_free_pages(GFP_KERNEL, 0);
-	dd->buf_out = (void *)__get_free_pages(GFP_KERNEL, 0);
+	dd->buf_in = get_free_pages(GFP_KERNEL, 0);
+	dd->buf_out = get_free_pages(GFP_KERNEL, 0);
 	dd->buflen = PAGE_SIZE;
 	dd->buflen &= ~(AES_BLOCK_SIZE - 1);
 
drivers/crypto/atmel-tdes.c +2 -2
index 0219027e..5f69db6 100644
@@ -347,8 +347,8 @@ static int atmel_tdes_buff_init(struct atmel_tdes_dev *dd)
 {
 	int err = -ENOMEM;
 
-	dd->buf_in = (void *)__get_free_pages(GFP_KERNEL, 0);
-	dd->buf_out = (void *)__get_free_pages(GFP_KERNEL, 0);
+	dd->buf_in = get_free_pages(GFP_KERNEL, 0);
+	dd->buf_out = get_free_pages(GFP_KERNEL, 0);
 	dd->buflen = PAGE_SIZE;
 	dd->buflen &= ~(DES_BLOCK_SIZE - 1);
 
drivers/crypto/nx/nx-842.c +2 -2
index ce459cb..be7cdf6 100644
@@ -117,8 +117,8 @@ int nx842_crypto_init(struct crypto_tfm *tfm, struct nx842_driver *driver)
 	spin_lock_init(&ctx->lock);
 	ctx->driver = driver;
 	ctx->wmem = kmalloc(driver->workmem_size, GFP_KERNEL);
-	ctx->sbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER);
-	ctx->dbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER);
+	ctx->sbounce = get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER);
+	ctx->dbounce = get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER);
 	if (!ctx->wmem || !ctx->sbounce || !ctx->dbounce) {
 		kfree(ctx->wmem);
 		free_page(ctx->sbounce);
drivers/crypto/omap-aes.c +2 -2
index cd41ce7..4c91b97 100644
@@ -582,8 +582,8 @@ static int omap_aes_copy_sgs(struct omap_aes_dev *dd)
 	total = ALIGN(dd->total, AES_BLOCK_SIZE);
 	pages = get_order(total);
 
-	buf_in = (void *)__get_free_pages(GFP_ATOMIC, pages);
-	buf_out = (void *)__get_free_pages(GFP_ATOMIC, pages);
+	buf_in = get_free_pages(GFP_ATOMIC, pages);
+	buf_out = get_free_pages(GFP_ATOMIC, pages);
 
 	if (!buf_in || !buf_out) {
 		pr_err("Couldn't allocated pages for unaligned cases.\n");
drivers/crypto/omap-des.c +2 -2
index 462f2bc..35c916e 100644
@@ -563,8 +563,8 @@ static int omap_des_copy_sgs(struct omap_des_dev *dd)
 
 	BUG_ON(!pages);
 
-	buf_in = (void *)__get_free_pages(GFP_ATOMIC, pages);
-	buf_out = (void *)__get_free_pages(GFP_ATOMIC, pages);
+	buf_in = get_free_pages(GFP_ATOMIC, pages);
+	buf_out = get_free_pages(GFP_ATOMIC, pages);
 
 	if (!buf_in || !buf_out) {
 		pr_err("Couldn't allocated pages for unaligned cases.\n");
drivers/dma/ste_dma40.c +1 -1
index e2e0225..287d468 100644
@@ -3425,7 +3425,7 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 	base->lcla_pool.pages = SZ_1K * base->num_phy_chans / PAGE_SIZE;
 
 	for (i = 0; i < MAX_LCLA_ALLOC_ATTEMPTS; i++) {
-		page_list[i] = (void *)__get_free_pages(GFP_KERNEL,
+		page_list[i] = get_free_pages(GFP_KERNEL,
 						base->lcla_pool.pages);
 		if (!page_list[i]) {
 
drivers/firmware/dell_rbu.c +2 -4
index 7d1afaa..ba66b09 100644
@@ -160,8 +160,7 @@ static int create_packet(void *data, size_t length)
 	}
 
 	while (!packet_data_temp_buf) {
-		packet_data_temp_buf = (unsigned char *)
-			__get_free_pages(GFP_KERNEL, ordernum);
+		packet_data_temp_buf = get_free_pages(GFP_KERNEL, ordernum);
 		if (!packet_data_temp_buf) {
 			printk(KERN_WARNING
 				"dell_rbu:%s: failed to allocate new "
@@ -434,8 +433,7 @@ static int img_update_realloc(unsigned long size)
 	spin_unlock(&rbu_data.lock);
 
 	ordernum = get_order(size);
-	image_update_buffer =
-		(unsigned char *) __get_free_pages(GFP_KERNEL, ordernum);
+	image_update_buffer = get_free_pages(GFP_KERNEL, ordernum);
 
 	img_buf_phys_addr =
 		(unsigned long) virt_to_phys(image_update_buffer);
drivers/gpu/drm/amd/amdkfd/kfd_events.c +1 -1
index 8bb3671..82d206f 100644
@@ -137,7 +137,7 @@ static bool allocate_signal_page(struct file *devkfd, struct kfd_process *p)
 
 	page->free_slots = SLOTS_PER_PAGE;
 
-	backing_store = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	backing_store = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					get_order(KFD_SIGNAL_EVENT_LIMIT * 8));
 	if (!backing_store)
 		goto fail_alloc_signal_store;
drivers/hv/channel.c +3 -3
index 0b65dc5..c06147c 100644
@@ -94,11 +94,11 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 				recv_ringbuffer_size));
 
 	if (!page)
-		out = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
-					       get_order(send_ringbuffer_size +
+		out = get_free_pages(GFP_KERNEL|__GFP_ZERO,
+				       get_order(send_ringbuffer_size +
 					       recv_ringbuffer_size));
 	else
-		out = (void *)page_address(page);
+		out = page_address(page);
 
 	if (!out) {
 		err = -ENOMEM;
drivers/hv/connection.c +3 -4
index 99cf9e9..1ec553d 100644
@@ -152,8 +152,7 @@ int vmbus_connect(void)
 	 * Setup the vmbus event connection for channel interrupt
 	 * abstraction stuff
 	 */
-	vmbus_connection.int_page =
-	(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
+	vmbus_connection.int_page = get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
 	if (vmbus_connection.int_page == NULL) {
 		ret = -ENOMEM;
 		goto cleanup;
@@ -168,8 +167,8 @@ int vmbus_connect(void)
 	 * Setup the monitor notification facility. The 1st page for
 	 * parent->child and the 2nd page for child->parent
 	 */
-	vmbus_connection.monitor_pages[0] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
-	vmbus_connection.monitor_pages[1] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
+	vmbus_connection.monitor_pages[0] = get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
+	vmbus_connection.monitor_pages[1] = get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
 	if ((vmbus_connection.monitor_pages[0] == NULL) ||
 	    (vmbus_connection.monitor_pages[1] == NULL)) {
 		ret = -ENOMEM;
drivers/iommu/amd_iommu_init.c +8 -8
index ace59ca..a89b9d5 100644
@@ -500,7 +500,7 @@ static int __init find_last_devid_acpi(struct acpi_table_header *table)
  */
 static int __init alloc_command_buffer(struct amd_iommu *iommu)
 {
-	iommu->cmd_buf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	iommu->cmd_buf = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 						  get_order(CMD_BUFFER_SIZE));
 
 	return iommu->cmd_buf ? 0 : -ENOMEM;
@@ -547,7 +547,7 @@ static void __init free_command_buffer(struct amd_iommu *iommu)
 /* allocates the memory where the IOMMU will log its events to */
 static int __init alloc_event_buffer(struct amd_iommu *iommu)
 {
-	iommu->evt_buf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	iommu->evt_buf = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 						  get_order(EVT_BUFFER_SIZE));
 
 	return iommu->evt_buf ? 0 : -ENOMEM;
@@ -579,7 +579,7 @@ static void __init free_event_buffer(struct amd_iommu *iommu)
 /* allocates the memory where the IOMMU will log its events to */
 static int __init alloc_ppr_log(struct amd_iommu *iommu)
 {
-	iommu->ppr_log = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	iommu->ppr_log = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 						  get_order(PPR_LOG_SIZE));
 
 	return iommu->ppr_log ? 0 : -ENOMEM;
@@ -1833,7 +1833,7 @@ static int __init early_amd_iommu_init(void)
 
 	/* Device table - directly used by all IOMMUs */
 	ret = -ENOMEM;
-	amd_iommu_dev_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	amd_iommu_dev_table = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 				      get_order(dev_table_size));
 	if (amd_iommu_dev_table == NULL)
 		goto out;
@@ -1842,19 +1842,19 @@ static int __init early_amd_iommu_init(void)
 	 * Alias table - map PCI Bus/Dev/Func to Bus/Dev/Func the
 	 * IOMMU see for that device
 	 */
-	amd_iommu_alias_table = (void *)__get_free_pages(GFP_KERNEL,
+	amd_iommu_alias_table = get_free_pages(GFP_KERNEL,
 			get_order(alias_table_size));
 	if (amd_iommu_alias_table == NULL)
 		goto out;
 
 	/* IOMMU rlookup table - find the IOMMU for a specific device */
-	amd_iommu_rlookup_table = (void *)__get_free_pages(
+	amd_iommu_rlookup_table = get_free_pages(
 			GFP_KERNEL | __GFP_ZERO,
 			get_order(rlookup_table_size));
 	if (amd_iommu_rlookup_table == NULL)
 		goto out;
 
-	amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages(
+	amd_iommu_pd_alloc_bitmap = get_free_pages(
 					    GFP_KERNEL | __GFP_ZERO,
 					    get_order(MAX_DOMAIN_ID/8));
 	if (amd_iommu_pd_alloc_bitmap == NULL)
@@ -1898,7 +1898,7 @@ static int __init early_amd_iommu_init(void)
 		if (!amd_iommu_irq_cache)
 			goto out;
 
-		irq_lookup_table = (void *)__get_free_pages(
+		irq_lookup_table = get_free_pages(
 				GFP_KERNEL | __GFP_ZERO,
 				get_order(rlookup_table_size));
 		if (!irq_lookup_table)
drivers/iommu/exynos-iommu.c +2 -2
index 828a316..6d376c8 100644
@@ -669,11 +669,11 @@ static struct iommu_domain *exynos_iommu_domain_alloc(unsigned type)
 	if (!domain)
 		return NULL;
 
-	domain->pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2);
+	domain->pgtable = get_free_pages(GFP_KERNEL, 2);
 	if (!domain->pgtable)
 		goto err_pgtable;
 
-	domain->lv2entcnt = (short *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
+	domain->lv2entcnt = get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
 	if (!domain->lv2entcnt)
 		goto err_counter;
 
drivers/iommu/msm_iommu.c +3 -5
index 01afc79..2d9f859 100644
@@ -227,8 +227,7 @@ static struct iommu_domain *msm_iommu_domain_alloc(unsigned type)
 		goto fail_nomem;
 
 	INIT_LIST_HEAD(&priv->list_attached);
-	priv->pgtable = (unsigned long *)__get_free_pages(GFP_KERNEL,
-							  get_order(SZ_16K));
+	priv->pgtable = get_free_pages(GFP_KERNEL, get_order(SZ_16K));
 
 	if (!priv->pgtable)
 		goto fail_nomem;
@@ -433,9 +432,8 @@ static int msm_iommu_map(struct iommu_domain *domain, unsigned long va,
 
 	/* Need a 2nd level table */
 	if ((len == SZ_4K || len == SZ_64K) && (*fl_pte) == 0) {
-		unsigned long *sl;
-		sl = (unsigned long *) __get_free_pages(GFP_ATOMIC,
-							get_order(SZ_4K));
+		unsigned long *sl = get_free_pages(GFP_ATOMIC,
+						   get_order(SZ_4K));
 
 		if (!sl) {
 			pr_debug("Could not allocate second level table\n");
drivers/irqchip/irq-gic-v3-its.c +1 -1
index 2513a68..217765a 100644
@@ -883,7 +883,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
 				node_name, order, alloc_pages);
 		}
 
-		base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
+		base = get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 		if (!base) {
 			err = -ENOMEM;
 			goto out_free;
drivers/md/bcache/bset.c +4 -4
index 3059674..22b8aaa 100644
@@ -315,19 +315,19 @@ int bch_btree_keys_alloc(struct btree_keys *b, unsigned page_order, gfp_t gfp)
 
 	b->page_order = page_order;
 
-	t->data = (void *) __get_free_pages(gfp, b->page_order);
+	t->data = get_free_pages(gfp, b->page_order);
 	if (!t->data)
 		goto err;
 
 	t->tree = bset_tree_bytes(b) < PAGE_SIZE
 		? kmalloc(bset_tree_bytes(b), gfp)
-		: (void *) __get_free_pages(gfp, get_order(bset_tree_bytes(b)));
+		: get_free_pages(gfp, get_order(bset_tree_bytes(b)));
 	if (!t->tree)
 		goto err;
 
 	t->prev = bset_prev_bytes(b) < PAGE_SIZE
 		? kmalloc(bset_prev_bytes(b), gfp)
-		: (void *) __get_free_pages(gfp, get_order(bset_prev_bytes(b)));
+		: get_free_pages(gfp, get_order(bset_prev_bytes(b)));
 	if (!t->prev)
 		goto err;
 
@@ -1180,7 +1180,7 @@ static void __btree_sort(struct btree_keys *b, struct btree_iter *iter,
 {
 	uint64_t start_time;
 	bool used_mempool = false;
-	struct bset *out = (void *) __get_free_pages(__GFP_NOWARN|GFP_NOWAIT,
+	struct bset *out = get_free_pages(__GFP_NOWARN|GFP_NOWAIT,
 						     order);
 	if (!out) {
 		struct page *outp;
drivers/md/bcache/btree.c +1 -2
index 1540114..9499bfb 100644
@@ -792,8 +792,7 @@ int bch_btree_cache_alloc(struct cache_set *c)
 #ifdef CONFIG_BCACHE_DEBUG
 	mutex_init(&c->verify_lock);
 
-	c->verify_ondisk = (void *)
-		__get_free_pages(GFP_KERNEL, ilog2(bucket_pages(c)));
+	c->verify_ondisk = get_free_pages(GFP_KERNEL, ilog2(bucket_pages(c)));
 
 	c->verify_data = mca_bucket_alloc(c, &ZERO_KEY, GFP_KERNEL);
 
drivers/md/bcache/journal.c +2 -2
index 6ed9533..813def6 100644
@@ -815,8 +815,8 @@ int bch_journal_alloc(struct cache_set *c)
 	j->w[1].c = c;
 
 	if (!(init_fifo(&j->pin, JOURNAL_PIN, GFP_KERNEL)) ||
-	    !(j->w[0].data = (void *) __get_free_pages(GFP_KERNEL, JSET_BITS)) ||
-	    !(j->w[1].data = (void *) __get_free_pages(GFP_KERNEL, JSET_BITS)))
+	    !(j->w[0].data = get_free_pages(GFP_KERNEL, JSET_BITS)) ||
+	    !(j->w[1].data = get_free_pages(GFP_KERNEL, JSET_BITS)))
 		return -ENOMEM;
 
 	return 0;
drivers/md/bcache/super.c +1 -1
index cd04e2d..2fb3624 100644
@@ -1431,7 +1431,7 @@ void bch_cache_set_unregister(struct cache_set *c)
 }
 
 #define alloc_bucket_pages(gfp, c)			\
-	((void *) __get_free_pages(__GFP_ZERO|gfp, ilog2(bucket_pages(c))))
+	(get_free_pages(__GFP_ZERO|gfp, ilog2(bucket_pages(c))))
 
 struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
 {
drivers/md/dm-bufio.c +1 -2
index 10f8a45..f2aae7e 100644
@@ -380,8 +380,7 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
 	if (c->block_size <= DM_BUFIO_BLOCK_SIZE_GFP_LIMIT &&
 	    gfp_mask & __GFP_NORETRY) {
 		*data_mode = DATA_MODE_GET_FREE_PAGES;
-		return (void *)__get_free_pages(gfp_mask,
-						c->pages_per_block_bits);
+		return get_free_pages(gfp_mask, c->pages_per_block_bits);
 	}
 
 	*data_mode = DATA_MODE_VMALLOC;
drivers/media/pci/solo6x10/solo6x10-p2m.c +2 -2
index ef91be9..85bdeac 100644
@@ -221,11 +221,11 @@ static int solo_p2m_test(struct solo_dev *solo_dev, int base, int size)
 	int ret = -EIO;
 	int order = get_order(size);
 
-	wr_buf = (u32 *)__get_free_pages(GFP_KERNEL, order);
+	wr_buf = get_free_pages(GFP_KERNEL, order);
 	if (wr_buf == NULL)
 		return -1;
 
-	rd_buf = (u32 *)__get_free_pages(GFP_KERNEL, order);
+	rd_buf = get_free_pages(GFP_KERNEL, order);
 	if (rd_buf == NULL) {
 		free_pages(wr_buf, order);
 		return -1;
drivers/media/platform/davinci/dm644x_ccdc.c +1 -2
index 42df06f..f816042 100644
@@ -268,8 +268,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params)
 		}
 
 		/* Allocate memory for FPC table */
-		fpc_virtaddr =
-			(unsigned int *)__get_free_pages(GFP_KERNEL | GFP_DMA,
+		fpc_virtaddr = get_free_pages(GFP_KERNEL | GFP_DMA,
 							 get_order(raw_params->
 							 fault_pxl.fp_num *
 							 FP_NUM_BYTES));
drivers/misc/cxl/native.c +2 -2
index 4620627..6ff5696 100644
@@ -195,8 +195,8 @@ int cxl_alloc_spa(struct cxl_afu *afu)
 
 	WARN_ON(afu->spa_size > 0x100000); /* Max size supported by the hardware */
 
-	if (!(afu->spa = (struct cxl_process_element *)
-	      __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->spa_order))) {
+	if (!(afu->spa = 
+	      get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->spa_order))) {
 		pr_err("cxl_alloc_spa: Unable to allocate scheduled process area\n");
 		return -ENOMEM;
 	}
drivers/misc/mic/card/mic_virtio.c +1 -1
index bb364ee..19e5731 100644
@@ -279,7 +279,7 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
 	mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
 					     sizeof(struct vring_used_elem) *
 					     le16_to_cpu(config.num));
-	used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	used = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					get_order(mvdev->used_size[index]));
 	if (!used) {
 		err = -ENOMEM;
drivers/misc/mic/host/mic_virtio.c +2 -3
index 3474aa2..253c525 100644
@@ -649,8 +649,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
 		mutex_init(&mvr->vr_mutex);
 		vr_size = PAGE_ALIGN(vring_size(num, MIC_VIRTIO_RING_ALIGN) +
 			sizeof(struct _mic_vring_info));
-		vr->va = (void *)
-			__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+		vr->va = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					 get_order(vr_size));
 		if (!vr->va) {
 			ret = -ENOMEM;
@@ -688,7 +687,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
 		dev_dbg(&mdev->pdev->dev,
 			"%s %d index %d va %p info %p vr_size 0x%x\n",
 			__func__, __LINE__, i, vr->va, vr->info, vr_size);
-		mvr->buf = (void *)__get_free_pages(GFP_KERNEL,
+		mvr->buf = get_free_pages(GFP_KERNEL,
 					get_order(MIC_INT_DMA_BUF_SIZE));
 		mvr->buf_da = mic_map_single(mvdev->mdev, mvr->buf,
 					  MIC_INT_DMA_BUF_SIZE);
drivers/misc/mic/scif/scif_rma.h +1 -1
index e13ab83..020073e 100644
@@ -402,7 +402,7 @@ static inline void *scif_zalloc(size_t size)
 	size_t align = ALIGN(size, PAGE_SIZE);
 
 	if (align && get_order(align) < MAX_ORDER)
-		ret = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+		ret = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					       get_order(align));
 	return ret ? ret : vzalloc(align);
 }
drivers/net/ethernet/cavium/liquidio/octeon_main.h +1 -3
index b6a90a9..e053e4a 100644
@@ -136,9 +136,7 @@ cnnic_alloc_aligned_dma(struct pci_dev *pci_dev,
 
 #define OCTEON_MAX_ALLOC_RETRIES     1
 	do {
-		ptr =
-		    (void *)__get_free_pages(GFP_KERNEL,
-					     get_order(size));
+		ptr = get_free_pages(GFP_KERNEL, get_order(size));
 		retries++;
 	} while ((retries <= OCTEON_MAX_ALLOC_RETRIES) && !ptr);
 
drivers/net/ethernet/sgi/ioc3-eth.c +1 -1
index e314d3f..6a256b1 100644
@@ -932,7 +932,7 @@ static void ioc3_alloc_rings(struct net_device *dev)
 
 	if (ip->txr == NULL) {
 		/* Allocate and initialize tx rings.  16kb = 128 bufs.  */
-		ip->txr = (struct ioc3_etxd *)__get_free_pages(GFP_KERNEL, 2);
+		ip->txr = get_free_pages(GFP_KERNEL, 2);
 		if (!ip->txr)
 			printk("ioc3_alloc_rings(): __get_free_pages() failed!\n");
 		ip->tx_pi = 0;
drivers/net/irda/au1k_ir.c +1 -1
index 6095cf4..ec4b640 100644
@@ -229,7 +229,7 @@ static void *dma_alloc(size_t size, dma_addr_t *dma_handle)
 	void *ret;
 	int gfp = GFP_ATOMIC | GFP_DMA;
 
-	ret = (void *)__get_free_pages(gfp, get_order(size));
+	ret = get_free_pages(gfp, get_order(size));
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
drivers/net/rionet.c +1 -1
index d0c1b13..2d060ff 100644
@@ -467,7 +467,7 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
 	const size_t rionet_active_bytes = sizeof(void *) *
 				RIO_MAX_ROUTE_ENTRIES(mport->sys_size);
 
-	nets[mport->id].active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+	nets[mport->id].active = get_free_pages(GFP_KERNEL,
 						get_order(rionet_active_bytes));
 	if (!nets[mport->id].active) {
 		rc = -ENOMEM;
drivers/net/wireless/b43/debugfs.c +1 -1
index 50a2316..844e290 100644
@@ -532,7 +532,7 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 	dfile = fops_to_dfs_file(dev, dfops);
 
 	if (!dfile->buffer) {
-		buf = (char *)__get_free_pages(GFP_KERNEL, buforder);
+		buf = get_free_pages(GFP_KERNEL, buforder);
 		if (!buf) {
 			err = -ENOMEM;
 			goto out_unlock;
drivers/net/wireless/b43legacy/debugfs.c +1 -1
index e243955..371ece0 100644
@@ -229,7 +229,7 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 	dfile = fops_to_dfs_file(dev, dfops);
 
 	if (!dfile->buffer) {
-		buf = (char *)__get_free_pages(GFP_KERNEL, buforder);
+		buf = get_free_pages(GFP_KERNEL, buforder);
 		if (!buf) {
 			err = -ENOMEM;
 			goto out_unlock;
drivers/net/wireless/ti/wlcore/main.c +1 -1
index 374adb1..ec979ba 100644
@@ -6309,7 +6309,7 @@ struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size, u32 aggr_buf_size,
 	init_completion(&wl->nvs_loading_complete);
 
 	order = get_order(aggr_buf_size);
-	wl->aggr_buf = (u8 *)__get_free_pages(GFP_KERNEL, order);
+	wl->aggr_buf = get_free_pages(GFP_KERNEL, order);
 	if (!wl->aggr_buf) {
 		ret = -ENOMEM;
 		goto err_wq;
drivers/parisc/ccio-dma.c +3 -5
index b172617..633c6d4 100644
@@ -847,7 +847,7 @@ ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, g
 		return 0;
 	}
 #endif
-        ret = (void *) __get_free_pages(flag, get_order(size));
+        ret = get_free_pages(flag, get_order(size));
 
 	if (ret) {
 		memset(ret, 0, size);
@@ -1299,8 +1299,7 @@ ccio_ioc_init(struct ioc *ioc)
 			iova_space_size>>20,
 			iov_order + PAGE_SHIFT);
 
-	ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, 
-						 get_order(ioc->pdir_size));
+	ioc->pdir_base = get_free_pages(GFP_KERNEL, get_order(ioc->pdir_size));
 	if(NULL == ioc->pdir_base) {
 		panic("%s() could not allocate I/O Page Table\n", __func__);
 	}
@@ -1313,8 +1312,7 @@ ccio_ioc_init(struct ioc *ioc)
  	ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3;
 	DBG_INIT("%s() res_size 0x%x\n", __func__, ioc->res_size);
 	
-	ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, 
-					      get_order(ioc->res_size));
+	ioc->res_map = get_free_pages(GFP_KERNEL, get_order(ioc->res_size));
 	if(NULL == ioc->res_map) {
 		panic("%s() could not allocate resource map\n", __func__);
 	}
drivers/parisc/ccio-rm-dma.c +1 -1
index b9649c2..e4239f8 100644
@@ -84,7 +84,7 @@ static void *ccio_alloc_consistent(struct pci_dev *dev, size_t size,
 {
 	void *ret;
 	
-	ret = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
+	ret = get_free_pages(GFP_ATOMIC, get_order(size));
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
drivers/parisc/sba_iommu.c +3 -4
index 6066d4e..10ca71d 100644
@@ -876,7 +876,7 @@ static void *sba_alloc_consistent(struct device *hwdev, size_t size,
 		return NULL;
 	}
 
-        ret = (void *) __get_free_pages(gfp, get_order(size));
+        ret = get_free_pages(gfp, get_order(size));
 
 	if (ret) {
 		memset(ret, 0, size);
@@ -1283,8 +1283,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
 		__func__, ioc->ioc_hpa, iova_space_size >> 20,
 		iov_order + PAGE_SHIFT);
 
-	ioc->pdir_base = (void *) __get_free_pages(GFP_KERNEL,
-						   get_order(ioc->pdir_size));
+	ioc->pdir_base = get_free_pages(GFP_KERNEL, get_order(ioc->pdir_size));
 	if (!ioc->pdir_base)
 		panic("Couldn't allocate I/O Page Table\n");
 
@@ -1697,7 +1696,7 @@ sba_common_init(struct sba_device *sba_dev)
 			__func__, res_size);
 
 		sba_dev->ioc[i].res_size = res_size;
-		sba_dev->ioc[i].res_map = (char *) __get_free_pages(GFP_KERNEL, get_order(res_size));
+		sba_dev->ioc[i].res_map = get_free_pages(GFP_KERNEL, get_order(res_size));
 
 #ifdef DEBUG_DMB_TRAP
 		iterate_pages( sba_dev->ioc[i].res_map, res_size,
drivers/pci/host/pci-tegra.c +1 -1
index ba7fc9e..9d12ce1 100644
@@ -1296,7 +1296,7 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie)
 	}
 
 	/* setup AFI/FPCI range */
-	msi->pages = (void *)__get_free_pages(GFP_KERNEL, 0);
+	msi->pages = get_free_pages(GFP_KERNEL, 0);
 	base = virt_to_phys(msi->pages);
 
 	afi_writel(pcie, base >> soc->msi_base_shift, AFI_MSI_FPCI_BAR_ST);
drivers/pci/host/pcie-designware.c +1 -1
index 769fc9d..a46c493 100644
@@ -206,7 +206,7 @@ void dw_pcie_msi_init(struct pcie_port *pp)
 {
 	u64 msi_target;
 
-	pp->msi_data = (void *)__get_free_pages(GFP_KERNEL, 0);
+	pp->msi_data = get_free_pages(GFP_KERNEL, 0);
 	msi_target = virt_to_phys(pp->msi_data);
 
 	/* program the msi_data */
drivers/pci/host/pcie-rcar.c +1 -1
index fdeb72f..1cf7746 100644
@@ -734,7 +734,7 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
 	}
 
 	/* setup MSI data target */
-	msi->pages = (void *)__get_free_pages(GFP_KERNEL, 0);
+	msi->pages = get_free_pages(GFP_KERNEL, 0);
 	base = virt_to_phys(msi->pages);
 
 	rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR);
drivers/pci/host/pcie-xilinx.c +1 -1
index 3cc679d..a31938b 100644
@@ -353,7 +353,7 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
 {
 	phys_addr_t msg_addr;
 
-	port->msi_pages = (void *)__get_free_pages(GFP_KERNEL, 0);
+	port->msi_pages = get_free_pages(GFP_KERNEL, 0);
 	msg_addr = virt_to_phys(port->msi_pages);
 	pcie_write(port, 0x0, XILINX_PCIE_REG_MSIBASE1);
 	pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2);
drivers/s390/block/dasd.c +1 -1
index 7b24131..ddab935 100644
@@ -96,7 +96,7 @@ struct dasd_device *dasd_alloc_device(void)
 		return ERR_PTR(-ENOMEM);
 
 	/* Get two pages for normal block device operations. */
-	device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
+	device->ccw_mem = get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
 	if (!device->ccw_mem) {
 		kfree(device);
 		return ERR_PTR(-ENOMEM);
drivers/s390/char/hmcdrv_cache.c +1 -1
index 60a4233..98f049b 100644
@@ -217,7 +217,7 @@ int hmcdrv_cache_startup(size_t cachesize)
 	if (cachesize > 0) { /* perform caching ? */
 		hmcdrv_cache_order = get_order(cachesize);
 		hmcdrv_cache_file.content =
-			(void *) __get_free_pages(GFP_KERNEL | GFP_DMA,
+			get_free_pages(GFP_KERNEL | GFP_DMA,
 						  hmcdrv_cache_order);
 
 		if (!hmcdrv_cache_file.content) {
drivers/s390/char/hmcdrv_ftp.c +1 -1
index c08e633..0ee0827 100644
@@ -245,7 +245,7 @@ ssize_t hmcdrv_ftp_cmd(char __kernel *cmd, loff_t offset,
 		return retlen;
 
 	order = get_order(ftp.len);
-	ftp.buf = (void *) __get_free_pages(GFP_KERNEL | GFP_DMA, order);
+	ftp.buf = get_free_pages(GFP_KERNEL | GFP_DMA, order);
 
 	if (!ftp.buf)
 		return -ENOMEM;
drivers/s390/char/tty3270.c +2 -2
index bb61f97..f5c9599 100644
@@ -690,8 +690,8 @@ tty3270_alloc_view(void)
 	tp->rcl_max = 20;
 
 	for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) {
-		tp->freemem_pages[pages] = (void *)
-			__get_free_pages(GFP_KERNEL|GFP_DMA, 0);
+		tp->freemem_pages[pages] = 
+			get_free_pages(GFP_KERNEL|GFP_DMA, 0);
 		if (!tp->freemem_pages[pages])
 			goto out_pages;
 		add_string_memory(&tp->freemem,
drivers/s390/char/vmcp.c +1 -1
index f73bf6b..fea0a72 100644
@@ -102,7 +102,7 @@ vmcp_write(struct file *file, const char __user *buff, size_t count,
 		return -ERESTARTSYS;
 	}
 	if (!session->response)
-		session->response = (char *)__get_free_pages(GFP_KERNEL
+		session->response = get_free_pages(GFP_KERNEL
 						| __GFP_REPEAT | GFP_DMA,
 						get_order(session->bufsize));
 	if (!session->response) {
drivers/s390/cio/cmf.c +1 -1
index 70356a3..6ee6ad6 100644
@@ -572,7 +572,7 @@ static int alloc_cmb(struct ccw_device *cdev)
 		WARN_ON(!list_empty(&cmb_area.list));
 
 		spin_unlock(&cmb_area.lock);
-		mem = (void*)__get_free_pages(GFP_KERNEL | GFP_DMA,
+		mem = get_free_pages(GFP_KERNEL | GFP_DMA,
 				 get_order(size));
 		spin_lock(&cmb_area.lock);
 
drivers/scsi/cxlflash/main.c +1 -1
index d4d6e38..ff85994 100644
@@ -763,7 +763,7 @@ static int alloc_mem(struct cxlflash_cfg *cfg)
 	struct device *dev = &cfg->dev->dev;
 
 	/* AFU is ~12k, i.e. only one 64k page or up to four 4k pages */
-	cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	cfg->afu = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					    get_order(sizeof(struct afu)));
 	if (unlikely(!cfg->afu)) {
 		dev_err(dev, "%s: cannot get %d free pages\n",
drivers/scsi/libiscsi.c +1 -2
index d03ab52..4513104 100644
@@ -2912,8 +2912,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
 	}
 	spin_unlock_bh(&session->frwd_lock);
 
-	data = (char *) __get_free_pages(GFP_KERNEL,
-					 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
+	data = get_free_pages(GFP_KERNEL, get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
 	if (!data)
 		goto login_task_data_alloc_fail;
 	conn->login_task->data = conn->data = data;
drivers/scsi/lpfc/lpfc_init.c +2 -4
index 4d9457b..5447150 100644
@@ -6233,8 +6233,7 @@ lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost)
 	if (!_dump_buf_data) {
 		while (pagecnt) {
 			spin_lock_init(&_dump_buf_lock);
-			_dump_buf_data =
-				(char *) __get_free_pages(GFP_KERNEL, pagecnt);
+			_dump_buf_data = get_free_pages(GFP_KERNEL, pagecnt);
 			if (_dump_buf_data) {
 				lpfc_printf_log(phba, KERN_ERR, LOG_BG,
 					"9043 BLKGRD: allocated %d pages for "
@@ -6257,8 +6256,7 @@ lpfc_setup_bg(struct lpfc_hba *phba, struct Scsi_Host *shost)
 		       "\n", _dump_buf_data);
 	if (!_dump_buf_dif) {
 		while (pagecnt) {
-			_dump_buf_dif =
-				(char *) __get_free_pages(GFP_KERNEL, pagecnt);
+			_dump_buf_dif = get_free_pages(GFP_KERNEL, pagecnt);
 			if (_dump_buf_dif) {
 				lpfc_printf_log(phba, KERN_ERR, LOG_BG,
 					"9046 BLKGRD: allocated %d pages for "
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
index 2c81ab3..56710df 100644
@@ -5382,7 +5382,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
 	{
 		instance->ctrl_context_pages =
 			get_order(sizeof(struct fusion_context));
-		instance->ctrl_context = (void *)__get_free_pages(GFP_KERNEL,
+		instance->ctrl_context = get_free_pages(GFP_KERNEL,
 				instance->ctrl_context_pages);
 		if (!instance->ctrl_context) {
 			dev_printk(KERN_DEBUG, &pdev->dev, "Failed to allocate "
drivers/scsi/megaraid/megaraid_sas_fusion.c +2 -2
index 6429914..f11c3b7 100644
@@ -1186,7 +1186,7 @@ megasas_init_adapter_fusion(struct megasas_instance *instance)
 	fusion->drv_map_pages = get_order(fusion->drv_map_sz);
 	for (i = 0; i < 2; i++) {
 		fusion->ld_map[i] = NULL;
-		fusion->ld_drv_map[i] = (void *)__get_free_pages(GFP_KERNEL,
+		fusion->ld_drv_map[i] = get_free_pages(GFP_KERNEL,
 			fusion->drv_map_pages);
 		if (!fusion->ld_drv_map[i]) {
 			dev_err(&instance->pdev->dev, "Could not allocate "
@@ -2462,7 +2462,7 @@ megasas_alloc_host_crash_buffer(struct megasas_instance *instance)
 
 	instance->crash_buf_pages = get_order(CRASH_DMA_BUF_SIZE);
 	for (i = 0; i < MAX_CRASH_DUMP_SIZE; i++) {
-		instance->crash_buf[i] = (void	*)__get_free_pages(GFP_KERNEL,
+		instance->crash_buf[i] = get_free_pages(GFP_KERNEL,
 				instance->crash_buf_pages);
 		if (!instance->crash_buf[i]) {
 			dev_info(&instance->pdev->dev, "Firmware crash dump "
drivers/scsi/mpt3sas/mpt3sas_base.c +2 -3
index 0d73ea3..13e893a 100644
@@ -3386,7 +3386,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc,  int sleep_flag)
 
 	sz = ioc->scsiio_depth * sizeof(struct scsiio_tracker);
 	ioc->scsi_lookup_pages = get_order(sz);
-	ioc->scsi_lookup = (struct scsiio_tracker *)__get_free_pages(
+	ioc->scsi_lookup = get_free_pages(
 	    GFP_KERNEL, ioc->scsi_lookup_pages);
 	if (!ioc->scsi_lookup) {
 		pr_err(MPT3SAS_FMT "scsi_lookup: get_free_pages failed, sz(%d)\n",
@@ -3400,8 +3400,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc,  int sleep_flag)
 	ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH);
 	sz = ioc->chain_depth * sizeof(struct chain_tracker);
 	ioc->chain_pages = get_order(sz);
-	ioc->chain_lookup = (struct chain_tracker *)__get_free_pages(
-	    GFP_KERNEL, ioc->chain_pages);
+	ioc->chain_lookup = get_free_pages(GFP_KERNEL, ioc->chain_pages);
 	if (!ioc->chain_lookup) {
 		pr_err(MPT3SAS_FMT "chain_lookup: __get_free_pages failed\n",
 			ioc->name);
drivers/scsi/sym53c8xx_2/sym_hipd.h +1 -1
index 45f9ac2..6c0161e 100644
@@ -1123,7 +1123,7 @@ bad:
  */
 
 #define sym_get_mem_cluster()	\
-	(void *) __get_free_pages(GFP_ATOMIC, SYM_MEM_PAGE_ORDER)
+	get_free_pages(GFP_ATOMIC, SYM_MEM_PAGE_ORDER)
 #define sym_free_mem_cluster(p)	\
 	free_pages(p, SYM_MEM_PAGE_ORDER)
 
drivers/scsi/vmw_pvscsi.c +1 -2
index 7921fc8..16467b53 100644
@@ -1251,8 +1251,7 @@ static int pvscsi_allocate_sg(struct pvscsi_adapter *adapter)
 	BUILD_BUG_ON(sizeof(struct pvscsi_sg_list) > SGL_SIZE);
 
 	for (i = 0; i < adapter->req_depth; ++i, ++ctx) {
-		ctx->sgl = (void *)__get_free_pages(GFP_KERNEL,
-						    get_order(SGL_SIZE));
+		ctx->sgl = get_free_pages(GFP_KERNEL, get_order(SGL_SIZE));
 		ctx->sglPA = 0;
 		BUG_ON(!IS_ALIGNED(((unsigned long)ctx->sgl), PAGE_SIZE));
 		if (!ctx->sgl) {
drivers/sh/maple/maple.c +1 -2
index 84fa4f7..4495a56 100644
@@ -738,8 +738,7 @@ static int maple_set_vblank_interrupt_handler(void)
 
 static int maple_get_dma_buffer(void)
 {
-	maple_sendbuf =
-	    (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	maple_sendbuf = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 				      MAPLE_DMA_PAGES);
 	if (!maple_sendbuf)
 		return -ENOMEM;
drivers/usb/core/devices.c +1 -1
index b741639..3163ae4 100644
@@ -513,7 +513,7 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
 		return 0;
 	/* allocate 2^1 pages = 8K (on i386);
 	 * should be more than enough for one device */
-	pages_start = (char *)__get_free_pages(GFP_NOIO, 1);
+	pages_start = get_free_pages(GFP_NOIO, 1);
 	if (!pages_start)
 		return -ENOMEM;
 
drivers/video/fbdev/fb-puv3.c +1 -1
index 88fa2e7..e6dfba5 100644
@@ -671,7 +671,7 @@ static int unifb_probe(struct platform_device *dev)
 	struct resource *iomem;
 	void *videomemory;
 
-	videomemory = (void *)__get_free_pages(GFP_KERNEL | __GFP_COMP,
+	videomemory = get_free_pages(GFP_KERNEL | __GFP_COMP,
 				get_order(UNIFB_MEMSIZE));
 	if (!videomemory)
 		goto err;
drivers/video/fbdev/ssd1307fb.c +1 -1
index fa34808..ba475e1 100644
@@ -592,7 +592,7 @@ static int ssd1307fb_probe(struct i2c_client *client,
 
 	vmem_size = par->width * par->height / 8;
 
-	vmem = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	vmem = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					get_order(vmem_size));
 	if (!vmem) {
 		dev_err(&client->dev, "Couldn't allocate graphical memory.\n");
fs/ceph/mds_client.c +1 -2
index 40c9ef6..459cb01731 100644
@@ -1677,8 +1677,7 @@ int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req,
 
 	order = get_order(size * num_entries);
 	while (order >= 0) {
-		rinfo->dir_in = (void*)__get_free_pages(GFP_KERNEL |
-							__GFP_NOWARN,
+		rinfo->dir_in = get_free_pages(GFP_KERNEL | __GFP_NOWARN,
 							order);
 		if (rinfo->dir_in)
 			break;
fs/configfs/file.c +1 -1
index c4a3c5c..0fd6d8e 100644
@@ -140,7 +140,7 @@ fill_write_buffer(struct configfs_buffer * buffer, const char __user * buf, size
 	int error;
 
 	if (!buffer->page)
-		buffer->page = (char *)__get_free_pages(GFP_KERNEL, 0);
+		buffer->page = get_free_pages(GFP_KERNEL, 0);
 	if (!buffer->page)
 		return -ENOMEM;
 
fs/hfs/mdb.c +1 -1
index 92f1730..914a40e 100644
@@ -166,7 +166,7 @@ int hfs_mdb_get(struct super_block *sb)
 		pr_warn("continuing without an alternate MDB\n");
 	}
 
-	HFS_SB(sb)->bitmap = (__be32 *)__get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0);
+	HFS_SB(sb)->bitmap = get_free_pages(GFP_KERNEL, PAGE_SIZE < 8192 ? 1 : 0);
 	if (!HFS_SB(sb)->bitmap)
 		goto out;
 
fs/jbd2/journal.c +2 -2
index 450a30b..337faf2 100644
@@ -2301,12 +2301,12 @@ void *jbd2_alloc(size_t size, gfp_t flags)
 
 	flags |= __GFP_REPEAT;
 	if (size == PAGE_SIZE)
-		ptr = (void *)__get_free_pages(flags, 0);
+		ptr = get_free_pages(flags, 0);
 	else if (size > PAGE_SIZE) {
 		int order = get_order(size);
 
 		if (order < 3)
-			ptr = (void *)__get_free_pages(flags, order);
+			ptr = get_free_pages(flags, order);
 		else
 			ptr = vmalloc(size);
 	} else
fs/nilfs2/ioctl.c +1 -1
index 09d2ede..da2c0ee 100644
@@ -84,7 +84,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
 	if (argv->v_index > ~(__u64)0 - argv->v_nmembs)
 		return -EINVAL;
 
-	buf = (void *)__get_free_pages(GFP_NOFS, 0);
+	buf = get_free_pages(GFP_NOFS, 0);
 	if (unlikely(!buf))
 		return -ENOMEM;
 	maxmembs = PAGE_SIZE / argv->v_size;
fs/proc/vmcore.c +2 -2
index dd6566c..b4cf217 100644
@@ -1027,7 +1027,7 @@ static int __init parse_crash_elf64_headers(void)
 	elfcorebuf_sz_orig = sizeof(Elf64_Ehdr) +
 				ehdr.e_phnum * sizeof(Elf64_Phdr);
 	elfcorebuf_sz = elfcorebuf_sz_orig;
-	elfcorebuf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	elfcorebuf = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					      get_order(elfcorebuf_sz_orig));
 	if (!elfcorebuf)
 		return -ENOMEM;
@@ -1082,7 +1082,7 @@ static int __init parse_crash_elf32_headers(void)
 	/* Read in all elf headers. */
 	elfcorebuf_sz_orig = sizeof(Elf32_Ehdr) + ehdr.e_phnum * sizeof(Elf32_Phdr);
 	elfcorebuf_sz = elfcorebuf_sz_orig;
-	elfcorebuf = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+	elfcorebuf = get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					      get_order(elfcorebuf_sz_orig));
 	if (!elfcorebuf)
 		return -ENOMEM;
fs/quota/dquot.c +1 -1
index ef0d64b..b814eeb 100644
@@ -2894,7 +2894,7 @@ static int __init dquot_init(void)
 			NULL);
 
 	order = 0;
-	dquot_hash = (struct hlist_head *)__get_free_pages(GFP_ATOMIC, order);
+	dquot_hash = get_free_pages(GFP_ATOMIC, order);
 	if (!dquot_hash)
 		panic("Cannot create dquot hash table");
 
kernel/trace/ftrace.c +1 -1
index 927cdd4..1d42951 100644
@@ -2924,7 +2924,7 @@ static int ftrace_allocate_records(struct ftrace_page *pg, int count)
 		order--;
 
  again:
-	pg->records = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
+	pg->records = get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 
 	if (!pg->records) {
 		/* if we can't allocate this size, try something smaller */
kernel/trace/trace_events.c +2 -4
index 5d06111..0a0a08e 100644
@@ -1640,8 +1640,7 @@ ftrace_event_pid_write(struct file *filp, const char __user *ubuf,
 			else
 				pid_list->order = 0;
 
-			pid_list->pids = (void *)__get_free_pages(GFP_KERNEL,
-								  pid_list->order);
+			pid_list->pids = get_free_pages(GFP_KERNEL, pid_list->order);
 			if (!pid_list->pids)
 				break;
 
@@ -1656,8 +1655,7 @@ ftrace_event_pid_write(struct file *filp, const char __user *ubuf,
 		if (pid_list->nr_pids >= max_pids(pid_list)) {
 			pid_t *pid_page;
 
-			pid_page = (void *)__get_free_pages(GFP_KERNEL,
-							    pid_list->order + 1);
+			pid_page = get_free_pages(GFP_KERNEL, pid_list->order + 1);
 			if (!pid_page)
 				break;
 			memcpy(pid_page, pid_list->pids,
lib/percpu_ida.c +1 -1
index d58f5a9..ef95209 100644
@@ -303,7 +303,7 @@ int __percpu_ida_init(struct percpu_ida *pool, unsigned long nr_tags,
 	}
 
 	order = get_order(nr_tags * sizeof(unsigned));
-	pool->freelist = (void *) __get_free_pages(GFP_KERNEL, order);
+	pool->freelist = get_free_pages(GFP_KERNEL, order);
 	if (!pool->freelist)
 		return -ENOMEM;
 
lib/raid6/algos.c +1 -1
index 3d8cf31..c98026d 100644
@@ -218,7 +218,7 @@ int __init raid6_select_algo(void)
 		dptrs[i] = ((char *)raid6_gfmul) + PAGE_SIZE*i;
 
 	/* Normal code - use a 2-page allocation to avoid D$ conflict */
-	syndromes = (void *) __get_free_pages(GFP_KERNEL, 1);
+	syndromes = get_free_pages(GFP_KERNEL, 1);
 
 	if (!syndromes) {
 		pr_err("raid6: Yikes!  No memory available.\n");
lib/swiotlb.c +5 -7
index 87e33e7..456e38d 100644
@@ -260,7 +260,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
 	bytes = io_tlb_nslabs << IO_TLB_SHIFT;
 
 	while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
-		vstart = (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN,
+		vstart = get_free_pages(GFP_DMA | __GFP_NOWARN,
 						  order);
 		if (vstart)
 			break;
@@ -299,8 +299,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
 	/*
 	 * Get the overflow emergency buffer
 	 */
-	v_overflow_buffer = (void *)__get_free_pages(GFP_DMA,
-						     get_order(io_tlb_overflow));
+	v_overflow_buffer = get_free_pages(GFP_DMA, get_order(io_tlb_overflow));
 	if (!v_overflow_buffer)
 		goto cleanup2;
 
@@ -311,13 +310,12 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
 	 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
 	 * between io_tlb_start and io_tlb_end.
 	 */
-	io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL,
+	io_tlb_list = get_free_pages(GFP_KERNEL,
 	                              get_order(io_tlb_nslabs * sizeof(int)));
 	if (!io_tlb_list)
 		goto cleanup3;
 
-	io_tlb_orig_addr = (phys_addr_t *)
-		__get_free_pages(GFP_KERNEL,
+	io_tlb_orig_addr = get_free_pages(GFP_KERNEL,
 				 get_order(io_tlb_nslabs *
 					   sizeof(phys_addr_t)));
 	if (!io_tlb_orig_addr)
@@ -634,7 +632,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
 	if (hwdev && hwdev->coherent_dma_mask)
 		dma_mask = hwdev->coherent_dma_mask;
 
-	ret = (void *)__get_free_pages(flags, order);
+	ret = get_free_pages(flags, order);
 	if (ret) {
 		dev_addr = swiotlb_virt_to_bus(hwdev, ret);
 		if (dev_addr + size - 1 > dma_mask) {
mm/memory.c +1 -1
index 8364c20..a3c4440 100644
@@ -194,7 +194,7 @@ static bool tlb_next_batch(struct mmu_gather *tlb)
 	if (tlb->batch_count == MAX_GATHER_BATCH_COUNT)
 		return false;
 
-	batch = (void *)__get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
+	batch = get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
 	if (!batch)
 		return false;
 
mm/page_alloc.c +2 -2
index 9ab053f..a4d01ea 100644
@@ -3276,7 +3276,7 @@ EXPORT_SYMBOL(get_free_pages);
 
 void *get_zeroed_page(gfp_t gfp_mask)
 {
-	return (void *)__get_free_pages(gfp_mask | __GFP_ZERO, 0);
+	return get_free_pages(gfp_mask | __GFP_ZERO, 0);
 }
 EXPORT_SYMBOL(get_zeroed_page);
 
@@ -3481,7 +3481,7 @@ static void *make_alloc_exact(void *addr, unsigned int order,
 void *alloc_pages_exact(size_t size, gfp_t gfp_mask)
 {
 	unsigned int order = get_order(size);
-	void *addr = (void *)__get_free_pages(gfp_mask, order);
+	void *addr = get_free_pages(gfp_mask, order);
 	return make_alloc_exact(addr, order, size);
 }
 EXPORT_SYMBOL(alloc_pages_exact);
mm/slub.c +1 -1
index 5da985fe..c04a507 100644
@@ -4206,7 +4206,7 @@ static int alloc_loc_track(struct loc_track *t, unsigned long max, gfp_t flags)
 
 	order = get_order(sizeof(struct location) * max);
 
-	l = (void *)__get_free_pages(flags, order);
+	l = get_free_pages(flags, order);
 	if (!l)
 		return 0;
 
net/core/neighbour.c +1 -2
index 6eb5170..621eaac 100644
@@ -327,8 +327,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
 	if (size <= PAGE_SIZE)
 		buckets = kzalloc(size, GFP_ATOMIC);
 	else
-		buckets = (struct neighbour __rcu **)
-			  __get_free_pages(GFP_ATOMIC | __GFP_ZERO,
+		buckets = get_free_pages(GFP_ATOMIC | __GFP_ZERO,
 					   get_order(size));
 	if (!buckets) {
 		kfree(ret);
net/dccp/proto.c +4 -4
index b689ca8..77c2afe 100644
@@ -1147,8 +1147,8 @@ static int __init dccp_init(void)
 		while (hash_size & (hash_size - 1))
 			hash_size--;
 		dccp_hashinfo.ehash_mask = hash_size - 1;
-		dccp_hashinfo.ehash = (struct inet_ehash_bucket *)
-			__get_free_pages(GFP_ATOMIC|__GFP_NOWARN, ehash_order);
+		dccp_hashinfo.ehash = 
+			get_free_pages(GFP_ATOMIC|__GFP_NOWARN, ehash_order);
 	} while (!dccp_hashinfo.ehash && --ehash_order > 0);
 
 	if (!dccp_hashinfo.ehash) {
@@ -1170,8 +1170,8 @@ static int __init dccp_init(void)
 		if ((dccp_hashinfo.bhash_size > (64 * 1024)) &&
 		    bhash_order > 0)
 			continue;
-		dccp_hashinfo.bhash = (struct inet_bind_hashbucket *)
-			__get_free_pages(GFP_ATOMIC|__GFP_NOWARN, bhash_order);
+		dccp_hashinfo.bhash =
+			get_free_pages(GFP_ATOMIC|__GFP_NOWARN, bhash_order);
 	} while (!dccp_hashinfo.bhash && --bhash_order >= 0);
 
 	if (!dccp_hashinfo.bhash) {
net/decnet/dn_route.c +1 -2
index 607a14f..9aae75d 100644
@@ -1894,8 +1894,7 @@ void __init dn_route_init(void)
 			sizeof(struct dn_rt_hash_bucket);
 		while(dn_rt_hash_mask & (dn_rt_hash_mask - 1))
 			dn_rt_hash_mask--;
-		dn_rt_hash_table = (struct dn_rt_hash_bucket *)
-			__get_free_pages(GFP_ATOMIC, order);
+		dn_rt_hash_table = get_free_pages(GFP_ATOMIC, order);
 	} while (dn_rt_hash_table == NULL && --order > 0);
 
 	if (!dn_rt_hash_table)
net/ipv4/fib_semantics.c +1 -2
index f69b6d9..fddffc1 100644
@@ -840,8 +840,7 @@ static struct hlist_head *fib_info_hash_alloc(int bytes)
 	if (bytes <= PAGE_SIZE)
 		return kzalloc(bytes, GFP_KERNEL);
 	else
-		return (struct hlist_head *)
-			__get_free_pages(GFP_KERNEL | __GFP_ZERO,
+		return get_free_pages(GFP_KERNEL | __GFP_ZERO,
 					 get_order(bytes));
 }
 
net/netfilter/nf_conntrack_core.c +1 -1
index 5a80da65..9124509 100644
@@ -1544,7 +1544,7 @@ void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls)
 	BUILD_BUG_ON(sizeof(struct hlist_nulls_head) != sizeof(struct hlist_head));
 	nr_slots = *sizep = roundup(*sizep, PAGE_SIZE / sizeof(struct hlist_nulls_head));
 	sz = nr_slots * sizeof(struct hlist_nulls_head);
-	hash = (void *)__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
+	hash = get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
 					get_order(sz));
 	if (!hash)
 		hash = vzalloc(sz);
net/netlink/af_netlink.c +2 -2
index da6fba6..587eb78 100644
@@ -340,7 +340,7 @@ static void *alloc_one_pg_vec_page(unsigned long order)
 	gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP | __GFP_ZERO |
 			  __GFP_NOWARN | __GFP_NORETRY;
 
-	buffer = (void *)__get_free_pages(gfp_flags, order);
+	buffer = get_free_pages(gfp_flags, order);
 	if (buffer != NULL)
 		return buffer;
 
@@ -349,7 +349,7 @@ static void *alloc_one_pg_vec_page(unsigned long order)
 		return buffer;
 
 	gfp_flags &= ~__GFP_NORETRY;
-	return (void *)__get_free_pages(gfp_flags, order);
+	return get_free_pages(gfp_flags, order);
 }
 
 static void **alloc_pg_vec(struct netlink_sock *nlk,
net/packet/af_packet.c +2 -2
index fae2812..c1d1284 100644
@@ -4013,7 +4013,7 @@ static char *alloc_one_pg_vec_page(unsigned long order)
 	gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP |
 			  __GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY;
 
-	buffer = (char *) __get_free_pages(gfp_flags, order);
+	buffer = get_free_pages(gfp_flags, order);
 	if (buffer)
 		return buffer;
 
@@ -4024,7 +4024,7 @@ static char *alloc_one_pg_vec_page(unsigned long order)
 
 	/* vmalloc failed, lets dig into swap here */
 	gfp_flags &= ~__GFP_NORETRY;
-	buffer = (char *) __get_free_pages(gfp_flags, order);
+	buffer = get_free_pages(gfp_flags, order);
 	if (buffer)
 		return buffer;
 
net/sched/sch_api.c +1 -2
index 1c9ff0b..4c854f0 100644
@@ -628,8 +628,7 @@ static struct hlist_head *qdisc_class_hash_alloc(unsigned int n)
 	if (size <= PAGE_SIZE)
 		h = kmalloc(size, GFP_KERNEL);
 	else
-		h = (struct hlist_head *)
-			__get_free_pages(GFP_KERNEL, get_order(size));
+		h = get_free_pages(GFP_KERNEL, get_order(size));
 
 	if (h != NULL) {
 		for (i = 0; i < n; i++)
net/sctp/protocol.c +4 -4
index 8dfdd0e..4e44dfd 100644
@@ -1418,8 +1418,8 @@ static __init int sctp_init(void)
 					sizeof(struct sctp_hashbucket);
 		if ((sctp_assoc_hashsize > (64 * 1024)) && order > 0)
 			continue;
-		sctp_assoc_hashtable = (struct sctp_hashbucket *)
-			__get_free_pages(GFP_ATOMIC|__GFP_NOWARN, order);
+		sctp_assoc_hashtable = 
+			get_free_pages(GFP_ATOMIC|__GFP_NOWARN, order);
 	} while (!sctp_assoc_hashtable && --order > 0);
 	if (!sctp_assoc_hashtable) {
 		pr_err("Failed association hash alloc\n");
@@ -1451,8 +1451,8 @@ static __init int sctp_init(void)
 					sizeof(struct sctp_bind_hashbucket);
 		if ((sctp_port_hashsize > (64 * 1024)) && order > 0)
 			continue;
-		sctp_port_hashtable = (struct sctp_bind_hashbucket *)
-			__get_free_pages(GFP_ATOMIC|__GFP_NOWARN, order);
+		sctp_port_hashtable =
+			get_free_pages(GFP_ATOMIC|__GFP_NOWARN, order);
 	} while (!sctp_port_hashtable && --order > 0);
 	if (!sctp_port_hashtable) {
 		pr_err("Failed bind hash alloc\n");
net/sctp/ssnmap.c +1 -2
index 97b1939..e3e290c 100644
@@ -59,8 +59,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
 	if (size <= KMALLOC_MAX_SIZE)
 		retval = kmalloc(size, gfp);
 	else
-		retval = (struct sctp_ssnmap *)
-			  __get_free_pages(gfp, get_order(size));
+		retval = get_free_pages(gfp, get_order(size));
 	if (!retval)
 		goto fail;
 
net/xfrm/xfrm_hash.c +1 -2
index f19872e..47c40d3 100644
@@ -21,8 +21,7 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz)
 	else if (hashdist)
 		n = vzalloc(sz);
 	else
-		n = (struct hlist_head *)
-			__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
+		n = get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
 					 get_order(sz));
 
 	return n;
security/integrity/ima/ima_crypto.c +2 -2
index 96f416c..f52bf51 100644
@@ -132,7 +132,7 @@ static void *ima_alloc_pages(loff_t max_size, size_t *allocated_size,
 		order = min(get_order(max_size), order);
 
 	for (; order; order--) {
-		ptr = (void *)__get_free_pages(gfp_mask, order);
+		ptr = get_free_pages(gfp_mask, order);
 		if (ptr) {
 			*allocated_size = PAGE_SIZE << order;
 			return ptr;
@@ -146,7 +146,7 @@ static void *ima_alloc_pages(loff_t max_size, size_t *allocated_size,
 	if (!last_warn)
 		gfp_mask |= __GFP_NOWARN;
 
-	ptr = (void *)__get_free_pages(gfp_mask, 0);
+	ptr = get_free_pages(gfp_mask, 0);
 	if (ptr) {
 		*allocated_size = PAGE_SIZE;
 		return ptr;
sound/core/memalloc.c +1 -1
index 43ac8b5..3a0b54c 100644
@@ -52,7 +52,7 @@ void *snd_malloc_pages(size_t size, gfp_t gfp_flags)
 		return NULL;
 	gfp_flags |= __GFP_COMP;	/* compound page lets parts be mapped */
 	pg = get_order(size);
-	return (void *) __get_free_pages(gfp_flags, pg);
+	return get_free_pages(gfp_flags, pg);
 }
 
 /**
sound/oss/dmabuf.c +1 -1
index 457755a..e7c45ab 100644
@@ -91,7 +91,7 @@ static int sound_alloc_dmap(struct dma_buffparms *dmap)
 	while (start_addr == NULL && dmap->buffsize > PAGE_SIZE) {
 		for (sz = 0, size = PAGE_SIZE; size < dmap->buffsize; sz++, size <<= 1);
 		dmap->buffsize = PAGE_SIZE * (1 << sz);
-		start_addr = (char *) __get_free_pages(GFP_ATOMIC|GFP_DMA|__GFP_NOWARN, sz);
+		start_addr = get_free_pages(GFP_ATOMIC|GFP_DMA|__GFP_NOWARN, sz);
 		if (start_addr == NULL)
 			dmap->buffsize /= 2;
 	}
sound/usb/usx2y/usb_stream.c +2 -3
index c423951..8ca8200 100644
@@ -191,7 +191,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
 	}
 
 	pg = get_order(read_size);
-	sk->s = (void *) __get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO, pg);
+	sk->s = get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO, pg);
 	if (!sk->s) {
 		snd_printk(KERN_WARNING "couldn't __get_free_pages()\n");
 		goto out;
@@ -210,8 +210,7 @@ struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
 	sk->s->write_size = write_size;
 	pg = get_order(write_size);
 
-	sk->write_page =
-		(void *)__get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO, pg);
+	sk->write_page = get_free_pages(GFP_KERNEL|__GFP_COMP|__GFP_ZERO, pg);
 	if (!sk->write_page) {
 		snd_printk(KERN_WARNING "couldn't __get_free_pages()\n");
 		usb_stream_free(sk);
Signature · 1 line
2.1.4
author maintainer
#72 lore raw

PATCH 61/83 switch obvious cases to get_free_page()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/alpha/include/asm/pgalloc.h                  |  4 ++--
 arch/alpha/kernel/srm_env.c                       |  4 ++--
 arch/alpha/mm/init.c                              |  2 +-
 arch/arc/kernel/setup.c                           |  2 +-
 arch/arc/kernel/troubleshoot.c                    |  4 ++--
 arch/arm/include/asm/pgalloc.h                    |  2 +-
 arch/arm/kvm/arm.c                                |  2 +-
 arch/arm/kvm/mmu.c                                |  4 ++--
 arch/arm64/include/asm/pgalloc.h                  |  6 +++---
 arch/arm64/mm/mmu.c                               |  2 +-
 arch/arm64/mm/pgd.c                               |  2 +-
 arch/blackfin/kernel/dma-mapping.c                |  2 +-
 arch/cris/include/asm/pgalloc.h                   |  2 +-
 arch/frv/mm/pgalloc.c                             |  2 +-
 arch/hexagon/include/asm/pgalloc.h                |  4 ++--
 arch/m32r/include/asm/pgalloc.h                   |  4 ++--
 arch/m68k/include/asm/mcf_pgalloc.h               |  2 +-
 arch/m68k/include/asm/motorola_pgalloc.h          |  2 +-
 arch/metag/include/asm/pgalloc.h                  |  2 +-
 arch/microblaze/mm/pgtable.c                      |  2 +-
 arch/mn10300/mm/pgtable.c                         |  2 +-
 arch/openrisc/include/asm/pgalloc.h               |  2 +-
 arch/openrisc/mm/ioremap.c                        |  2 +-
 arch/parisc/include/asm/pgalloc.h                 |  2 +-
 arch/powerpc/include/asm/pgalloc-64.h             |  2 +-
 arch/powerpc/kvm/e500.c                           |  2 +-
 arch/powerpc/kvm/e500mc.c                         |  2 +-
 arch/powerpc/mm/hugetlbpage.c                     |  2 +-
 arch/powerpc/mm/pgtable_32.c                      |  2 +-
 arch/powerpc/platforms/pseries/cmm.c              |  6 ++----
 arch/powerpc/platforms/pseries/iommu.c            |  4 ++--
 arch/s390/crypto/aes_s390.c                       |  2 +-
 arch/s390/crypto/des_s390.c                       |  2 +-
 arch/s390/crypto/prng.c                           |  2 +-
 arch/s390/kernel/kprobes.c                        |  2 +-
 arch/s390/kernel/topology.c                       |  2 +-
 arch/s390/mm/cmm.c                                |  5 ++---
 arch/s390/mm/maccess.c                            |  4 ++--
 arch/s390/mm/pgtable.c                            |  3 +--
 arch/tile/mm/elf.c                                |  2 +-
 arch/um/kernel/mem.c                              |  6 +++---
 arch/unicore32/include/asm/pgalloc.h              |  2 +-
 arch/x86/kvm/mmu.c                                |  2 +-
 arch/x86/kvm/vmx.c                                | 21 +++++++++------------
 arch/x86/mm/pgtable.c                             |  8 ++++----
 arch/x86/pci/pcbios.c                             |  2 +-
 arch/x86/um/ldt.c                                 |  3 +--
 arch/x86/xen/mmu.c                                |  2 +-
 arch/x86/xen/p2m.c                                |  2 +-
 arch/xtensa/include/asm/pgalloc.h                 |  2 +-
 block/partitions/check.c                          |  2 +-
 crypto/blkcipher.c                                |  2 +-
 crypto/tcrypt.c                                   |  4 ++--
 crypto/testmgr.c                                  |  2 +-
 drivers/acpi/nvs.c                                |  2 +-
 drivers/block/cciss.c                             |  2 +-
 drivers/block/drbd/drbd_main.c                    |  4 ++--
 drivers/char/agp/amd-k7-agp.c                     |  2 +-
 drivers/char/agp/ati-agp.c                        |  2 +-
 drivers/char/agp/sworks-agp.c                     |  2 +-
 drivers/char/mem.c                                |  4 ++--
 drivers/char/tpm/xen-tpmfront.c                   |  2 +-
 drivers/char/xilinx_hwicap/xilinx_hwicap.c        |  2 +-
 drivers/firewire/ohci.c                           |  2 +-
 drivers/gpu/drm/via/via_dmablit.c                 |  3 +--
 drivers/ide/ide-proc.c                            |  2 +-
 drivers/infiniband/core/umem.c                    |  4 ++--
 drivers/infiniband/core/umem_odp.c                |  2 +-
 drivers/infiniband/hw/cxgb3/iwch_provider.c       |  2 +-
 drivers/infiniband/hw/cxgb4/device.c              |  3 +--
 drivers/infiniband/hw/cxgb4/mem.c                 |  2 +-
 drivers/infiniband/hw/mlx4/mr.c                   |  2 +-
 drivers/infiniband/hw/mlx5/odp.c                  |  2 +-
 drivers/infiniband/hw/mthca/mthca_provider.c      |  2 +-
 drivers/infiniband/hw/usnic/usnic_uiom.c          |  2 +-
 drivers/input/misc/xen-kbdfront.c                 |  2 +-
 drivers/macintosh/rack-meter.c                    |  2 +-
 drivers/media/pci/pt1/pt1.c                       |  2 +-
 drivers/media/pci/ttpci/av7110_ca.c               |  2 +-
 drivers/misc/cxl/pci.c                            |  2 +-
 drivers/misc/ibmasm/ibmasmfs.c                    |  2 +-
 drivers/misc/lkdtm.c                              |  6 +++---
 drivers/mmc/host/tmio_mmc_dma.c                   |  2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c   |  2 +-
 drivers/net/ethernet/sfc/mcdi.c                   |  2 +-
 drivers/net/ethernet/toshiba/ps3_gelic_wireless.c | 12 ++++++------
 drivers/net/usb/kaweth.c                          |  2 +-
 drivers/pci/xen-pcifront.c                        |  3 +--
 drivers/platform/x86/dell-laptop.c                |  2 +-
 drivers/s390/block/dasd_eckd.c                    |  2 +-
 drivers/s390/block/xpram.c                        |  4 ++--
 drivers/s390/char/sclp_cmd.c                      |  2 +-
 drivers/s390/char/vmur.c                          |  4 ++--
 drivers/s390/char/zcore.c                         |  2 +-
 drivers/s390/cio/qdio_setup.c                     |  4 ++--
 drivers/s390/cio/scm.c                            |  2 +-
 drivers/s390/net/qeth_core_main.c                 |  2 +-
 drivers/scsi/cxlflash/main.c                      |  2 +-
 drivers/scsi/ipr.c                                |  2 +-
 drivers/scsi/scsi_devinfo.c                       |  2 +-
 drivers/scsi/scsi_proc.c                          |  4 ++--
 drivers/scsi/xen-scsifront.c                      |  2 +-
 drivers/spi/spi-sh-msiof.c                        |  4 ++--
 drivers/staging/lustre/lustre/llite/llite_lib.c   |  2 +-
 drivers/staging/unisys/visorbus/visorchannel.c    |  2 +-
 drivers/target/target_core_file.c                 |  2 +-
 drivers/tty/hvc/hvc_xen.c                         |  2 +-
 drivers/tty/hvc/hvcs.c                            |  2 +-
 drivers/tty/mxser.c                               |  2 +-
 drivers/tty/rocket.c                              |  2 +-
 drivers/tty/serial/68328serial.c                  |  2 +-
 drivers/tty/serial/men_z135_uart.c                |  2 +-
 drivers/tty/serial/pch_uart.c                     |  2 +-
 drivers/tty/vt/vc_screen.c                        |  4 ++--
 drivers/usb/atm/cxacru.c                          |  6 +++---
 drivers/usb/atm/speedtch.c                        |  2 +-
 drivers/usb/core/devio.c                          |  2 +-
 drivers/usb/misc/rio500.c                         |  4 ++--
 drivers/usb/serial/usb_wwan.c                     |  2 +-
 drivers/uwb/hwa-rc.c                              |  2 +-
 drivers/video/fbdev/xen-fbfront.c                 |  2 +-
 drivers/xen/events/events_base.c                  |  2 +-
 drivers/xen/events/events_fifo.c                  |  4 ++--
 drivers/xen/evtchn.c                              |  2 +-
 drivers/xen/grant-table.c                         |  4 ++--
 fs/binfmt_misc.c                                  |  2 +-
 fs/fuse/dir.c                                     |  2 +-
 fs/fuse/file.c                                    |  2 +-
 fs/isofs/dir.c                                    |  2 +-
 fs/jfs/jfs_dtree.c                                |  2 +-
 fs/namespace.c                                    |  2 +-
 fs/nfs/namespace.c                                |  2 +-
 fs/nfs/nfs4namespace.c                            |  8 ++++----
 fs/nfs/super.c                                    |  2 +-
 fs/nfsd/vfs.c                                     |  2 +-
 fs/ocfs2/dlm/dlmdomain.c                          |  2 +-
 fs/ocfs2/dlm/dlmmaster.c                          |  2 +-
 fs/ocfs2/dlm/dlmrecovery.c                        |  2 +-
 fs/overlayfs/copy_up.c                            |  2 +-
 fs/proc/base.c                                    | 10 +++++-----
 fs/select.c                                       |  2 +-
 include/linux/quicklist.h                         |  2 +-
 kernel/groups.c                                   |  2 +-
 kernel/power/swap.c                               | 13 ++++++-------
 kernel/sysctl.c                                   |  6 +++---
 kernel/trace/trace_events.c                       |  4 ++--
 kernel/trace/trace_events_filter.c                |  2 +-
 kernel/trace/trace_events_trigger.c               |  2 +-
 kernel/user_namespace.c                           |  2 +-
 lib/scatterlist.c                                 |  2 +-
 mm/memory.c                                       |  4 ++--
 mm/migrate.c                                      |  2 +-
 mm/mincore.c                                      |  2 +-
 net/atm/mpoa_proc.c                               |  2 +-
 security/selinux/hooks.c                          |  2 +-
 security/selinux/selinuxfs.c                      |  2 +-
 sound/oss/msnd_pinnacle.c                         |  4 ++--
 157 files changed, 221 insertions(+), 233 deletions(-)
arch/alpha/include/asm/pgalloc.h +2 -2
index 078da57..001da1d 100644
@@ -40,7 +40,7 @@ pgd_free(struct mm_struct *mm, pgd_t *pgd)
 static inline pmd_t *
 pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+	pmd_t *ret = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
 	return ret;
 }
 
@@ -53,7 +53,7 @@ pmd_free(struct mm_struct *mm, pmd_t *pmd)
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+	pte_t *pte = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
 	return pte;
 }
 
arch/alpha/kernel/srm_env.c +2 -2
index a66f23b..14f8597 100644
@@ -82,7 +82,7 @@ static int srm_env_proc_show(struct seq_file *m, void *v)
 	unsigned long	id = (unsigned long)m->private;
 	char		*page;
 
-	page = (char *)__get_free_page(GFP_USER);
+	page = get_free_page(GFP_USER);
 	if (!page)
 		return -ENOMEM;
 
@@ -107,7 +107,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
 {
 	int res;
 	unsigned long	id = (unsigned long)PDE_DATA(file_inode(file));
-	char		*buf = (char *) __get_free_page(GFP_USER);
+	char		*buf = get_free_page(GFP_USER);
 	unsigned long	ret1, ret2;
 
 	if (!buf)
arch/alpha/mm/init.c +1 -1
index a1bea91..6a604df 100644
@@ -42,7 +42,7 @@ pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *ret, *init;
 
-	ret = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	ret = get_free_page(GFP_KERNEL | __GFP_ZERO);
 	init = pgd_offset(&init_mm, 0UL);
 	if (ret) {
 #ifdef CONFIG_ALPHA_LARGE_VMALLOC
arch/arc/kernel/setup.c +1 -1
index 56fd4fc..39cae4a 100644
@@ -473,7 +473,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 		goto done;
 	}
 
-	str = (char *)__get_free_page(GFP_TEMPORARY);
+	str = get_free_page(GFP_TEMPORARY);
 	if (!str)
 		goto done;
 
arch/arc/kernel/troubleshoot.c +2 -2
index eb3464d..f09d68d 100644
@@ -175,7 +175,7 @@ void show_regs(struct pt_regs *regs)
 	struct callee_regs *cregs;
 	char *buf;
 
-	buf = (char *)__get_free_page(GFP_TEMPORARY);
+	buf = get_free_page(GFP_TEMPORARY);
 	if (!buf)
 		return;
 
@@ -272,7 +272,7 @@ static int fill_display_data(char *kbuf)
 
 static int tlb_stats_open(struct inode *inode, struct file *file)
 {
-	file->private_data = (void *)__get_free_page(GFP_KERNEL);
+	file->private_data = get_free_page(GFP_KERNEL);
 	return 0;
 }
 
arch/arm/include/asm/pgalloc.h +1 -1
index 540647d..aafdebc 100644
@@ -85,7 +85,7 @@ pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
 	pte_t *pte;
 
-	pte = (pte_t *)__get_free_page(PGALLOC_GFP);
+	pte = get_free_page(PGALLOC_GFP);
 	if (pte)
 		clean_pte_table(pte);
 
arch/arm/kvm/arm.c +1 -1
index 385bdce..56b066f 100644
@@ -1046,7 +1046,7 @@ static int init_hyp_mode(void)
 	 * Allocate stack pages for Hypervisor-mode
 	 */
 	for_each_possible_cpu(cpu) {
-		void *stack_page = (void *)__get_free_page(GFP_KERNEL);
+		void *stack_page = get_free_page(GFP_KERNEL);
 		if (!stack_page) {
 			err = -ENOMEM;
 			goto out_free_stack_pages;
arch/arm/kvm/mmu.c +2 -2
index 429b673..34c2de6 100644
@@ -131,7 +131,7 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
 	if (cache->nobjs >= min)
 		return 0;
 	while (cache->nobjs < max) {
-		page = (void *)__get_free_page(PGALLOC_GFP);
+		page = get_free_page(PGALLOC_GFP);
 		if (!page)
 			return -ENOMEM;
 		cache->objects[cache->nobjs++] = page;
@@ -1679,7 +1679,7 @@ int kvm_mmu_init(void)
 	}
 
 	if (__kvm_cpu_uses_extended_idmap()) {
-		merged_hyp_pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+		merged_hyp_pgd = get_free_page(GFP_KERNEL | __GFP_ZERO);
 		if (!merged_hyp_pgd) {
 			kvm_err("Failed to allocate extra HYP pgd\n");
 			goto out;
arch/arm64/include/asm/pgalloc.h +3 -3
index ce9b3c0..5bfbe35 100644
@@ -33,7 +33,7 @@
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
-	return (pmd_t *)__get_free_page(PGALLOC_GFP);
+	return get_free_page(PGALLOC_GFP);
 }
 
 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
@@ -53,7 +53,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 
 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
-	return (pud_t *)__get_free_page(PGALLOC_GFP);
+	return get_free_page(PGALLOC_GFP);
 }
 
 static inline void pud_free(struct mm_struct *mm, pud_t *pud)
@@ -75,7 +75,7 @@ extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	return (pte_t *)__get_free_page(PGALLOC_GFP);
+	return get_free_page(PGALLOC_GFP);
 }
 
 static inline pgtable_t
arch/arm64/mm/mmu.c +1 -1
index 873e363..753b6cb 100644
@@ -267,7 +267,7 @@ static void *late_alloc(unsigned long size)
 	void *ptr;
 
 	BUG_ON(size > PAGE_SIZE);
-	ptr = (void *)__get_free_page(PGALLOC_GFP);
+	ptr = get_free_page(PGALLOC_GFP);
 	BUG_ON(!ptr);
 	return ptr;
 }
arch/arm64/mm/pgd.c +1 -1
index a468648..d5574e5 100644
@@ -33,7 +33,7 @@ static struct kmem_cache *pgd_cache;
 pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	if (PGD_SIZE == PAGE_SIZE)
-		return (pgd_t *)__get_free_page(PGALLOC_GFP);
+		return get_free_page(PGALLOC_GFP);
 	else
 		return kmem_cache_alloc(pgd_cache, PGALLOC_GFP);
 }
arch/blackfin/kernel/dma-mapping.c +1 -1
index df437e5..aa71d9b 100644
@@ -27,7 +27,7 @@ static void dma_alloc_init(unsigned long start, unsigned long end)
 	spin_lock_init(&dma_page_lock);
 	dma_initialized = 0;
 
-	dma_page = (unsigned long *)__get_free_page(GFP_KERNEL);
+	dma_page = get_free_page(GFP_KERNEL);
 	memset(dma_page, 0, PAGE_SIZE);
 	dma_base = PAGE_ALIGN(start);
 	dma_size = PAGE_ALIGN(end) - PAGE_ALIGN(start);
arch/cris/include/asm/pgalloc.h +1 -1
index cac8206..65e3f32 100644
@@ -24,7 +24,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-  	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+  	pte_t *pte = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
  	return pte;
 }
 
arch/frv/mm/pgalloc.c +1 -1
index 41907d2..16addf2 100644
@@ -22,7 +22,7 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE)));
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	pte_t *pte = get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
arch/hexagon/include/asm/pgalloc.h +2 -2
index 48c04dc..ca48fcf 100644
@@ -35,7 +35,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *pgd;
 
-	pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	pgd = get_free_page(GFP_KERNEL | __GFP_ZERO);
 
 	/*
 	 * There may be better ways to do this, but to ensure
@@ -79,7 +79,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 					  unsigned long address)
 {
 	gfp_t flags =  GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO;
-	return (pte_t *) __get_free_page(flags);
+	return get_free_page(flags);
 }
 
 static inline void pte_free(struct mm_struct *mm, struct page *pte)
arch/m32r/include/asm/pgalloc.h +2 -2
index 3923429..80d1b26 100644
@@ -20,7 +20,7 @@ static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  */
 static __inline__ pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-	pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
+	pgd_t *pgd = get_free_page(GFP_KERNEL|__GFP_ZERO);
 
 	return pgd;
 }
@@ -33,7 +33,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 static __inline__ pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 	unsigned long address)
 {
-	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
+	pte_t *pte = get_free_page(GFP_KERNEL|__GFP_ZERO);
 
 	return pte;
 }
arch/m68k/include/asm/mcf_pgalloc.h +1 -1
index 2e70a56..04ffc22 100644
@@ -93,7 +93,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
 	pgd_t *new_pgd;
 
-	new_pgd = (pgd_t *)__get_free_page(GFP_DMA | __GFP_NOWARN);
+	new_pgd = get_free_page(GFP_DMA | __GFP_NOWARN);
 	if (!new_pgd)
 		return NULL;
 	memcpy(new_pgd, swapper_pg_dir, PAGE_SIZE);
arch/m68k/include/asm/motorola_pgalloc.h +1 -1
index 6e84224..60df054 100644
@@ -11,7 +11,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long ad
 {
 	pte_t *pte;
 
-	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+	pte = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
 	if (pte) {
 		__flush_page_to_ram(pte);
 		flush_tlb_kernel_page(pte);
arch/metag/include/asm/pgalloc.h +1 -1
index cf9e2fb..ae19628 100644
@@ -42,7 +42,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 					  unsigned long address)
 {
-	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT |
+	pte_t *pte = get_free_page(GFP_KERNEL | __GFP_REPEAT |
 					      __GFP_ZERO);
 	return pte;
 }
arch/microblaze/mm/pgtable.c +1 -1
index 4f4520e..76e117d 100644
@@ -239,7 +239,7 @@ __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 {
 	pte_t *pte;
 	if (mem_init_done) {
-		pte = (pte_t *)__get_free_page(GFP_KERNEL |
+		pte = get_free_page(GFP_KERNEL |
 					__GFP_REPEAT | __GFP_ZERO);
 	} else {
 		pte = (pte_t *)early_get_page();
arch/mn10300/mm/pgtable.c +1 -1
index e77a7c7..391992b 100644
@@ -63,7 +63,7 @@ void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	pte_t *pte = get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
arch/openrisc/include/asm/pgalloc.h +1 -1
index 1f61391..642186f 100644
@@ -43,7 +43,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
  */
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-	pgd_t *ret = (pgd_t *)__get_free_page(GFP_KERNEL);
+	pgd_t *ret = get_free_page(GFP_KERNEL);
 
 	if (ret) {
 		memset(ret, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
arch/openrisc/mm/ioremap.c +1 -1
index 62b08ef..801533f 100644
@@ -122,7 +122,7 @@ pte_t __init_refok *pte_alloc_one_kernel(struct mm_struct *mm,
 	pte_t *pte;
 
 	if (likely(mem_init_done)) {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT);
+		pte = get_free_page(GFP_KERNEL | __GFP_REPEAT);
 	} else {
 		pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
 #if 0
arch/parisc/include/asm/pgalloc.h +1 -1
index 5c10934..94e5b41 100644
@@ -135,7 +135,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long address)
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+	pte_t *pte = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
 	return pte;
 }
 
arch/powerpc/include/asm/pgalloc-64.h +1 -1
index c26021b..e61b0d2 100644
@@ -79,7 +79,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 					  unsigned long address)
 {
-	return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
+	return get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
 }
 
 static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
arch/powerpc/kvm/e500.c +1 -1
index 29803fb..a525971 100644
@@ -462,7 +462,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_e500(struct kvm *kvm,
 	if (err)
 		goto uninit_id;
 
-	vcpu->arch.shared = (void*)__get_free_page(GFP_KERNEL|__GFP_ZERO);
+	vcpu->arch.shared = get_free_page(GFP_KERNEL|__GFP_ZERO);
 	if (!vcpu->arch.shared)
 		goto uninit_tlb;
 
arch/powerpc/kvm/e500mc.c +1 -1
index e002a71..450eab9 100644
@@ -330,7 +330,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_e500mc(struct kvm *kvm,
 	if (err)
 		goto uninit_vcpu;
 
-	vcpu->arch.shared = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	vcpu->arch.shared = get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (!vcpu->arch.shared)
 		goto uninit_tlb;
 
arch/powerpc/mm/hugetlbpage.c +1 -1
index a466b84..a94f92b6 100644
@@ -497,7 +497,7 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte)
 	}
 
 	if (*batchp == NULL) {
-		*batchp = (struct hugepd_freelist *)__get_free_page(GFP_ATOMIC);
+		*batchp = get_free_page(GFP_ATOMIC);
 		(*batchp)->index = 0;
 	}
 
arch/powerpc/mm/pgtable_32.c +1 -1
index 6e6c311..542f425 100644
@@ -109,7 +109,7 @@ __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long add
 	pte_t *pte;
 
 	if (slab_is_available()) {
-		pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+		pte = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
 	} else {
 		pte = __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
 		if (pte)
arch/powerpc/platforms/pseries/cmm.c +2 -4
index db1dbe6..f4aa67d 100644
@@ -145,8 +145,7 @@ static long cmm_alloc_pages(long nr)
 		if (!pa || pa->index >= CMM_NR_PAGES) {
 			/* Need a new page for the page list. */
 			spin_unlock(&cmm_lock);
-			npa = (struct cmm_page_array *)__get_free_page(
-					GFP_NOIO | __GFP_NOWARN |
+			npa = get_free_page(GFP_NOIO | __GFP_NOWARN |
 					__GFP_NORETRY | __GFP_NOMEMALLOC);
 			if (!npa) {
 				pr_info("%s: Can not allocate new page list\n", __func__);
@@ -566,8 +565,7 @@ static int cmm_mem_going_offline(void *arg)
 	while (pa_curr) {
 		if (((unsigned long)pa_curr >= start_page) &&
 				((unsigned long)pa_curr < end_page)) {
-			npa = (struct cmm_page_array *)__get_free_page(
-					GFP_NOIO | __GFP_NOWARN |
+			npa = get_free_page(GFP_NOIO | __GFP_NOWARN |
 					__GFP_NORETRY | __GFP_NOMEMALLOC);
 			if (!npa) {
 				spin_unlock(&cmm_lock);
arch/powerpc/platforms/pseries/iommu.c +2 -2
index bd98ce2..f471734 100644
@@ -275,7 +275,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
 	 * from iommu_alloc{,_sg}()
 	 */
 	if (!tcep) {
-		tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
+		tcep = get_free_page(GFP_ATOMIC);
 		/* If allocation fails, fall back to the loop implementation */
 		if (!tcep) {
 			local_irq_restore(flags);
@@ -474,7 +474,7 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn,
 	tcep = __this_cpu_read(tce_page);
 
 	if (!tcep) {
-		tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
+		tcep = get_free_page(GFP_ATOMIC);
 		if (!tcep) {
 			local_irq_enable();
 			return -ENOMEM;
arch/s390/crypto/aes_s390.c +1 -1
index 4b610d6..15edffb 100644
@@ -936,7 +936,7 @@ static int __init aes_s390_init(void)
 				CRYPT_S390_MSA | CRYPT_S390_MSA4) &&
 	    crypt_s390_func_available(KMCTR_AES_256_ENCRYPT,
 				CRYPT_S390_MSA | CRYPT_S390_MSA4)) {
-		ctrblk = (u8 *) __get_free_page(GFP_KERNEL);
+		ctrblk = get_free_page(GFP_KERNEL);
 		if (!ctrblk) {
 			ret = -ENOMEM;
 			goto ctr_aes_err;
arch/s390/crypto/des_s390.c +1 -1
index 9f402dc..6f7288b 100644
@@ -573,7 +573,7 @@ static int __init des_s390_init(void)
 		ret = crypto_register_alg(&ctr_des3_alg);
 		if (ret)
 			goto ctr_des3_err;
-		ctrblk = (u8 *) __get_free_page(GFP_KERNEL);
+		ctrblk = get_free_page(GFP_KERNEL);
 		if (!ctrblk) {
 			ret = -ENOMEM;
 			goto ctr_mem_err;
arch/s390/crypto/prng.c +1 -1
index d3835d2..2971c2c 100644
@@ -116,7 +116,7 @@ static int generate_entropy(u8 *ebuf, size_t nbytes)
 	int n, ret = 0;
 	u8 *pg, *h, hash[32];
 
-	pg = (u8 *) __get_free_page(GFP_KERNEL);
+	pg = get_free_page(GFP_KERNEL);
 	if (!pg) {
 		prng_errorflag = PRNG_GEN_ENTROPY_FAILED;
 		return -ENOMEM;
arch/s390/kernel/kprobes.c +1 -1
index 2021dc0..8e2c032 100644
@@ -43,7 +43,7 @@ DEFINE_INSN_CACHE_OPS(dmainsn);
 
 static void *alloc_dmainsn_page(void)
 {
-	return (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+	return get_free_page(GFP_KERNEL | GFP_DMA);
 }
 
 static void free_dmainsn_page(void *page)
arch/s390/kernel/topology.c +1 -1
index 40b8102..b7994b5 100644
@@ -481,7 +481,7 @@ static int __init s390_topology_init(void)
 
 	if (!MACHINE_HAS_TOPOLOGY)
 		return 0;
-	tl_info = (struct sysinfo_15_1_x *)__get_free_page(GFP_KERNEL);
+	tl_info = get_free_page(GFP_KERNEL);
 	info = tl_info;
 	store_topology(info);
 	pr_info("The CPU configuration topology of the machine is:");
arch/s390/mm/cmm.c +2 -3
index e5879ba..4236961 100644
@@ -67,7 +67,7 @@ static long cmm_alloc_pages(long nr, long *counter,
 	void *addr;
 
 	while (nr) {
-		addr = (void *)__get_free_page(GFP_NOIO);
+		addr = get_free_page(GFP_NOIO);
 		if (!addr)
 			break;
 		spin_lock(&cmm_lock);
@@ -75,8 +75,7 @@ static long cmm_alloc_pages(long nr, long *counter,
 		if (!pa || pa->index >= CMM_NR_PAGES) {
 			/* Need a new page for the page list. */
 			spin_unlock(&cmm_lock);
-			npa = (struct cmm_page_array *)
-				__get_free_page(GFP_NOIO);
+			npa = get_free_page(GFP_NOIO);
 			if (!npa) {
 				free_page(addr);
 				break;
arch/s390/mm/maccess.c +2 -2
index e20811c..93241b9 100644
@@ -137,7 +137,7 @@ int copy_to_user_real(void __user *dest, void *src, unsigned long count)
 	int offs = 0, size, rc;
 	char *buf;
 
-	buf = (char *) __get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 	rc = -EFAULT;
@@ -189,7 +189,7 @@ void *xlate_dev_mem_ptr(phys_addr_t addr)
 	preempt_disable();
 	if (is_swapped(addr)) {
 		size = PAGE_SIZE - (addr & ~PAGE_MASK);
-		bounce = (void *) __get_free_page(GFP_ATOMIC);
+		bounce = get_free_page(GFP_ATOMIC);
 		if (bounce)
 			memcpy_absolute(bounce, (void *) addr, size);
 	}
arch/s390/mm/pgtable.c +1 -2
index df429c6..5078169 100644
@@ -1113,8 +1113,7 @@ void tlb_remove_table(struct mmu_gather *tlb, void *table)
 
 	tlb->mm->context.flush_mm = 1;
 	if (*batch == NULL) {
-		*batch = (struct mmu_table_batch *)
-			__get_free_page(GFP_NOWAIT | __GFP_NOWARN);
+		*batch = get_free_page(GFP_NOWAIT | __GFP_NOWARN);
 		if (*batch == NULL) {
 			__tlb_flush_mm_lazy(tlb->mm);
 			tlb_remove_table_one(table);
arch/tile/mm/elf.c +1 -1
index cbc81ab..a8a58cd 100644
@@ -48,7 +48,7 @@ static int notify_exec(struct mm_struct *mm)
 	if (!sim_is_simulator())
 		return 1;
 
-	buf = (char *) __get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (buf == NULL)
 		return 0;
 
arch/um/kernel/mem.c +3 -3
index 8936388..5bbd2eb 100644
@@ -184,7 +184,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
 
 pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-	pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
+	pgd_t *pgd = get_free_page(GFP_KERNEL);
 
 	if (pgd) {
 		memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
@@ -204,7 +204,7 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
 	pte_t *pte;
 
-	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
+	pte = get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
 	return pte;
 }
 
@@ -225,7 +225,7 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
 #ifdef CONFIG_3_LEVEL_PGTABLES
 pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
+	pmd_t *pmd = get_free_page(GFP_KERNEL);
 
 	if (pmd)
 		memset(pmd, 0, PAGE_SIZE);
arch/unicore32/include/asm/pgalloc.h +1 -1
index 3287878..3b03876 100644
@@ -38,7 +38,7 @@ pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
 	pte_t *pte;
 
-	pte = (pte_t *)__get_free_page(PGALLOC_GFP);
+	pte = get_free_page(PGALLOC_GFP);
 	if (pte)
 		clean_dcache_area(pte, PTRS_PER_PTE * sizeof(pte_t));
 
arch/x86/kvm/mmu.c +1 -1
index fb86efb..c3f7453 100644
@@ -692,7 +692,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
 	if (cache->nobjs >= min)
 		return 0;
 	while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
-		page = (void *)__get_free_page(GFP_KERNEL);
+		page = get_free_page(GFP_KERNEL);
 		if (!page)
 			return -ENOMEM;
 		cache->objects[cache->nobjs++] = page;
arch/x86/kvm/vmx.c +9 -12
index 7206fee..fe36bf2 100644
@@ -6088,44 +6088,41 @@ static __init int hardware_setup(void)
 	for (i = 0; i < ARRAY_SIZE(vmx_msr_index); ++i)
 		kvm_define_shared_msr(i, vmx_msr_index[i]);
 
-	vmx_io_bitmap_a = (unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_io_bitmap_a = get_free_page(GFP_KERNEL);
 	if (!vmx_io_bitmap_a)
 		return r;
 
-	vmx_io_bitmap_b = (unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_io_bitmap_b = get_free_page(GFP_KERNEL);
 	if (!vmx_io_bitmap_b)
 		goto out;
 
-	vmx_msr_bitmap_legacy = (unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_msr_bitmap_legacy = get_free_page(GFP_KERNEL);
 	if (!vmx_msr_bitmap_legacy)
 		goto out1;
 
-	vmx_msr_bitmap_legacy_x2apic =
-				(unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_msr_bitmap_legacy_x2apic = get_free_page(GFP_KERNEL);
 	if (!vmx_msr_bitmap_legacy_x2apic)
 		goto out2;
 
-	vmx_msr_bitmap_longmode = (unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_msr_bitmap_longmode = get_free_page(GFP_KERNEL);
 	if (!vmx_msr_bitmap_longmode)
 		goto out3;
 
-	vmx_msr_bitmap_longmode_x2apic =
-				(unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_msr_bitmap_longmode_x2apic = get_free_page(GFP_KERNEL);
 	if (!vmx_msr_bitmap_longmode_x2apic)
 		goto out4;
 
 	if (nested) {
-		vmx_msr_bitmap_nested =
-			(unsigned long *)__get_free_page(GFP_KERNEL);
+		vmx_msr_bitmap_nested = get_free_page(GFP_KERNEL);
 		if (!vmx_msr_bitmap_nested)
 			goto out5;
 	}
 
-	vmx_vmread_bitmap = (unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_vmread_bitmap = get_free_page(GFP_KERNEL);
 	if (!vmx_vmread_bitmap)
 		goto out6;
 
-	vmx_vmwrite_bitmap = (unsigned long *)__get_free_page(GFP_KERNEL);
+	vmx_vmwrite_bitmap = get_free_page(GFP_KERNEL);
 	if (!vmx_vmwrite_bitmap)
 		goto out7;
 
arch/x86/mm/pgtable.c +4 -4
index 8e51a6c..d9781f0 100644
@@ -18,7 +18,7 @@ gfp_t __userpte_alloc_gfp = PGALLOC_GFP | PGALLOC_USER_GFP;
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	return (pte_t *)__get_free_page(PGALLOC_GFP);
+	return get_free_page(PGALLOC_GFP);
 }
 
 pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
@@ -209,7 +209,7 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
 	bool failed = false;
 
 	for(i = 0; i < PREALLOCATED_PMDS; i++) {
-		pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
+		pmd_t *pmd = get_free_page(PGALLOC_GFP);
 		if (!pmd)
 			failed = true;
 		if (pmd && !pgtable_pmd_page_ctor(virt_to_page(pmd))) {
@@ -323,7 +323,7 @@ static inline pgd_t *_pgd_alloc(void)
 	 * We allocate one page for pgd.
 	 */
 	if (!SHARED_KERNEL_PMD)
-		return (pgd_t *)__get_free_page(PGALLOC_GFP);
+		return get_free_page(PGALLOC_GFP);
 
 	/*
 	 * Now PAE kernel is not running as a Xen domain. We can allocate
@@ -342,7 +342,7 @@ static inline void _pgd_free(pgd_t *pgd)
 #else
 static inline pgd_t *_pgd_alloc(void)
 {
-	return (pgd_t *)__get_free_page(PGALLOC_GFP);
+	return get_free_page(PGALLOC_GFP);
 }
 
 static inline void _pgd_free(pgd_t *pgd)
arch/x86/pci/pcbios.c +1 -1
index 674ecff..f5a9458 100644
@@ -385,7 +385,7 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
 
 	if (!pci_bios_present)
 		return NULL;
-	page = (void *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return NULL;
 	opt.table = page;
arch/x86/um/ldt.c +1 -2
index 5264f55..60b4314 100644
@@ -157,8 +157,7 @@ static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
 			if (i == 0)
 				memcpy(&entry0, ldt->u.entries,
 				       sizeof(entry0));
-			ldt->u.pages[i] = (struct ldt_entry *)
-				__get_free_page(GFP_KERNEL|__GFP_ZERO);
+			ldt->u.pages[i] = get_free_page(GFP_KERNEL|__GFP_ZERO);
 			if (!ldt->u.pages[i]) {
 				err = -ENOMEM;
 				/* Undo the change in host */
arch/x86/xen/mmu.c +1 -1
index bb7b2e5..d06a96d 100644
@@ -1523,7 +1523,7 @@ static int xen_pgd_alloc(struct mm_struct *mm)
 
 		ret = -ENOMEM;
 
-		user_pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+		user_pgd = get_free_page(GFP_KERNEL | __GFP_ZERO);
 		page->private = (unsigned long)user_pgd;
 
 		if (user_pgd != NULL) {
arch/x86/xen/p2m.c +1 -1
index b72eab3..b2505a6 100644
@@ -182,7 +182,7 @@ static void * __ref alloc_p2m_page(void)
 	if (unlikely(!slab_is_available()))
 		return alloc_bootmem_align(PAGE_SIZE, PAGE_SIZE);
 
-	return (void *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
+	return get_free_page(GFP_KERNEL | __GFP_REPEAT);
 }
 
 static void __ref free_p2m_page(void *p)
arch/xtensa/include/asm/pgalloc.h +1 -1
index 2a7631f..65657a6 100644
@@ -44,7 +44,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 	pte_t *ptep;
 	int i;
 
-	ptep = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	ptep = get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (!ptep)
 		return NULL;
 	for (i = 0; i < 1024; i++)
block/partitions/check.c +1 -1
index dc43d02b..6e69263 100644
@@ -147,7 +147,7 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
 	state = allocate_partitions(hd);
 	if (!state)
 		return NULL;
-	state->pp_buf = (char *)__get_free_page(GFP_KERNEL);
+	state->pp_buf = get_free_page(GFP_KERNEL);
 	if (!state->pp_buf) {
 		free_partitions(state);
 		return NULL;
crypto/blkcipher.c +1 -1
index d46ebfa..97274e7 100644
@@ -240,7 +240,7 @@ static int blkcipher_walk_next(struct blkcipher_desc *desc,
 	    !scatterwalk_aligned(&walk->out, walk->alignmask)) {
 		walk->flags |= BLKCIPHER_WALK_COPY;
 		if (!walk->page) {
-			walk->page = (void *)__get_free_page(GFP_ATOMIC);
+			walk->page = get_free_page(GFP_ATOMIC);
 			if (!walk->page)
 				n = 0;
 		}
crypto/tcrypt.c +2 -2
index 5cc0a85..df693aa 100644
@@ -255,7 +255,7 @@ static int testmgr_alloc_buf(char *buf[XBUFSIZE])
 	int i;
 
 	for (i = 0; i < XBUFSIZE; i++) {
-		buf[i] = (void *)__get_free_page(GFP_KERNEL);
+		buf[i] = get_free_page(GFP_KERNEL);
 		if (!buf[i])
 			goto err_free_buf;
 	}
@@ -2204,7 +2204,7 @@ static int __init tcrypt_mod_init(void)
 	int i;
 
 	for (i = 0; i < TVMEMSIZE; i++) {
-		tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
+		tvmem[i] = get_free_page(GFP_KERNEL);
 		if (!tvmem[i])
 			goto err_free_tv;
 	}
crypto/testmgr.c +1 -1
index dc8d8f7..47dd4b8 100644
@@ -166,7 +166,7 @@ static int testmgr_alloc_buf(char *buf[XBUFSIZE])
 	int i;
 
 	for (i = 0; i < XBUFSIZE; i++) {
-		buf[i] = (void *)__get_free_page(GFP_KERNEL);
+		buf[i] = get_free_page(GFP_KERNEL);
 		if (!buf[i])
 			goto err_free_buf;
 	}
drivers/acpi/nvs.c +1 -1
index 36bf798..c07363c 100644
@@ -155,7 +155,7 @@ int suspend_nvs_alloc(void)
 	struct nvs_page *entry;
 
 	list_for_each_entry(entry, &nvs_list, node) {
-		entry->data = (void *)__get_free_page(GFP_KERNEL);
+		entry->data = get_free_page(GFP_KERNEL);
 		if (!entry->data) {
 			suspend_nvs_free();
 			return -ENOMEM;
drivers/block/cciss.c +1 -1
index a055899..9e0889f 100644
@@ -514,7 +514,7 @@ cciss_proc_write(struct file *file, const char __user *buf,
 	if (!buf || length > PAGE_SIZE - 1)
 		return -EINVAL;
 
-	buffer = (char *)__get_free_page(GFP_KERNEL);
+	buffer = get_free_page(GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
drivers/block/drbd/drbd_main.c +2 -2
index c5f9c21..06ca3ef 100644
@@ -2487,10 +2487,10 @@ found:
 
 static int drbd_alloc_socket(struct drbd_socket *socket)
 {
-	socket->rbuf = (void *) __get_free_page(GFP_KERNEL);
+	socket->rbuf = get_free_page(GFP_KERNEL);
 	if (!socket->rbuf)
 		return -ENOMEM;
-	socket->sbuf = (void *) __get_free_page(GFP_KERNEL);
+	socket->sbuf = get_free_page(GFP_KERNEL);
 	if (!socket->sbuf)
 		return -ENOMEM;
 	return 0;
drivers/char/agp/amd-k7-agp.c +1 -1
index 3835c1b..505be8d 100644
@@ -37,7 +37,7 @@ static int amd_create_page_map(struct amd_page_map *page_map)
 {
 	int i;
 
-	page_map->real = (unsigned long *) __get_free_page(GFP_KERNEL);
+	page_map->real = get_free_page(GFP_KERNEL);
 	if (page_map->real == NULL)
 		return -ENOMEM;
 
drivers/char/agp/ati-agp.c +1 -1
index 95651e2..758e7c6 100644
@@ -56,7 +56,7 @@ static int ati_create_page_map(struct ati_page_map *page_map)
 {
 	int i, err = 0;
 
-	page_map->real = (unsigned long *) __get_free_page(GFP_KERNEL);
+	page_map->real = get_free_page(GFP_KERNEL);
 	if (page_map->real == NULL)
 		return -ENOMEM;
 
drivers/char/agp/sworks-agp.c +1 -1
index 96d2e55..b590985 100644
@@ -48,7 +48,7 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map)
 {
 	int i;
 
-	page_map->real = (unsigned long *) __get_free_page(GFP_KERNEL);
+	page_map->real = get_free_page(GFP_KERNEL);
 	if (page_map->real == NULL) {
 		return -ENOMEM;
 	}
drivers/char/mem.c +2 -2
index 63f7056..2a6ce6b 100644
@@ -424,7 +424,7 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
 	}
 
 	if (count > 0) {
-		kbuf = (char *)__get_free_page(GFP_KERNEL);
+		kbuf = get_free_page(GFP_KERNEL);
 		if (!kbuf)
 			return -ENOMEM;
 		while (count > 0) {
@@ -524,7 +524,7 @@ static ssize_t write_kmem(struct file *file, const char __user *buf,
 	}
 
 	if (count > 0) {
-		kbuf = (char *)__get_free_page(GFP_KERNEL);
+		kbuf = get_free_page(GFP_KERNEL);
 		if (!kbuf)
 			return wrote ? wrote : -ENOMEM;
 		while (count > 0) {
drivers/char/tpm/xen-tpmfront.c +1 -1
index 2ccd0c9..abd4162 100644
@@ -195,7 +195,7 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
 	int rv;
 	grant_ref_t gref;
 
-	priv->shr = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
+	priv->shr = get_free_page(GFP_KERNEL|__GFP_ZERO);
 	if (!priv->shr) {
 		xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
 		return -ENOMEM;
drivers/char/xilinx_hwicap/xilinx_hwicap.c +1 -1
index 7b09193..7175120a 100644
@@ -456,7 +456,7 @@ hwicap_write(struct file *file, const char __user *buf,
 		goto error;
 	}
 
-	kbuf = (u32 *) __get_free_page(GFP_KERNEL);
+	kbuf = get_free_page(GFP_KERNEL);
 	if (!kbuf) {
 		status = -ENOMEM;
 		goto error;
drivers/firewire/ohci.c +1 -1
index f7303dd..bf433b7 100644
@@ -2999,7 +2999,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card,
 
 	memset(ctx, 0, sizeof(*ctx));
 	ctx->header_length = 0;
-	ctx->header = (void *) __get_free_page(GFP_KERNEL);
+	ctx->header = get_free_page(GFP_KERNEL);
 	if (ctx->header == NULL) {
 		ret = -ENOMEM;
 		goto out;
drivers/gpu/drm/via/via_dmablit.c +1 -2
index 869282d..5fa7c6d 100644
@@ -277,8 +277,7 @@ via_alloc_desc_pages(drm_via_sg_info_t *vsg)
 
 	vsg->state = dr_via_desc_pages_alloc;
 	for (i = 0; i < vsg->num_desc_pages; ++i) {
-		if (NULL == (vsg->desc_pages[i] =
-			     (drm_via_descriptor_t *) __get_free_page(GFP_KERNEL)))
+		if (NULL == (vsg->desc_pages[i] = get_free_page(GFP_KERNEL)))
 			return -ENOMEM;
 	}
 	DRM_DEBUG("Allocated %d pages for %d descriptors.\n", vsg->num_desc_pages,
drivers/ide/ide-proc.c +1 -1
index 0002937..cbb2ba2 100644
@@ -349,7 +349,7 @@ static ssize_t ide_settings_proc_write(struct file *file, const char __user *buf
 	if (count >= PAGE_SIZE)
 		return -EINVAL;
 
-	s = buf = (char *)__get_free_page(GFP_USER);
+	s = buf = get_free_page(GFP_USER);
 	if (!buf)
 		return -ENOMEM;
 
drivers/infiniband/core/umem.c +2 -2
index a81e139..61b9417 100644
@@ -147,7 +147,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 	/* We assume the memory is from hugetlb until proved otherwise */
 	umem->hugetlb   = 1;
 
-	page_list = (struct page **) __get_free_page(GFP_KERNEL);
+	page_list = get_free_page(GFP_KERNEL);
 	if (!page_list) {
 		kfree(umem);
 		return ERR_PTR(-ENOMEM);
@@ -157,7 +157,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 	 * if we can't alloc the vma_list, it's not so bad;
 	 * just assume the memory is not hugetlb memory
 	 */
-	vma_list = (struct vm_area_struct **) __get_free_page(GFP_KERNEL);
+	vma_list = get_free_page(GFP_KERNEL);
 	if (!vma_list)
 		umem->hugetlb = 0;
 
drivers/infiniband/core/umem_odp.c +1 -1
index 8b14a3f..c0f950ad 100644
@@ -535,7 +535,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 user_virt, u64 bcnt,
 	    user_virt + bcnt > ib_umem_end(umem))
 		return -EFAULT;
 
-	local_page_list = (struct page **)__get_free_page(GFP_KERNEL);
+	local_page_list = get_free_page(GFP_KERNEL);
 	if (!local_page_list)
 		return -ENOMEM;
 
drivers/infiniband/hw/cxgb3/iwch_provider.c +1 -1
index a80b709..db0b414 100644
@@ -660,7 +660,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (err)
 		goto err;
 
-	pages = (__be64 *) __get_free_page(GFP_KERNEL);
+	pages = get_free_page(GFP_KERNEL);
 	if (!pages) {
 		err = -ENOMEM;
 		goto err_pbl;
drivers/infiniband/hw/cxgb4/device.c +1 -2
index 870ac06..f519bc1 100644
@@ -848,8 +848,7 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 		printk(KERN_ERR MOD "error %d initializing ocqp pool\n", err);
 		goto err4;
 	}
-	rdev->status_page = (struct t4_dev_status_page *)
-			    __get_free_page(GFP_KERNEL);
+	rdev->status_page = get_free_page(GFP_KERNEL);
 	if (!rdev->status_page) {
 		pr_err(MOD "error allocating status page\n");
 		goto err4;
drivers/infiniband/hw/cxgb4/mem.c +1 -1
index 9720caa..eb6d82d 100644
@@ -743,7 +743,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (err)
 		goto err;
 
-	pages = (__be64 *) __get_free_page(GFP_KERNEL);
+	pages = get_free_page(GFP_KERNEL);
 	if (!pages) {
 		err = -ENOMEM;
 		goto err_pbl;
drivers/infiniband/hw/mlx4/mr.c +1 -1
index 227c99bb..c942b00 100644
@@ -96,7 +96,7 @@ int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
 	int err = 0;
 	struct scatterlist *sg;
 
-	pages = (u64 *) __get_free_page(GFP_KERNEL);
+	pages = get_free_page(GFP_KERNEL);
 	if (!pages)
 		return -ENOMEM;
 
drivers/infiniband/hw/mlx5/odp.c +1 -1
index 899add65..a378917 100644
@@ -538,7 +538,7 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5_ib_qp *qp,
 	u16 wqe_index = pfault->mpfault.wqe.wqe_index;
 	int requestor = pfault->mpfault.flags & MLX5_PFAULT_REQUESTOR;
 
-	buffer = (char *)__get_free_page(GFP_KERNEL);
+	buffer = get_free_page(GFP_KERNEL);
 	if (!buffer) {
 		mlx5_ib_err(dev, "Error allocating memory for IO page fault handling.\n");
 		resume_with_error = 1;
drivers/infiniband/hw/mthca/mthca_provider.c +1 -1
index e95980e..4ea565c 100644
@@ -1026,7 +1026,7 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 		goto err_umem;
 	}
 
-	pages = (u64 *) __get_free_page(GFP_KERNEL);
+	pages = get_free_page(GFP_KERNEL);
 	if (!pages) {
 		err = -ENOMEM;
 		goto err_mtt;
drivers/infiniband/hw/usnic/usnic_uiom.c +1 -1
index daaaf3d..ddadc5c 100644
@@ -122,7 +122,7 @@ static int usnic_uiom_get_pages(unsigned long addr, size_t size, int writable,
 
 	INIT_LIST_HEAD(chunk_list);
 
-	page_list = (struct page **) __get_free_page(GFP_KERNEL);
+	page_list = get_free_page(GFP_KERNEL);
 	if (!page_list)
 		return -ENOMEM;
 
drivers/input/misc/xen-kbdfront.c +1 -1
index 93f3a5c..91be47a 100644
@@ -123,7 +123,7 @@ static int xenkbd_probe(struct xenbus_device *dev,
 	info->gref = -1;
 	snprintf(info->phys, sizeof(info->phys), "xenbus/%s", dev->nodename);
 
-	info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	info->page = get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (!info->page)
 		goto error_nomem;
 
drivers/macintosh/rack-meter.c +1 -1
index ff85b7b..971dc30 100644
@@ -441,7 +441,7 @@ static int rackmeter_probe(struct macio_dev* mdev,
 	pr_debug("  dma @0x%08x\n", (unsigned int)rdma.start);
 	pr_debug("  irq %d\n", rm->irq);
 
-	rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL);
+	rm->ubuf = get_free_page(GFP_KERNEL);
 	if (rm->ubuf == NULL) {
 		printk(KERN_ERR
 		       "rackmeter: failed to allocate samples page !\n");
drivers/media/pci/pt1/pt1.c +1 -1
index ce4f862..b56fe66 100644
@@ -651,7 +651,7 @@ pt1_alloc_adapter(struct pt1 *pt1)
 	adap->voltage = SEC_VOLTAGE_OFF;
 	adap->sleep = 1;
 
-	buf = (u8 *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf) {
 		ret = -ENOMEM;
 		goto err_kfree;
drivers/media/pci/ttpci/av7110_ca.c +1 -1
index ed9c8380..c99e079 100644
@@ -152,7 +152,7 @@ static ssize_t ci_ll_write(struct dvb_ringbuffer *cibuf, struct file *file,
 {
 	int free;
 	int non_blocking = file->f_flags & O_NONBLOCK;
-	u8 *page = (u8 *)__get_free_page(GFP_USER);
+	u8 *page = get_free_page(GFP_USER);
 	int res;
 
 	if (!page)
drivers/misc/cxl/pci.c +1 -1
index 2750bff..5cce770 100644
@@ -790,7 +790,7 @@ ssize_t cxl_afu_read_err_buffer(struct cxl_afu *afu, char *buf,
 	}
 
 	/* use bounce buffer for copy */
-	tbuf = (void *)__get_free_page(GFP_TEMPORARY);
+	tbuf = get_free_page(GFP_TEMPORARY);
 	if (!tbuf)
 		return -ENOMEM;
 
drivers/misc/ibmasm/ibmasmfs.c +1 -1
index 6694cca..b5385b0 100644
@@ -519,7 +519,7 @@ static ssize_t remote_settings_file_read(struct file *file, char __user *buf, si
 	if (*offset != 0)
 		return 0;
 
-	page = (unsigned char *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return -ENOMEM;
 
drivers/misc/lkdtm.c +3 -3
index 0446145..98a1108 100644
@@ -627,7 +627,7 @@ static ssize_t do_register_entry(enum cname which, struct file *f,
 	if (count >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = (char *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 	if (copy_from_user(buf, user_buf, count)) {
@@ -660,7 +660,7 @@ static ssize_t lkdtm_debugfs_read(struct file *f, char __user *user_buf,
 	char *buf;
 	int i, n, out;
 
-	buf = (char *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (buf == NULL)
 		return -ENOMEM;
 
@@ -742,7 +742,7 @@ static ssize_t direct_entry(struct file *f, const char __user *user_buf,
 	if (count < 1)
 		return -EINVAL;
 
-	buf = (char *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 	if (copy_from_user(buf, user_buf, count)) {
drivers/mmc/host/tmio_mmc_dma.c +1 -1
index be9c8d7..08a1ad0 100644
@@ -315,7 +315,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
 		if (ret < 0)
 			goto ecfgrx;
 
-		host->bounce_buf = (u8 *)__get_free_page(GFP_KERNEL | GFP_DMA);
+		host->bounce_buf = get_free_page(GFP_KERNEL | GFP_DMA);
 		if (!host->bounce_buf)
 			goto ebouncebuf;
 
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -1
index f8d7a2f..37d9b36 100644
@@ -692,7 +692,7 @@ static void *bnx2x_frag_alloc(const struct bnx2x_fastpath *fp, gfp_t gfp_mask)
 	if (fp->rx_frag_size) {
 		/* GFP_KERNEL allocations are used only during initialization */
 		if (unlikely(gfpflags_allow_blocking(gfp_mask)))
-			return (void *)__get_free_page(gfp_mask);
+			return get_free_page(gfp_mask);
 
 		return netdev_alloc_frag(fp->rx_frag_size);
 	}
drivers/net/ethernet/sfc/mcdi.c +1 -1
index 36c786b..972b9a7 100644
@@ -76,7 +76,7 @@ int efx_mcdi_init(struct efx_nic *efx)
 	mcdi->efx = efx;
 #ifdef CONFIG_SFC_MCDI_LOGGING
 	/* consuming code assumes buffer is page-sized */
-	mcdi->logging_buffer = (char *)__get_free_page(GFP_KERNEL);
+	mcdi->logging_buffer = get_free_page(GFP_KERNEL);
 	if (!mcdi->logging_buffer)
 		goto fail1;
 	mcdi->logging_enabled = mcdi_logging_default;
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +6 -6
index c1b3142..9ece945 100644
@@ -1412,7 +1412,7 @@ static struct iw_statistics *gelic_wl_get_wireless_stats(
 
 	pr_debug("%s: <-\n", __func__);
 
-	buf = (void *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		return NULL;
 
@@ -1472,7 +1472,7 @@ static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan,
 
 	/* ESSID scan ? */
 	if (essid_len && essid) {
-		buf = (void *)__get_free_page(GFP_KERNEL);
+		buf = get_free_page(GFP_KERNEL);
 		if (!buf) {
 			ret = -ENOMEM;
 			goto out;
@@ -1523,7 +1523,7 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
 	pr_debug("%s:start\n", __func__);
 	mutex_lock(&wl->scan_lock);
 
-	buf = (void *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf) {
 		pr_info("%s: scan buffer alloc failed\n", __func__);
 		goto out;
@@ -1764,7 +1764,7 @@ static int gelic_wl_do_wep_setup(struct gelic_wl_info *wl)
 
 	pr_debug("%s: <-\n", __func__);
 	/* we can assume no one should uses the buffer */
-	wep = (struct gelic_eurus_wep_cfg *)__get_free_page(GFP_KERNEL);
+	wep = get_free_page(GFP_KERNEL);
 	if (!wep)
 		return -ENOMEM;
 
@@ -1854,7 +1854,7 @@ static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl)
 
 	pr_debug("%s: <-\n", __func__);
 	/* we can assume no one should uses the buffer */
-	wpa = (struct gelic_eurus_wpa_cfg *)__get_free_page(GFP_KERNEL);
+	wpa = get_free_page(GFP_KERNEL);
 	if (!wpa)
 		return -ENOMEM;
 
@@ -1935,7 +1935,7 @@ static int gelic_wl_associate_bss(struct gelic_wl_info *wl,
 	pr_debug("%s: <-\n", __func__);
 
 	/* do common config */
-	common = (struct gelic_eurus_common_cfg *)__get_free_page(GFP_KERNEL);
+	common = get_free_page(GFP_KERNEL);
 	if (!common)
 		return -ENOMEM;
 
drivers/net/usb/kaweth.c +1 -1
index a8493be..ae21f17 100644
@@ -1047,7 +1047,7 @@ static int kaweth_probe(
 	} else {
 		/* Download the firmware */
 		dev_info(dev, "Downloading firmware...\n");
-		kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
+		kaweth->firmware_buf = get_free_page(GFP_KERNEL);
 		if ((result = kaweth_download_firmware(kaweth,
 						      "kaweth/new_code.bin",
 						      100,
drivers/pci/xen-pcifront.c +1 -2
index 90b77b9..5e41853 100644
@@ -725,8 +725,7 @@ static struct pcifront_device *alloc_pdev(struct xenbus_device *xdev)
 	if (pdev == NULL)
 		goto out;
 
-	pdev->sh_info =
-	    (struct xen_pci_sharedinfo *)__get_free_page(GFP_KERNEL);
+	pdev->sh_info = get_free_page(GFP_KERNEL);
 	if (pdev->sh_info == NULL) {
 		kfree(pdev);
 		pdev = NULL;
drivers/platform/x86/dell-laptop.c +1 -1
index 996839f..43a750a 100644
@@ -2145,7 +2145,7 @@ static int __init dell_init(void)
 	 * Allocate buffer below 4GB for SMI data--only 32-bit physical addr
 	 * is passed to SMI handler.
 	 */
-	buffer = (void *)__get_free_page(GFP_KERNEL | GFP_DMA32);
+	buffer = get_free_page(GFP_KERNEL | GFP_DMA32);
 	if (!buffer) {
 		ret = -ENOMEM;
 		goto fail_buffer;
drivers/s390/block/dasd_eckd.c +1 -1
index c2d120a..10a2d5c 100644
@@ -5118,7 +5118,7 @@ dasd_eckd_init(void)
 		kfree(dasd_reserve_req);
 		return -ENOMEM;
 	}
-	rawpadpage = (void *)__get_free_page(GFP_KERNEL);
+	rawpadpage = get_free_page(GFP_KERNEL);
 	if (!rawpadpage) {
 		kfree(path_verification_worker);
 		kfree(dasd_reserve_req);
drivers/s390/block/xpram.c +2 -2
index 87d13a6..a4e3f391 100644
@@ -145,7 +145,7 @@ static int xpram_present(void)
 	void *mem_page;
 	int rc;
 
-	mem_page = (void *)__get_free_page(GFP_KERNEL);
+	mem_page = get_free_page(GFP_KERNEL);
 	if (!mem_page)
 		return -ENOMEM;
 	rc = xpram_page_in(mem_page, 0);
@@ -161,7 +161,7 @@ static unsigned long xpram_highest_page_index(void)
 	unsigned int page_index, add_bit;
 	void *mem_page;
 
-	mem_page = (void *) __get_free_page(GFP_KERNEL);
+	mem_page = get_free_page(GFP_KERNEL);
 	if (!mem_page)
 		return 0;
 
drivers/s390/char/sclp_cmd.c +1 -1
index 09b6c07..6bd6fd0 100644
@@ -514,7 +514,7 @@ static int __init sclp_detect_standby_memory(void)
 	if ((sclp.facilities & 0xe00000000000ULL) != 0xe00000000000ULL)
 		return 0;
 	rc = -ENOMEM;
-	sccb = (void *) __get_free_page(GFP_KERNEL | GFP_DMA);
+	sccb = get_free_page(GFP_KERNEL | GFP_DMA);
 	if (!sccb)
 		goto out;
 	assigned = 0;
drivers/s390/char/vmur.c +2 -2
index 3974f34..02634f4c 100644
@@ -524,7 +524,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
 		return rc;
 
 	len = min((size_t) PAGE_SIZE, count);
-	buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
+	buf = get_free_page(GFP_KERNEL | GFP_DMA);
 	if (!buf)
 		return -ENOMEM;
 
@@ -616,7 +616,7 @@ static int verify_uri_device(struct urdev *urd)
 	}
 
 	/* open file on virtual reader	*/
-	buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
+	buf = get_free_page(GFP_KERNEL | GFP_DMA);
 	if (!buf) {
 		rc = -ENOMEM;
 		goto fail_free_fcb;
drivers/s390/char/zcore.c +1 -1
index 4a6f730..fe18b41 100644
@@ -616,7 +616,7 @@ static int __init zcore_reipl_init(void)
 		return rc;
 	if (ipib_info.ipib == 0)
 		return 0;
-	ipl_block = (void *) __get_free_page(GFP_KERNEL);
+	ipl_block = get_free_page(GFP_KERNEL);
 	if (!ipl_block)
 		return -ENOMEM;
 	if (ipib_info.ipib < sclp.hsa_size)
drivers/s390/cio/qdio_setup.c +2 -2
index 7322dd3..d842c56 100644
@@ -144,7 +144,7 @@ static int __qdio_allocate_qs(struct qdio_q **irq_ptr_qs, int nr_queues)
 		if (!q)
 			return -ENOMEM;
 
-		q->slib = (struct slib *) __get_free_page(GFP_KERNEL);
+		q->slib = get_free_page(GFP_KERNEL);
 		if (!q->slib) {
 			kmem_cache_free(qdio_q_cache, q);
 			return -ENOMEM;
@@ -305,7 +305,7 @@ int qdio_setup_get_ssqd(struct qdio_irq *irq_ptr,
 
 	DBF_EVENT("getssqd:%4x", schid->sch_no);
 	if (!irq_ptr) {
-		ssqd = (struct chsc_ssqd_area *)__get_free_page(GFP_KERNEL);
+		ssqd = get_free_page(GFP_KERNEL);
 		if (!ssqd)
 			return -ENOMEM;
 	} else {
drivers/s390/cio/scm.c +1 -1
index db1812e..90dbe36 100644
@@ -226,7 +226,7 @@ int scm_update_information(void)
 	size_t num;
 	int ret;
 
-	scm_info = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+	scm_info = get_free_page(GFP_KERNEL | GFP_DMA);
 	if (!scm_info)
 		return -ENOMEM;
 
drivers/s390/net/qeth_core_main.c +1 -1
index 18f4db4..f6de41b 100644
@@ -265,7 +265,7 @@ static int qeth_alloc_buffer_pool(struct qeth_card *card)
 			return -ENOMEM;
 		}
 		for (j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j) {
-			ptr = (void *) __get_free_page(GFP_KERNEL);
+			ptr = get_free_page(GFP_KERNEL);
 			if (!ptr) {
 				while (j > 0)
 					free_page(pool_entry->elements[--j]);
drivers/scsi/cxlflash/main.c +1 -1
index ff85994..cd29652 100644
@@ -776,7 +776,7 @@ static int alloc_mem(struct cxlflash_cfg *cfg)
 
 	for (i = 0; i < CXLFLASH_NUM_CMDS; buf += CMD_BUFSIZE, i++) {
 		if (!((u64)buf & (PAGE_SIZE - 1))) {
-			buf = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+			buf = get_free_page(GFP_KERNEL | __GFP_ZERO);
 			if (unlikely(!buf)) {
 				dev_err(dev,
 					"%s: Allocate command buffers fail!\n",
drivers/scsi/ipr.c +1 -1
index 1a05ba8..b80245b 100644
@@ -2904,7 +2904,7 @@ static int ipr_sdt_copy(struct ipr_ioa_cfg *ioa_cfg,
 	       (ioa_dump->hdr.len + bytes_copied) < max_dump_size) {
 		if (ioa_dump->page_offset >= PAGE_SIZE ||
 		    ioa_dump->page_offset == 0) {
-			page = (__be32 *)__get_free_page(GFP_ATOMIC);
+			page = get_free_page(GFP_ATOMIC);
 
 			if (!page) {
 				ipr_trace;
drivers/scsi/scsi_devinfo.c +1 -1
index 2f93f80..1893e6c 100644
@@ -707,7 +707,7 @@ static ssize_t proc_scsi_devinfo_write(struct file *file,
 
 	if (!buf || length>PAGE_SIZE)
 		return -EINVAL;
-	if (!(buffer = (char *) __get_free_page(GFP_KERNEL)))
+	if (!(buffer = get_free_page(GFP_KERNEL)))
 		return -ENOMEM;
 	if (copy_from_user(buffer, buf, length)) {
 		err =-EFAULT;
drivers/scsi/scsi_proc.c +2 -2
index e0e0e5d..71bee2d 100644
@@ -58,7 +58,7 @@ static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf,
 	if (!shost->hostt->write_info)
 		return -EINVAL;
 
-	page = (char *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (page) {
 		ret = -EFAULT;
 		if (copy_from_user(page, buf, count))
@@ -315,7 +315,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
 	if (!buf || length > PAGE_SIZE)
 		return -EINVAL;
 
-	buffer = (char *)__get_free_page(GFP_KERNEL);
+	buffer = get_free_page(GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
drivers/scsi/xen-scsifront.c +1 -1
index 825759b..93dc086 100644
@@ -718,7 +718,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
 	int err = -ENOMEM;
 
 	/***** Frontend to Backend ring start *****/
-	sring = (struct vscsiif_sring *)__get_free_page(GFP_KERNEL);
+	sring = get_free_page(GFP_KERNEL);
 	if (!sring) {
 		xenbus_dev_fatal(dev, err,
 			"fail to allocate shared ring (Front to Back)");
drivers/spi/spi-sh-msiof.c +2 -2
index b8286e7..eea6e9b 100644
@@ -1092,11 +1092,11 @@ static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
 	if (!master->dma_rx)
 		goto free_tx_chan;
 
-	p->tx_dma_page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+	p->tx_dma_page = get_free_page(GFP_KERNEL | GFP_DMA);
 	if (!p->tx_dma_page)
 		goto free_rx_chan;
 
-	p->rx_dma_page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+	p->rx_dma_page = get_free_page(GFP_KERNEL | GFP_DMA);
 	if (!p->rx_dma_page)
 		goto free_tx_page;
 
drivers/staging/lustre/lustre/llite/llite_lib.c +1 -1
index 92259be..f675ab3 100644
@@ -2268,7 +2268,7 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret)
 	struct ccc_object *obj = cl_inode2ccc(page->mapping->host);
 
 	/* this can be called inside spin lock so use GFP_ATOMIC. */
-	buf = (char *)__get_free_page(GFP_ATOMIC);
+	buf = get_free_page(GFP_ATOMIC);
 	if (buf != NULL) {
 		dentry = d_find_alias(page->mapping->host);
 		if (dentry != NULL)
drivers/staging/unisys/visorbus/visorchannel.c +1 -1
index 486bef0..35471c4 100644
@@ -279,7 +279,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
 	int written = 0;
 	u8 *buf;
 
-	buf = (u8 *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
drivers/target/target_core_file.c +1 -1
index ca682ec..86ad9ea 100644
@@ -460,7 +460,7 @@ fd_do_prot_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
 	void *buf;
 	int rc;
 
-	buf = (void *)__get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf) {
 		pr_err("Unable to allocate FILEIO prot buf\n");
 		return -ENOMEM;
drivers/tty/hvc/hvc_xen.c +1 -1
index 4f7716d..423d2cf 100644
@@ -445,7 +445,7 @@ static int xencons_probe(struct xenbus_device *dev,
 	dev_set_drvdata(&dev->dev, info);
 	info->xbdev = dev;
 	info->vtermno = xenbus_devid_to_vtermno(devid);
-	info->intf = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	info->intf = get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (!info->intf)
 		goto error_nomem;
 
drivers/tty/hvc/hvcs.c +1 -1
index fb3f4cd..29320d0 100644
@@ -1532,7 +1532,7 @@ static int hvcs_initialize(void)
 		goto register_fail;
 	}
 
-	hvcs_pi_buff = (unsigned long *) __get_free_page(GFP_KERNEL);
+	hvcs_pi_buff = get_free_page(GFP_KERNEL);
 	if (!hvcs_pi_buff) {
 		rc = -ENOMEM;
 		goto buff_alloc_fail;
drivers/tty/mxser.c +1 -1
index ee78fc2..56bd374 100644
@@ -865,7 +865,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
 	unsigned char *page;
 	unsigned long flags;
 
-	page = (unsigned char *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return -ENOMEM;
 
drivers/tty/rocket.c +1 -1
index 78f0330..fc2d1ef 100644
@@ -891,7 +891,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 		return -ENXIO;
 	port = &info->port;
 	
-	page = (unsigned char *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return -ENOMEM;
 
drivers/tty/serial/68328serial.c +1 -1
index 4485466..5fac3e7 100644
@@ -379,7 +379,7 @@ static int startup(struct m68k_serial *info, struct tty_struct *tty)
 		return 0;
 
 	if (!info->xmit_buf) {
-		info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
+		info->xmit_buf = get_free_page(GFP_KERNEL);
 		if (!info->xmit_buf)
 			return -ENOMEM;
 	}
drivers/tty/serial/men_z135_uart.c +1 -1
index df3c6ad..534b2ed 100644
@@ -824,7 +824,7 @@ static int men_z135_probe(struct mcb_device *mdev,
 	if (!uart)
 		return -ENOMEM;
 
-	uart->rxbuf = (unsigned char *)__get_free_page(GFP_KERNEL);
+	uart->rxbuf = get_free_page(GFP_KERNEL);
 	if (!uart->rxbuf)
 		return -ENOMEM;
 
drivers/tty/serial/pch_uart.c +1 -1
index 7e461e0..daee5b8 100644
@@ -1771,7 +1771,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	if (priv == NULL)
 		goto init_port_alloc_err;
 
-	rxbuf = (unsigned char *)__get_free_page(GFP_KERNEL);
+	rxbuf = get_free_page(GFP_KERNEL);
 	if (!rxbuf)
 		goto init_port_free_txbuf;
 
drivers/tty/vt/vc_screen.c +2 -2
index 5d25934..7227efe 100644
@@ -206,7 +206,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	ssize_t ret;
 	char *con_buf;
 
-	con_buf = (char *) __get_free_page(GFP_KERNEL);
+	con_buf = get_free_page(GFP_KERNEL);
 	if (!con_buf)
 		return -ENOMEM;
 
@@ -384,7 +384,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 	size_t ret;
 	char *con_buf;
 
-	con_buf = (char *) __get_free_page(GFP_KERNEL);
+	con_buf = get_free_page(GFP_KERNEL);
 	if (!con_buf)
 		return -ENOMEM;
 
drivers/usb/atm/cxacru.c +3 -3
index f03bc30..e078eeb 100644
@@ -942,7 +942,7 @@ static int cxacru_fw(struct usb_device *usb_dev, enum cxacru_fw_request fw,
 	int offd, offb;
 	const int stride = CMD_PACKET_SIZE - 8;
 
-	buf = (u8 *) __get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
@@ -1152,13 +1152,13 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
 
 	mutex_init(&instance->adsl_state_serialize);
 
-	instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL);
+	instance->rcv_buf = get_free_page(GFP_KERNEL);
 	if (!instance->rcv_buf) {
 		usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_buf\n");
 		ret = -ENOMEM;
 		goto fail;
 	}
-	instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL);
+	instance->snd_buf = get_free_page(GFP_KERNEL);
 	if (!instance->snd_buf) {
 		usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_buf\n");
 		ret = -ENOMEM;
drivers/usb/atm/speedtch.c +1 -1
index 681599f..e6a1ff8 100644
@@ -255,7 +255,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
 
 	usb_dbg(usbatm, "%s entered\n", __func__);
 
-	buffer = (unsigned char *)__get_free_page(GFP_KERNEL);
+	buffer = get_free_page(GFP_KERNEL);
 	if (!buffer) {
 		ret = -ENOMEM;
 		usb_dbg(usbatm, "%s: no memory for buffer!\n", __func__);
drivers/usb/core/devio.c +1 -1
index c2cef46..af957f0 100644
@@ -988,7 +988,7 @@ static int proc_control(struct usb_dev_state *ps, void __user *arg)
 			sizeof(struct usb_ctrlrequest));
 	if (ret)
 		return ret;
-	tbuf = (unsigned char *)__get_free_page(GFP_KERNEL);
+	tbuf = get_free_page(GFP_KERNEL);
 	if (!tbuf) {
 		ret = -ENOMEM;
 		goto done;
drivers/usb/misc/rio500.c +2 -2
index 3c49061..f50166565 100644
@@ -139,7 +139,7 @@ static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg)
 			retval = -EINVAL;
 			goto err_out;
 		}
-		buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
+		buffer = get_free_page(GFP_KERNEL);
 		if (buffer == NULL) {
 			retval = -ENOMEM;
 			goto err_out;
@@ -210,7 +210,7 @@ static long ioctl_rio(struct file *file, unsigned int cmd, unsigned long arg)
 			retval = -EINVAL;
 			goto err_out;
 		}
-		buffer = (unsigned char *) __get_free_page(GFP_KERNEL);
+		buffer = get_free_page(GFP_KERNEL);
 		if (buffer == NULL) {
 			retval = -ENOMEM;
 			goto err_out;
drivers/usb/serial/usb_wwan.c +1 -1
index de9ff1b..fbebc5d 100644
@@ -525,7 +525,7 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
 	init_usb_anchor(&portdata->delayed);
 
 	for (i = 0; i < N_IN_URB; i++) {
-		buffer = (u8 *)__get_free_page(GFP_KERNEL);
+		buffer = get_free_page(GFP_KERNEL);
 		if (!buffer)
 			goto bail_out_error;
 		portdata->in_buffer[i] = buffer;
drivers/uwb/hwa-rc.c +1 -1
index 2d3334f..b92ef24 100644
@@ -695,7 +695,7 @@ static int hwarc_neep_init(struct uwb_rc *rc)
 	struct usb_endpoint_descriptor *epd;
 
 	epd = &iface->cur_altsetting->endpoint[0].desc;
-	hwarc->rd_buffer = (void *) __get_free_page(GFP_KERNEL);
+	hwarc->rd_buffer = get_free_page(GFP_KERNEL);
 	if (hwarc->rd_buffer == NULL) {
 		dev_err(dev, "Unable to allocate notification's read buffer\n");
 		goto error_rd_buffer;
drivers/video/fbdev/xen-fbfront.c +1 -1
index b126f77..11ecb95 100644
@@ -407,7 +407,7 @@ static int xenfb_probe(struct xenbus_device *dev,
 		goto error_nomem;
 
 	/* set up shared page */
-	info->page = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+	info->page = get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (!info->page)
 		goto error_nomem;
 
drivers/xen/events/events_base.c +1 -1
index 0fe5889..b107c3e 100644
@@ -1688,7 +1688,7 @@ void __init xen_init_IRQ(void)
 		int rc;
 		struct physdev_pirq_eoi_gmfn eoi_gmfn;
 
-		pirq_eoi_map = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
+		pirq_eoi_map = get_free_page(GFP_KERNEL|__GFP_ZERO);
 		eoi_gmfn.gmfn = virt_to_gfn(pirq_eoi_map);
 		rc = HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn);
 		/* TODO: No PVH support for PIRQ EOI */
drivers/xen/events/events_fifo.c +2 -2
index 722c2a0..cc3857c 100644
@@ -156,7 +156,7 @@ static int evtchn_fifo_setup(struct irq_info *info)
 		/* Might already have a page if we've resumed. */
 		array_page = event_array[event_array_pages];
 		if (!array_page) {
-			array_page = (void *)__get_free_page(GFP_KERNEL);
+			array_page = get_free_page(GFP_KERNEL);
 			if (array_page == NULL) {
 				ret = -ENOMEM;
 				goto error;
@@ -391,7 +391,7 @@ static int evtchn_fifo_alloc_control_block(unsigned cpu)
 	void *control_block = NULL;
 	int ret = -ENOMEM;
 
-	control_block = (void *)__get_free_page(GFP_KERNEL);
+	control_block = get_free_page(GFP_KERNEL);
 	if (control_block == NULL)
 		goto error;
 
drivers/xen/evtchn.c +1 -1
index bcd5f54..5c044a2 100644
@@ -270,7 +270,7 @@ static ssize_t evtchn_write(struct file *file, const char __user *buf,
 			    size_t count, loff_t *ppos)
 {
 	int rc, i;
-	evtchn_port_t *kbuf = (evtchn_port_t *)__get_free_page(GFP_KERNEL);
+	evtchn_port_t *kbuf = get_free_page(GFP_KERNEL);
 	struct per_user_data *u = file->private_data;
 
 	if (kbuf == NULL)
drivers/xen/grant-table.c +2 -2
index 29d88da..00e7130 100644
@@ -577,7 +577,7 @@ static int grow_gnttab_list(unsigned int more_frames)
 	new_nr_glist_frames =
 		(new_nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;
 	for (i = nr_glist_frames; i < new_nr_glist_frames; i++) {
-		gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC);
+		gnttab_list[i] = get_free_page(GFP_ATOMIC);
 		if (!gnttab_list[i])
 			goto grow_nomem;
 	}
@@ -1109,7 +1109,7 @@ int gnttab_init(void)
 
 	nr_glist_frames = (nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;
 	for (i = 0; i < nr_glist_frames; i++) {
-		gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
+		gnttab_list[i] = get_free_page(GFP_KERNEL);
 		if (gnttab_list[i] == NULL) {
 			ret = -ENOMEM;
 			goto ini_nomem;
fs/binfmt_misc.c +1 -1
index a7ab050..5479f6f 100644
@@ -607,7 +607,7 @@ bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 	ssize_t res;
 	char *page;
 
-	page = (char *) __get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return -ENOMEM;
 
fs/fuse/dir.c +1 -1
index 37b4ae3..c3755f0 100644
@@ -1373,7 +1373,7 @@ static const char *fuse_follow_link(struct dentry *dentry, void **cookie)
 	char *link;
 	ssize_t ret;
 
-	link = (char *) __get_free_page(GFP_KERNEL);
+	link = get_free_page(GFP_KERNEL);
 	if (!link)
 		return ERR_PTR(-ENOMEM);
 
fs/fuse/file.c +1 -1
index a07709b..2e44926 100644
@@ -2458,7 +2458,7 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 
 	err = -ENOMEM;
 	pages = kcalloc(FUSE_MAX_PAGES_PER_REQ, sizeof(pages[0]), GFP_KERNEL);
-	iov_page = (struct iovec *) __get_free_page(GFP_KERNEL);
+	iov_page = get_free_page(GFP_KERNEL);
 	if (!pages || !iov_page)
 		goto out;
 
fs/isofs/dir.c +1 -1
index 2d495b5..63199f6 100644
@@ -253,7 +253,7 @@ static int isofs_readdir(struct file *file, struct dir_context *ctx)
 	struct iso_directory_record *tmpde;
 	struct inode *inode = file_inode(file);
 
-	tmpname = (char *)__get_free_page(GFP_KERNEL);
+	tmpname = get_free_page(GFP_KERNEL);
 	if (tmpname == NULL)
 		return -ENOMEM;
 
fs/jfs/jfs_dtree.c +1 -1
index 56d18de..1007b44 100644
@@ -3180,7 +3180,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
 		}
 	}
 
-	dirent_buf = (void *)__get_free_page(GFP_KERNEL);
+	dirent_buf = get_free_page(GFP_KERNEL);
 	if (!dirent_buf) {
 		DT_PUTPAGE(mp);
 		jfs_warn("jfs_readdir: __get_free_page failed!");
fs/namespace.c +1 -1
index 4bcae39..5f1245c 100644
@@ -2611,7 +2611,7 @@ int copy_mount_options(const void __user * data, void **where)
 	if (!data)
 		return 0;
 
-	if (!(page = (char *)__get_free_page(GFP_KERNEL)))
+	if (!(page = get_free_page(GFP_KERNEL)))
 		return -ENOMEM;
 
 	/* We only care that *some* data at the address the user
fs/nfs/namespace.c +1 -1
index faa1ce5..20b38fa 100644
@@ -248,7 +248,7 @@ struct vfsmount *nfs_do_submount(struct dentry *dentry, struct nfs_fh *fh,
 		.authflavor = authflavor,
 	};
 	struct vfsmount *mnt = ERR_PTR(-ENOMEM);
-	char *page = (char *) __get_free_page(GFP_USER);
+	char *page = get_free_page(GFP_USER);
 	char *devname;
 
 	dprintk("--> nfs_do_submount()\n");
fs/nfs/nfs4namespace.c +4 -4
index 82b1537..7a6565a 100644
@@ -310,11 +310,11 @@ static struct vfsmount *nfs_follow_referral(struct dentry *dentry,
 
 	dprintk("%s: referral at %pd2\n", __func__, dentry);
 
-	page = (char *) __get_free_page(GFP_USER);
+	page = get_free_page(GFP_USER);
 	if (!page)
 		goto out;
 
-	page2 = (char *) __get_free_page(GFP_USER);
+	page2 = get_free_page(GFP_USER);
 	if (!page2)
 		goto out;
 
@@ -495,10 +495,10 @@ int nfs4_replace_transport(struct nfs_server *server,
 		goto out;
 
 	error = -ENOMEM;
-	page = (char *) __get_free_page(GFP_USER);
+	page = get_free_page(GFP_USER);
 	if (!page)
 		goto out;
-	page2 = (char *) __get_free_page(GFP_USER);
+	page2 = get_free_page(GFP_USER);
 	if (!page2)
 		goto out;
 
fs/nfs/super.c +1 -1
index ba0ad91..427d0a9 100644
@@ -779,7 +779,7 @@ static void show_implementation_id(struct seq_file *m, struct nfs_server *nfss)
 
 int nfs_show_devname(struct seq_file *m, struct dentry *root)
 {
-	char *page = (char *) __get_free_page(GFP_KERNEL);
+	char *page = get_free_page(GFP_KERNEL);
 	char *devname, *dummy;
 	int err = 0;
 	if (!page)
fs/nfsd/vfs.c +1 -1
index e9df47b..8a10704 100644
@@ -1800,7 +1800,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
 	loff_t offset;
 	struct readdir_data buf = {
 		.ctx.actor = nfsd_buffered_filldir,
-		.dirent = (void *)__get_free_page(GFP_KERNEL)
+		.dirent = get_free_page(GFP_KERNEL)
 	};
 
 	if (!buf.dirent)
fs/ocfs2/dlm/dlmdomain.c +1 -1
index 841d822..4a80983 100644
@@ -92,7 +92,7 @@ static void **dlm_alloc_pagevec(int pages)
 		return NULL;
 
 	for (i = 0; i < pages; i++)
-		if (!(vec[i] = (void *)__get_free_page(GFP_KERNEL)))
+		if (!(vec[i] = get_free_page(GFP_KERNEL)))
 			goto out_free;
 
 	mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
fs/ocfs2/dlm/dlmmaster.c +1 -1
index a0edd7e..2d5c2c38 100644
@@ -2498,7 +2498,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
 
 	/* preallocate up front. if this fails, abort */
 	ret = -ENOMEM;
-	mres = (struct dlm_migratable_lockres *) __get_free_page(GFP_NOFS);
+	mres = get_free_page(GFP_NOFS);
 	if (!mres) {
 		mlog_errno(ret);
 		goto leave;
fs/ocfs2/dlm/dlmrecovery.c +1 -1
index 7368158..a2338d8 100644
@@ -856,7 +856,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data,
 	}
 
 	/* this will get freed by dlm_request_all_locks_worker */
-	buf = (char *) __get_free_page(GFP_NOFS);
+	buf = get_free_page(GFP_NOFS);
 	if (!buf) {
 		kfree(item);
 		dlm_put(dlm);
fs/overlayfs/copy_up.c +1 -1
index b3f1da5..0c66579 100644
@@ -134,7 +134,7 @@ static char *ovl_read_symlink(struct dentry *realdentry)
 		goto err;
 
 	res = -ENOMEM;
-	buf = (char *) __get_free_page(GFP_KERNEL);
+	buf = get_free_page(GFP_KERNEL);
 	if (!buf)
 		goto err;
 
fs/proc/base.c +5 -5
index a9828e5..f115e58 100644
@@ -224,7 +224,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
 		goto out_mmput;
 	}
 
-	page = (char *)__get_free_page(GFP_TEMPORARY);
+	page = get_free_page(GFP_TEMPORARY);
 	if (!page) {
 		rv = -ENOMEM;
 		goto out_mmput;
@@ -855,7 +855,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
 	if (!mm)
 		return 0;
 
-	page = (char *)__get_free_page(GFP_TEMPORARY);
+	page = get_free_page(GFP_TEMPORARY);
 	if (!page)
 		return -ENOMEM;
 
@@ -956,7 +956,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
 	if (!mm)
 		return 0;
 
-	page = (char *)__get_free_page(GFP_TEMPORARY);
+	page = get_free_page(GFP_TEMPORARY);
 	if (!page)
 		return -ENOMEM;
 
@@ -1586,7 +1586,7 @@ out:
 
 static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
 {
-	char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
+	char *tmp = get_free_page(GFP_TEMPORARY);
 	char *pathname;
 	int len;
 
@@ -2375,7 +2375,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
 		goto out;
 
 	length = -ENOMEM;
-	page = (char*)__get_free_page(GFP_TEMPORARY);
+	page = get_free_page(GFP_TEMPORARY);
 	if (!page)
 		goto out;
 
fs/select.c +1 -1
index 6acb0ae..8619de7 100644
@@ -165,7 +165,7 @@ static struct poll_table_entry *poll_get_entry(struct poll_wqueues *p)
 	if (!table || POLL_TABLE_FULL(table)) {
 		struct poll_table_page *new_table;
 
-		new_table = (struct poll_table_page *) __get_free_page(GFP_KERNEL);
+		new_table = get_free_page(GFP_KERNEL);
 		if (!new_table) {
 			p->error = -ENOMEM;
 			return NULL;
include/linux/quicklist.h +1 -1
index bd46643..fa5ecd2 100644
@@ -46,7 +46,7 @@ static inline void *quicklist_alloc(int nr, gfp_t flags, void (*ctor)(void *))
 	if (likely(p))
 		return p;
 
-	p = (void *)__get_free_page(flags | __GFP_ZERO);
+	p = get_free_page(flags | __GFP_ZERO);
 	if (ctor && p)
 		ctor(p);
 	return p;
kernel/groups.c +1 -1
index 88f7e1a8..e978016c 100644
@@ -30,7 +30,7 @@ struct group_info *groups_alloc(int gidsetsize)
 	else {
 		for (i = 0; i < nblocks; i++) {
 			kgid_t *b;
-			b = (void *)__get_free_page(GFP_USER);
+			b = get_free_page(GFP_USER);
 			if (!b)
 				goto out_undo_partial_alloc;
 			group_info->blocks[i] = b;
kernel/power/swap.c +6 -7
index 5bbe897..f64d341 100644
@@ -356,7 +356,7 @@ static int write_page(void *buf, sector_t offset, struct hib_bio_batch *hb)
 		return -ENOSPC;
 
 	if (hb) {
-		src = (void *)__get_free_page(__GFP_RECLAIM | __GFP_NOWARN |
+		src = get_free_page(__GFP_RECLAIM | __GFP_NOWARN |
 		                              __GFP_NORETRY);
 		if (src) {
 			copy_page(src, buf);
@@ -364,7 +364,7 @@ static int write_page(void *buf, sector_t offset, struct hib_bio_batch *hb)
 			ret = hib_wait_io(hb); /* Free pages */
 			if (ret)
 				return ret;
-			src = (void *)__get_free_page(__GFP_RECLAIM |
+			src = get_free_page(__GFP_RECLAIM |
 			                              __GFP_NOWARN |
 			                              __GFP_NORETRY);
 			if (src) {
@@ -672,7 +672,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
 	nr_threads = num_online_cpus() - 1;
 	nr_threads = clamp_val(nr_threads, 1, LZO_THREADS);
 
-	page = (void *)__get_free_page(__GFP_RECLAIM | __GFP_HIGH);
+	page = get_free_page(__GFP_RECLAIM | __GFP_HIGH);
 	if (!page) {
 		printk(KERN_ERR "PM: Failed to allocate LZO page\n");
 		ret = -ENOMEM;
@@ -974,8 +974,7 @@ static int get_swap_reader(struct swap_map_handle *handle,
 			last->next = tmp;
 		last = tmp;
 
-		tmp->map = (struct swap_map_page *)
-			   __get_free_page(__GFP_RECLAIM | __GFP_HIGH);
+		tmp->map = get_free_page(__GFP_RECLAIM | __GFP_HIGH);
 		if (!tmp->map) {
 			release_swap_reader(handle);
 			return -ENOMEM;
@@ -1241,7 +1240,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
 	read_pages = clamp_val(read_pages, LZO_MIN_RD_PAGES, LZO_MAX_RD_PAGES);
 
 	for (i = 0; i < read_pages; i++) {
-		page[i] = (void *)__get_free_page(i < LZO_CMP_PAGES ?
+		page[i] = get_free_page(i < LZO_CMP_PAGES ?
 						  __GFP_RECLAIM | __GFP_HIGH :
 						  __GFP_RECLAIM | __GFP_NOWARN |
 						  __GFP_NORETRY);
@@ -1580,7 +1579,7 @@ int swsusp_unmark(void)
 
 static int swsusp_header_init(void)
 {
-	swsusp_header = (struct swsusp_header*) __get_free_page(GFP_KERNEL);
+	swsusp_header =  get_free_page(GFP_KERNEL);
 	if (!swsusp_header)
 		panic("Could not allocate memory for swsusp_header\n");
 	return 0;
kernel/sysctl.c +3 -3
index edb7da4..b2aed2a 100644
@@ -2077,7 +2077,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
 
 		if (left > PAGE_SIZE - 1)
 			left = PAGE_SIZE - 1;
-		kbuf = (char *)__get_free_page(GFP_TEMPORARY);
+		kbuf = get_free_page(GFP_TEMPORARY);
 		if (!kbuf)
 			return -ENOMEM;
 		if (copy_from_user(kbuf, buffer, left)) {
@@ -2337,7 +2337,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
 
 		if (left > PAGE_SIZE - 1)
 			left = PAGE_SIZE - 1;
-		kbuf = (char *)__get_free_page(GFP_TEMPORARY);
+		kbuf = get_free_page(GFP_TEMPORARY);
 		if (!kbuf)
 			return -ENOMEM;
 		if (copy_from_user(kbuf, buffer, left)) {
@@ -2646,7 +2646,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
 	}
 
 	if (write) {
-		char *kbuf = (char *)__get_free_page(GFP_TEMPORARY);
+		char *kbuf = get_free_page(GFP_TEMPORARY);
 		if (!kbuf)
 			return -ENOMEM;
 
kernel/trace/trace_events.c +2 -2
index 0a0a08e..d32df68 100644
@@ -1340,7 +1340,7 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	if (cnt >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = (char *)__get_free_page(GFP_TEMPORARY);
+	buf = get_free_page(GFP_TEMPORARY);
 	if (!buf)
 		return -ENOMEM;
 
@@ -1507,7 +1507,7 @@ subsystem_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 	if (cnt >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = (char *)__get_free_page(GFP_TEMPORARY);
+	buf = get_free_page(GFP_TEMPORARY);
 	if (!buf)
 		return -ENOMEM;
 
kernel/trace/trace_events_filter.c +1 -1
index 234b5b9e..3889fce 100644
@@ -671,7 +671,7 @@ static void append_filter_err(struct filter_parse_state *ps,
 	int pos = ps->lasterr_pos;
 	char *buf, *pbuf;
 
-	buf = (char *)__get_free_page(GFP_TEMPORARY);
+	buf = get_free_page(GFP_TEMPORARY);
 	if (!buf)
 		return;
 
kernel/trace/trace_events_trigger.c +1 -1
index 0796e61..af6c31d 100644
@@ -237,7 +237,7 @@ static ssize_t event_trigger_regex_write(struct file *file,
 	if (cnt >= PAGE_SIZE)
 		return -EINVAL;
 
-	buf = (char *)__get_free_page(GFP_TEMPORARY);
+	buf = get_free_page(GFP_TEMPORARY);
 	if (!buf)
 		return -ENOMEM;
 
kernel/user_namespace.c +1 -1
index badce97..57eb85f0 100644
@@ -639,7 +639,7 @@ static ssize_t map_write(struct file *file, const char __user *buf,
 
 	/* Get a buffer */
 	ret = -ENOMEM;
-	kbuf = (char *)__get_free_page(GFP_TEMPORARY);
+	kbuf = get_free_page(GFP_TEMPORARY);
 	if (!kbuf)
 		goto out;
 
lib/scatterlist.c +1 -1
index 6f44c3e..0752e7a 100644
@@ -173,7 +173,7 @@ static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask)
 		 * false-positive) we need to inform kmemleak of all the
 		 * intermediate allocations.
 		 */
-		void *ptr = (void *) __get_free_page(gfp_mask);
+		void *ptr = get_free_page(gfp_mask);
 		kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask);
 		return ptr;
 	} else
mm/memory.c +2 -2
index a3c4440..8e4b375 100644
@@ -371,7 +371,7 @@ void tlb_remove_table(struct mmu_gather *tlb, void *table)
 	}
 
 	if (*batch == NULL) {
-		*batch = (struct mmu_table_batch *)__get_free_page(GFP_NOWAIT | __GFP_NOWARN);
+		*batch = get_free_page(GFP_NOWAIT | __GFP_NOWARN);
 		if (*batch == NULL) {
 			tlb_remove_table_one(table);
 			return;
@@ -3762,7 +3762,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
 	vma = find_vma(mm, ip);
 	if (vma && vma->vm_file) {
 		struct file *f = vma->vm_file;
-		char *buf = (char *)__get_free_page(GFP_KERNEL);
+		char *buf = get_free_page(GFP_KERNEL);
 		if (buf) {
 			char *p;
 
mm/migrate.c +1 -1
index 7aeba9a..f9c2d38 100644
@@ -1323,7 +1323,7 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes,
 	int err;
 
 	err = -ENOMEM;
-	pm = (struct page_to_node *)__get_free_page(GFP_KERNEL);
+	pm = get_free_page(GFP_KERNEL);
 	if (!pm)
 		goto out;
 
mm/mincore.c +1 -1
index 077ef0e..a6a19db 100644
@@ -239,7 +239,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len,
 	if (!access_ok(VERIFY_WRITE, vec, pages))
 		return -EFAULT;
 
-	tmp = (void *) __get_free_page(GFP_USER);
+	tmp = get_free_page(GFP_USER);
 	if (!tmp)
 		return -EAGAIN;
 
net/atm/mpoa_proc.c +1 -1
index a2721ae..45d20cb 100644
@@ -215,7 +215,7 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
 	if (nbytes >= PAGE_SIZE)
 		nbytes = PAGE_SIZE-1;
 
-	page = (char *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return -ENOMEM;
 
security/selinux/hooks.c +1 -1
index dba9f5f..e539d0d 100644
@@ -1258,7 +1258,7 @@ static int selinux_genfs_get_sid(struct dentry *dentry,
 	struct super_block *sb = dentry->d_inode->i_sb;
 	char *buffer, *path;
 
-	buffer = (char *)__get_free_page(GFP_KERNEL);
+	buffer = get_free_page(GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
security/selinux/selinuxfs.c +1 -1
index c4de69b..563ba88 100644
@@ -1336,7 +1336,7 @@ static ssize_t sel_read_avc_hash_stats(struct file *filp, char __user *buf,
 	char *page;
 	ssize_t length;
 
-	page = (char *)__get_free_page(GFP_KERNEL);
+	page = get_free_page(GFP_KERNEL);
 	if (!page)
 		return -ENOMEM;
 
sound/oss/msnd_pinnacle.c +2 -2
index 8aa54fc..8ce2399 100644
@@ -899,7 +899,7 @@ static __inline__ int pack_DAPF_to_DAPQ(register int start)
 static int dsp_read(char __user *buf, size_t len)
 {
 	int count = len;
-	char *page = (char *)__get_free_page(GFP_KERNEL);
+	char *page = get_free_page(GFP_KERNEL);
 	int timeout = get_rec_delay_jiffies(DAR_BUFF_SIZE);
 
 	if (!page)
@@ -958,7 +958,7 @@ static int dsp_read(char __user *buf, size_t len)
 static int dsp_write(const char __user *buf, size_t len)
 {
 	int count = len;
-	char *page = (char *)__get_free_page(GFP_KERNEL);
+	char *page = get_free_page(GFP_KERNEL);
 	int timeout = get_play_delay_jiffies(DAP_BUFF_SIZE);
 
 	if (!page)
Signature · 1 line
2.1.4
author maintainer
#73 lore raw

PATCH 62/83 m68k: switch pte_alloc_one_kernel() to get_free_page()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/m68k/include/asm/mcf_pgalloc.h  | 6 +++---
 arch/m68k/include/asm/sun3_pgalloc.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/m68k/include/asm/mcf_pgalloc.h +3 -3
index 04ffc22..e08cac3 100644
@@ -14,13 +14,13 @@ extern const char bad_pmd_string[];
 extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 	unsigned long address)
 {
-	unsigned long page = __get_free_page(GFP_DMA|__GFP_REPEAT);
+	pte_t *page = get_free_page(GFP_DMA|__GFP_REPEAT);
 
 	if (!page)
 		return NULL;
 
-	memset((void *)page, 0, PAGE_SIZE);
-	return (pte_t *) (page);
+	memset(page, 0, PAGE_SIZE);
+	return page;
 }
 
 extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
arch/m68k/include/asm/sun3_pgalloc.h +3 -3
index ab0fd5c..9140b29 100644
@@ -37,13 +37,13 @@ do {							\
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
 					  unsigned long address)
 {
-	unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	pte_t *page = get_free_page(GFP_KERNEL|__GFP_REPEAT);
 
 	if (!page)
 		return NULL;
 
-	memset((void *)page, 0, PAGE_SIZE);
-	return (pte_t *) (page);
+	memset(page, 0, PAGE_SIZE);
+	return page;
 }
 
 static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
Signature · 1 line
2.1.4
author maintainer
#74 lore raw

PATCH 63/83 switch kvmppc_core_vcpu_create_pr() to get_free_page()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/powerpc/kvm/book3s_pr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/kvm/book3s_pr.c +3 -3
index 3775664..9bdf9e3 100644
@@ -1375,7 +1375,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_pr(struct kvm *kvm,
 	struct kvmppc_vcpu_book3s *vcpu_book3s;
 	struct kvm_vcpu *vcpu;
 	int err = -ENOMEM;
-	unsigned long p;
+	void *p;
 
 	vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
 	if (!vcpu)
@@ -1398,10 +1398,10 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_pr(struct kvm *kvm,
 		goto free_shadow_vcpu;
 
 	err = -ENOMEM;
-	p = __get_free_page(GFP_KERNEL|__GFP_ZERO);
+	p = get_free_page(GFP_KERNEL|__GFP_ZERO);
 	if (!p)
 		goto uninit_vcpu;
-	vcpu->arch.shared = (void *)p;
+	vcpu->arch.shared = p;
 #ifdef CONFIG_PPC_BOOK3S_64
 	/* Always start the shared struct in native endian mode */
 #ifdef __BIG_ENDIAN__
Signature · 1 line
2.1.4
author maintainer
#75 lore raw

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

In reply to Al Viro

From: Al Viro <[email protected]>

---
 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(-)
drivers/video/fbdev/grvga.c +9 -11
index b471f92..28fd657 100644
@@ -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:
drivers/video/fbdev/vermilion/vermilion.c +8 -9
index 0882f41..4e9e02f 100644
@@ -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;
 	}
 }
 
drivers/video/fbdev/vermilion/vermilion.h +1 -1
index 43d11ec..65f1a63 100644
@@ -203,7 +203,7 @@ struct vml_par {
 };
 
 struct vram_area {
-	unsigned long logical;
+	void *logical;
 	unsigned long phys;
 	unsigned long size;
 	unsigned order;
Signature · 1 line
2.1.4
author maintainer
#76 lore raw

PATCH 65/83 um: switch to get_free_page()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/x86/um/ldt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/um/ldt.c +3 -4
index 60b4314..a3c5104 100644
@@ -297,7 +297,7 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm)
 	struct user_desc desc;
 	short * num_p;
 	int i;
-	long page, err=0;
+	long err=0;
 	void *addr = NULL;
 
 
@@ -336,13 +336,12 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm)
 	else {
 		i = from_mm->arch.ldt.entry_count / LDT_ENTRIES_PER_PAGE;
 		while (i-->0) {
-			page = __get_free_page(GFP_KERNEL|__GFP_ZERO);
+			void *page = get_free_page(GFP_KERNEL|__GFP_ZERO);
 			if (!page) {
 				err = -ENOMEM;
 				break;
 			}
-			new_mm->arch.ldt.u.pages[i] =
-				(struct ldt_entry *) page;
+			new_mm->arch.ldt.u.pages[i] = page;
 			memcpy(new_mm->arch.ldt.u.pages[i],
 			       from_mm->arch.ldt.u.pages[i], PAGE_SIZE);
 		}
Signature · 1 line
2.1.4
author maintainer
#77 lore raw

PATCH 66/83 switch xen_get_swiotlb_free_pages() to returning a pointer

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/arm/include/asm/xen/page.h | 2 +-
 arch/arm/xen/mm.c               | 4 ++--
 arch/x86/include/asm/xen/page.h | 4 ++--
 drivers/xen/swiotlb-xen.c       | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/include/asm/xen/page.h +1 -1
index 415dbc6..79f92d4 100644
@@ -117,6 +117,6 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 bool xen_arch_need_swiotlb(struct device *dev,
 			   phys_addr_t phys,
 			   dma_addr_t dev_addr);
-unsigned long xen_get_swiotlb_free_pages(unsigned int order);
+void *xen_get_swiotlb_free_pages(unsigned int order);
 
 #endif /* _ASM_ARM_XEN_PAGE_H */
arch/arm/xen/mm.c +2 -2
index c5f9a9e..9677c56 100644
@@ -22,7 +22,7 @@
 #include <asm/xen/hypercall.h>
 #include <asm/xen/interface.h>
 
-unsigned long xen_get_swiotlb_free_pages(unsigned int order)
+void *xen_get_swiotlb_free_pages(unsigned int order)
 {
 	struct memblock_region *reg;
 	gfp_t flags = __GFP_NOWARN|__GFP_KSWAPD_RECLAIM;
@@ -33,7 +33,7 @@ unsigned long xen_get_swiotlb_free_pages(unsigned int order)
 			break;
 		}
 	}
-	return __get_free_pages(flags, order);
+	return get_free_pages(flags, order);
 }
 
 enum dma_cache_op {
arch/x86/include/asm/xen/page.h +2 -2
index f5fb840..89d7a44 100644
@@ -304,9 +304,9 @@ static inline bool xen_arch_need_swiotlb(struct device *dev,
 	return false;
 }
 
-static inline unsigned long xen_get_swiotlb_free_pages(unsigned int order)
+static inline void *xen_get_swiotlb_free_pages(unsigned int order)
 {
-	return __get_free_pages(__GFP_NOWARN, order);
+	return get_free_pages(__GFP_NOWARN, order);
 }
 
 #endif /* _ASM_X86_XEN_PAGE_H */
drivers/xen/swiotlb-xen.c +1 -1
index fa6b56e..952255f 100644
@@ -234,7 +234,7 @@ retry:
 #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
 #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
 		while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
-			xen_io_tlb_start = (void *)xen_get_swiotlb_free_pages(order);
+			xen_io_tlb_start = xen_get_swiotlb_free_pages(order);
 			if (xen_io_tlb_start)
 				break;
 			order--;
Signature · 1 line
2.1.4
author maintainer
#78 lore raw

PATCH 67/83 mn10300 dma_alloc_coherent(): switch to get_free_pages()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/mn10300/mm/dma-alloc.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
arch/mn10300/mm/dma-alloc.c +8 -9
index 5f3132a4..ffcf771 100644
@@ -23,17 +23,16 @@ static unsigned long pci_sram_allocated = 0xbc000000;
 void *dma_alloc_coherent(struct device *dev, size_t size,
 			 dma_addr_t *dma_handle, int gfp)
 {
-	unsigned long addr;
-	void *ret;
+	void *addr, *ret;
 
 	pr_debug("dma_alloc_coherent(%s,%zu,%x)\n",
 		 dev ? dev_name(dev) : "?", size, gfp);
 
 	if (0xbe000000 - pci_sram_allocated >= size) {
 		size = (size + 255) & ~255;
-		addr = pci_sram_allocated;
+		addr = (void *)pci_sram_allocated;
 		pci_sram_allocated += size;
-		ret = (void *) addr;
+		ret = addr;
 		goto done;
 	}
 
@@ -43,21 +42,21 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 	if (dev == NULL || dev->coherent_dma_mask < 0xffffffff)
 		gfp |= GFP_DMA;
 
-	addr = __get_free_pages(gfp, get_order(size));
+	addr = get_free_pages(gfp, get_order(size));
 	if (!addr)
 		return NULL;
 
 	/* map the coherent memory through the uncached memory window */
-	ret = (void *) (addr | 0x20000000);
+	ret = (void *) ((unsigned long)addr | 0x20000000);
 
 	/* fill the memory with obvious rubbish */
-	memset((void *) addr, 0xfb, size);
+	memset(addr, 0xfb, size);
 
 	/* write back and evict all cache lines covering this region */
-	mn10300_dcache_flush_inv_range2(virt_to_phys((void *) addr), PAGE_SIZE);
+	mn10300_dcache_flush_inv_range2(virt_to_phys(addr), PAGE_SIZE);
 
 done:
-	*dma_handle = virt_to_bus((void *) addr);
+	*dma_handle = virt_to_bus(addr);
 	printk("dma_alloc_coherent() = %p [%x]\n", ret, *dma_handle);
 	return ret;
 }
Signature · 1 line
2.1.4
author maintainer
#79 lore raw

PATCH 68/83 switch ps3_dma_map() and ps3_dma_region_ops->map() instances to physical address

In reply to Al Viro

From: Al Viro <[email protected]>

callers know whether they are passing a virtual address or a physical one; seeing that all work in the instances is done with physical addresses, might as well have all callers pass those and don't bother with instances checking whether they'd got a physical or a virtual address.

---
 arch/powerpc/include/asm/ps3.h          |  4 ++--
 arch/powerpc/platforms/ps3/mm.c         | 34 ++++++++++++---------------------
 arch/powerpc/platforms/ps3/system-bus.c |  6 +++---
 3 files changed, 17 insertions(+), 27 deletions(-)
arch/powerpc/include/asm/ps3.h +2 -2
index a1bc7e7..ec12e0ba 100644
@@ -110,7 +110,7 @@ struct ps3_dma_region_ops {
 	int (*create)(struct ps3_dma_region *);
 	int (*free)(struct ps3_dma_region *);
 	int (*map)(struct ps3_dma_region *,
-		   unsigned long virt_addr,
+		   unsigned long phys_addr,
 		   unsigned long len,
 		   dma_addr_t *bus_addr,
 		   u64 iopte_pp);
@@ -132,7 +132,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
 	enum ps3_dma_region_type region_type, void *addr, unsigned long len);
 int ps3_dma_region_create(struct ps3_dma_region *r);
 int ps3_dma_region_free(struct ps3_dma_region *r);
-int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
+int ps3_dma_map(struct ps3_dma_region *r, unsigned long phys_addr,
 	unsigned long len, dma_addr_t *bus_addr,
 	u64 iopte_pp);
 int ps3_dma_unmap(struct ps3_dma_region *r, dma_addr_t bus_addr,
arch/powerpc/platforms/ps3/mm.c +12 -22
index b0f3466..6cc3007 100644
@@ -772,7 +772,7 @@ static int dma_ioc0_region_free(struct ps3_dma_region *r)
 /**
  * dma_sb_map_area - Map an area of memory into a device dma region.
  * @r: Pointer to a struct ps3_dma_region.
- * @virt_addr: Starting virtual address of the area to map.
+ * @phys_addr: Starting virtual address of the area to map.
  * @len: Length in bytes of the area to map.
  * @bus_addr: A pointer to return the starting ioc bus address of the area to
  * map.
@@ -780,15 +780,13 @@ static int dma_ioc0_region_free(struct ps3_dma_region *r)
  * This is the common dma mapping routine.
  */
 
-static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
+static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long phys_addr,
 	   unsigned long len, dma_addr_t *bus_addr,
 	   u64 iopte_flag)
 {
 	int result;
 	unsigned long flags;
 	struct dma_chunk *c;
-	unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
-		: virt_addr;
 	unsigned long aligned_phys = _ALIGN_DOWN(phys_addr, 1 << r->page_size);
 	unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
 					      1 << r->page_size);
@@ -797,8 +795,6 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
 	if (!USE_DYNAMIC_DMA) {
 		unsigned long lpar_addr = ps3_mm_phys_to_lpar(phys_addr);
 		DBG(" -> %s:%d\n", __func__, __LINE__);
-		DBG("%s:%d virt_addr %lxh\n", __func__, __LINE__,
-			virt_addr);
 		DBG("%s:%d phys_addr %lxh\n", __func__, __LINE__,
 			phys_addr);
 		DBG("%s:%d lpar_addr %lxh\n", __func__, __LINE__,
@@ -835,23 +831,19 @@ static int dma_sb_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
 	return result;
 }
 
-static int dma_ioc0_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
+static int dma_ioc0_map_area(struct ps3_dma_region *r, unsigned long phys_addr,
 	     unsigned long len, dma_addr_t *bus_addr,
 	     u64 iopte_flag)
 {
 	int result;
 	unsigned long flags;
 	struct dma_chunk *c;
-	unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
-		: virt_addr;
 	unsigned long aligned_phys = _ALIGN_DOWN(phys_addr, 1 << r->page_size);
 	unsigned long aligned_len = _ALIGN_UP(len + phys_addr - aligned_phys,
 					      1 << r->page_size);
 
-	DBG(KERN_ERR "%s: vaddr=%#lx, len=%#lx\n", __func__,
-	    virt_addr, len);
-	DBG(KERN_ERR "%s: ph=%#lx a_ph=%#lx a_l=%#lx\n", __func__,
-	    phys_addr, aligned_phys, aligned_len);
+	DBG(KERN_ERR "%s: ph=%#lx len=%#lx a_ph=%#lx a_l=%#lx\n", __func__,
+	    phys_addr, len, aligned_phys, aligned_len);
 
 	spin_lock_irqsave(&r->chunk_list.lock, flags);
 	c = dma_find_chunk_lpar(r, ps3_mm_phys_to_lpar(phys_addr), len);
@@ -876,8 +868,8 @@ static int dma_ioc0_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
 		return result;
 	}
 	*bus_addr = c->bus_addr + phys_addr - aligned_phys;
-	DBG("%s: va=%#lx pa=%#lx a_pa=%#lx bus=%#llx\n", __func__,
-	    virt_addr, phys_addr, aligned_phys, *bus_addr);
+	DBG("%s: pa=%#lx a_pa=%#lx bus=%#llx\n", __func__,
+	    phys_addr, aligned_phys, *bus_addr);
 	c->usage_count = 1;
 
 	spin_unlock_irqrestore(&r->chunk_list.lock, flags);
@@ -1001,7 +993,7 @@ static int dma_sb_region_create_linear(struct ps3_dma_region *r)
 		len = map.rm.size - r->offset;
 		if (len > r->len)
 			len = r->len;
-		result = dma_sb_map_area(r, virt_addr, len, &tmp,
+		result = dma_sb_map_area(r, __pa(virt_addr), len, &tmp,
 			CBE_IOPTE_PP_W | CBE_IOPTE_PP_R | CBE_IOPTE_SO_RW |
 			CBE_IOPTE_M);
 		BUG_ON(result);
@@ -1015,7 +1007,7 @@ static int dma_sb_region_create_linear(struct ps3_dma_region *r)
 			virt_addr += r->offset - map.rm.size;
 		else
 			len -= map.rm.size - r->offset;
-		result = dma_sb_map_area(r, virt_addr, len, &tmp,
+		result = dma_sb_map_area(r, __pa(virt_addr), len, &tmp,
 			CBE_IOPTE_PP_W | CBE_IOPTE_PP_R | CBE_IOPTE_SO_RW |
 			CBE_IOPTE_M);
 		BUG_ON(result);
@@ -1080,11 +1072,9 @@ static int dma_sb_region_free_linear(struct ps3_dma_region *r)
  */
 
 static int dma_sb_map_area_linear(struct ps3_dma_region *r,
-	unsigned long virt_addr, unsigned long len, dma_addr_t *bus_addr,
+	unsigned long phys_addr, unsigned long len, dma_addr_t *bus_addr,
 	u64 iopte_flag)
 {
-	unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
-		: virt_addr;
 	*bus_addr = dma_sb_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr));
 	return 0;
 }
@@ -1176,11 +1166,11 @@ int ps3_dma_region_free(struct ps3_dma_region *r)
 }
 EXPORT_SYMBOL(ps3_dma_region_free);
 
-int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
+int ps3_dma_map(struct ps3_dma_region *r, unsigned long phys_addr,
 	unsigned long len, dma_addr_t *bus_addr,
 	u64 iopte_flag)
 {
-	return r->region_ops->map(r, virt_addr, len, bus_addr, iopte_flag);
+	return r->region_ops->map(r, phys_addr, len, bus_addr, iopte_flag);
 }
 
 int ps3_dma_unmap(struct ps3_dma_region *r, dma_addr_t bus_addr,
arch/powerpc/platforms/ps3/system-bus.c +3 -3
index 001b93c..988f8eb 100644
@@ -532,7 +532,7 @@ static void * ps3_alloc_coherent(struct device *_dev, size_t size,
 		goto clean_none;
 	}
 
-	result = ps3_dma_map(dev->d_region, virt_addr, size, dma_handle,
+	result = ps3_dma_map(dev->d_region, __pa(virt_addr), size, dma_handle,
 			     CBE_IOPTE_PP_W | CBE_IOPTE_PP_R |
 			     CBE_IOPTE_SO_RW | CBE_IOPTE_M);
 
@@ -576,7 +576,7 @@ static dma_addr_t ps3_sb_map_page(struct device *_dev, struct page *page,
 	dma_addr_t bus_addr;
 	void *ptr = page_address(page) + offset;
 
-	result = ps3_dma_map(dev->d_region, (unsigned long)ptr, size,
+	result = ps3_dma_map(dev->d_region, __pa(ptr), size,
 			     &bus_addr,
 			     CBE_IOPTE_PP_R | CBE_IOPTE_PP_W |
 			     CBE_IOPTE_SO_RW | CBE_IOPTE_M);
@@ -615,7 +615,7 @@ static dma_addr_t ps3_ioc0_map_page(struct device *_dev, struct page *page,
 		/* not happned */
 		BUG();
 	};
-	result = ps3_dma_map(dev->d_region, (unsigned long)ptr, size,
+	result = ps3_dma_map(dev->d_region, __pa(ptr), size,
 			     &bus_addr, iopte_flag);
 
 	if (result) {
Signature · 1 line
2.1.4
author maintainer
#80 lore raw

PATCH 69/83 ps3_alloc_coherent(): get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/powerpc/platforms/ps3/system-bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/ps3/system-bus.c +4 -4
index 988f8eb..bb358ab 100644
@@ -520,12 +520,12 @@ static void * ps3_alloc_coherent(struct device *_dev, size_t size,
 {
 	int result;
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
-	unsigned long virt_addr;
+	void *virt_addr;
 
 	flag &= ~(__GFP_DMA | __GFP_HIGHMEM);
 	flag |= __GFP_ZERO;
 
-	virt_addr = __get_free_pages(flag, get_order(size));
+	virt_addr = get_free_pages(flag, get_order(size));
 
 	if (!virt_addr) {
 		pr_debug("%s:%d: get_free_pages failed\n", __func__, __LINE__);
@@ -543,10 +543,10 @@ static void * ps3_alloc_coherent(struct device *_dev, size_t size,
 		goto clean_alloc;
 	}
 
-	return (void*)virt_addr;
+	return virt_addr;
 
 clean_alloc:
-	free_pages((void *)virt_addr, get_order(size));
+	free_pages(virt_addr, get_order(size));
 clean_none:
 	dma_handle = NULL;
 	return NULL;
Signature · 1 line
2.1.4
author maintainer
#81 lore raw

PATCH 70/83 s390_dma_alloc(): page_to_phys() result is always a multiple of PAGE_SIZE

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/s390/pci/pci_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/pci/pci_dma.c +1 -1
index 5a15471..afa4be1 100644
@@ -366,7 +366,7 @@ static void *s390_dma_alloc(struct device *dev, size_t size,
 	pa = page_to_phys(page);
 	memset((void *) pa, 0, size);
 
-	map = s390_dma_map_pages(dev, page, pa % PAGE_SIZE,
+	map = s390_dma_map_pages(dev, page, 0,
 				 size, DMA_BIDIRECTIONAL, NULL);
 	if (dma_mapping_error(dev, map)) {
 		free_pages((void *)pa, get_order(size));
Signature · 1 line
2.1.4
author maintainer
#82 lore raw

PATCH 71/83 s390_dma_alloc(): use page_address()

In reply to Al Viro

From: Al Viro <[email protected]>

... rather than open-coding it as (void *)page_to_phys() - those expand to the same thing on s390 (no highmem and __va is an identity mapping), but it's more readable (and less confusing) that way.

---
 arch/s390/pci/pci_dma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/s390/pci/pci_dma.c +5 -5
index afa4be1..6ea4d13 100644
@@ -355,7 +355,7 @@ static void *s390_dma_alloc(struct device *dev, size_t size,
 {
 	struct zpci_dev *zdev = to_zpci(to_pci_dev(dev));
 	struct page *page;
-	unsigned long pa;
+	void *p;
 	dma_addr_t map;
 
 	size = PAGE_ALIGN(size);
@@ -363,20 +363,20 @@ static void *s390_dma_alloc(struct device *dev, size_t size,
 	if (!page)
 		return NULL;
 
-	pa = page_to_phys(page);
-	memset((void *) pa, 0, size);
+	p = page_address(page);
+	memset(p, 0, size);
 
 	map = s390_dma_map_pages(dev, page, 0,
 				 size, DMA_BIDIRECTIONAL, NULL);
 	if (dma_mapping_error(dev, map)) {
-		free_pages((void *)pa, get_order(size));
+		free_pages(p, get_order(size));
 		return NULL;
 	}
 
 	atomic64_add(size / PAGE_SIZE, &zdev->allocated_pages);
 	if (dma_handle)
 		*dma_handle = map;
-	return (void *) pa;
+	return p;
 }
 
 static void s390_dma_free(struct device *dev, size_t size,
Signature · 1 line
2.1.4
author maintainer
#83 lore raw

PATCH 72/83 switch cmm_page_array->pages[] to pointers

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/powerpc/platforms/pseries/cmm.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
arch/powerpc/platforms/pseries/cmm.c +16 -16
index f4aa67d..af628e4 100644
@@ -94,7 +94,7 @@ MODULE_PARM_DESC(debug, "Enable module debugging logging. Set to 1 to enable. "
 struct cmm_page_array {
 	struct cmm_page_array *next;
 	unsigned long index;
-	unsigned long page[CMM_NR_PAGES];
+	void *page[CMM_NR_PAGES];
 };
 
 static unsigned long loaned_pages;
@@ -119,7 +119,7 @@ static struct task_struct *cmm_thread_ptr;
 static long cmm_alloc_pages(long nr)
 {
 	struct cmm_page_array *pa, *npa;
-	unsigned long addr;
+	void *addr;
 	long rc;
 
 	cmm_dbg("Begin request for %ld pages\n", nr);
@@ -136,7 +136,7 @@ static long cmm_alloc_pages(long nr)
 			break;
 		}
 
-		addr = __get_free_page(GFP_NOIO | __GFP_NOWARN |
+		addr = get_free_page(GFP_NOIO | __GFP_NOWARN |
 				       __GFP_NORETRY | __GFP_NOMEMALLOC);
 		if (!addr)
 			break;
@@ -149,7 +149,7 @@ static long cmm_alloc_pages(long nr)
 					__GFP_NORETRY | __GFP_NOMEMALLOC);
 			if (!npa) {
 				pr_info("%s: Can not allocate new page list\n", __func__);
-				free_page((void *)addr);
+				free_page(addr);
 				break;
 			}
 			spin_lock(&cmm_lock);
@@ -167,7 +167,7 @@ static long cmm_alloc_pages(long nr)
 		if ((rc = plpar_page_set_loaned(__pa(addr)))) {
 			pr_err("%s: Can not set page to loaned. rc=%ld\n", __func__, rc);
 			spin_unlock(&cmm_lock);
-			free_page((void *)addr);
+			free_page(addr);
 			break;
 		}
 
@@ -192,7 +192,7 @@ static long cmm_alloc_pages(long nr)
 static long cmm_free_pages(long nr)
 {
 	struct cmm_page_array *pa;
-	unsigned long addr;
+	void *addr;
 
 	cmm_dbg("Begin free of %ld pages.\n", nr);
 	spin_lock(&cmm_lock);
@@ -209,7 +209,7 @@ static long cmm_free_pages(long nr)
 		}
 
 		plpar_page_set_active(__pa(addr));
-		free_page((void *)addr);
+		free_page(addr);
 		loaned_pages--;
 		nr--;
 		totalram_pages++;
@@ -471,14 +471,14 @@ static unsigned long cmm_count_pages(void *arg)
 {
 	struct memory_isolate_notify *marg = arg;
 	struct cmm_page_array *pa;
-	unsigned long start = (unsigned long)pfn_to_kaddr(marg->start_pfn);
-	unsigned long end = start + (marg->nr_pages << PAGE_SHIFT);
+	void *start = pfn_to_kaddr(marg->start_pfn);
+	void *end = start + (marg->nr_pages << PAGE_SHIFT);
 	unsigned long idx;
 
 	spin_lock(&cmm_lock);
 	pa = cmm_page_list;
 	while (pa) {
-		if ((unsigned long)pa >= start && (unsigned long)pa < end)
+		if ((void *)pa >= start && (void *)pa < end)
 			marg->pages_found++;
 		for (idx = 0; idx < pa->index; idx++)
 			if (pa->page[idx] >= start && pa->page[idx] < end)
@@ -524,13 +524,13 @@ static struct notifier_block cmm_mem_isolate_nb = {
 static int cmm_mem_going_offline(void *arg)
 {
 	struct memory_notify *marg = arg;
-	unsigned long start_page = (unsigned long)pfn_to_kaddr(marg->start_pfn);
-	unsigned long end_page = start_page + (marg->nr_pages << PAGE_SHIFT);
+	void *start_page = pfn_to_kaddr(marg->start_pfn);
+	void *end_page = start_page + (marg->nr_pages << PAGE_SHIFT);
 	struct cmm_page_array *pa_curr, *pa_last, *npa;
 	unsigned long idx;
 	unsigned long freed = 0;
 
-	cmm_dbg("Memory going offline, searching 0x%lx (%ld pages).\n",
+	cmm_dbg("Memory going offline, searching 0x%p (%ld pages).\n",
 			start_page, marg->nr_pages);
 	spin_lock(&cmm_lock);
 
@@ -543,7 +543,7 @@ static int cmm_mem_going_offline(void *arg)
 				continue;
 
 			plpar_page_set_active(__pa(pa_curr->page[idx]));
-			free_page((void *)pa_curr->page[idx]);
+			free_page(pa_curr->page[idx]);
 			freed++;
 			loaned_pages--;
 			totalram_pages++;
@@ -563,8 +563,8 @@ static int cmm_mem_going_offline(void *arg)
 	pa_last = NULL;
 	pa_curr = cmm_page_list;
 	while (pa_curr) {
-		if (((unsigned long)pa_curr >= start_page) &&
-				((unsigned long)pa_curr < end_page)) {
+		if (((void *)pa_curr >= start_page) &&
+		    ((void *)pa_curr < end_page)) {
 			npa = get_free_page(GFP_NOIO | __GFP_NOWARN |
 					__GFP_NORETRY | __GFP_NOMEMALLOC);
 			if (!npa) {
Signature · 1 line
2.1.4
author maintainer
#84 lore raw

PATCH 73/83 niu.c: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 drivers/net/ethernet/sun/niu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/niu.c +3 -3
index 66ac0ffe..1716148 100644
@@ -9959,14 +9959,14 @@ static void *niu_phys_alloc_coherent(struct device *dev, size_t size,
 				     u64 *dma_addr, gfp_t flag)
 {
 	unsigned long order = get_order(size);
-	unsigned long page = __get_free_pages(flag, order);
+	void *page = get_free_pages(flag, order);
 
 	if (page == 0UL)
 		return NULL;
-	memset((char *)page, 0, PAGE_SIZE << order);
+	memset(page, 0, PAGE_SIZE << order);
 	*dma_addr = __pa(page);
 
-	return (void *) page;
+	return page;
 }
 
 static void niu_phys_free_coherent(struct device *dev, size_t size,
Signature · 1 line
2.1.4
author maintainer
#85 lore raw

PATCH 74/83 switch pcpu_alloc_lowcore() to get_free_page()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/s390/kernel/smp.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
arch/s390/kernel/smp.c +9 -9
index 34a5041..a32f727 100644
@@ -179,24 +179,24 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit)
 
 static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
 {
-	unsigned long async_stack, panic_stack;
+	void *async_stack, *panic_stack;
 	struct _lowcore *lc;
 
 	if (pcpu != &pcpu_devices[0]) {
 		pcpu->lowcore =	get_free_pages(GFP_KERNEL | GFP_DMA, LC_ORDER);
-		async_stack = __get_free_pages(GFP_KERNEL, ASYNC_ORDER);
-		panic_stack = __get_free_page(GFP_KERNEL);
+		async_stack = get_free_pages(GFP_KERNEL, ASYNC_ORDER);
+		panic_stack = get_free_page(GFP_KERNEL);
 		if (!pcpu->lowcore || !panic_stack || !async_stack)
 			goto out;
 	} else {
-		async_stack = pcpu->lowcore->async_stack - ASYNC_FRAME_OFFSET;
-		panic_stack = pcpu->lowcore->panic_stack - PANIC_FRAME_OFFSET;
+		async_stack = (void *)(pcpu->lowcore->async_stack - ASYNC_FRAME_OFFSET);
+		panic_stack = (void *)(pcpu->lowcore->panic_stack - PANIC_FRAME_OFFSET);
 	}
 	lc = pcpu->lowcore;
 	memcpy(lc, &S390_lowcore, 512);
 	memset((char *) lc + 512, 0, sizeof(*lc) - 512);
-	lc->async_stack = async_stack + ASYNC_FRAME_OFFSET;
-	lc->panic_stack = panic_stack + PANIC_FRAME_OFFSET;
+	lc->async_stack = (u64)async_stack + ASYNC_FRAME_OFFSET;
+	lc->panic_stack = (u64)panic_stack + PANIC_FRAME_OFFSET;
 	lc->cpu_nr = cpu;
 	lc->spinlock_lockval = arch_spin_lockval(cpu);
 	if (MACHINE_HAS_VX)
@@ -209,8 +209,8 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
 	return 0;
 out:
 	if (pcpu != &pcpu_devices[0]) {
-		free_page((void *)panic_stack);
-		free_pages((void *)async_stack, ASYNC_ORDER);
+		free_page(panic_stack);
+		free_pages(async_stack, ASYNC_ORDER);
 		free_pages(pcpu->lowcore, LC_ORDER);
 	}
 	return -ENOMEM;
Signature · 1 line
2.1.4
author maintainer
#86 lore raw

PATCH 75/83 kill __get_free_page()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 drivers/acpi/apei/ghes.c | 2 +-
 include/linux/gfp.h      | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/acpi/apei/ghes.c +1 -1
index 1d074de..3c02819 100644
@@ -223,7 +223,7 @@ static int ghes_estatus_pool_expand(unsigned long len)
 		return 0;
 	pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE;
 	for (i = 0; i < pages; i++) {
-		addr = __get_free_page(GFP_KERNEL);
+		addr = (unsigned long)get_free_page(GFP_KERNEL);
 		if (!addr)
 			return -ENOMEM;
 		ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1);
include/linux/gfp.h +0 -3
index bb1626a..c929a04 100644
@@ -485,9 +485,6 @@ void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask);
 #define get_free_page(gfp_mask) \
 		get_free_pages((gfp_mask), 0)
 
-#define __get_free_page(gfp_mask) \
-		__get_free_pages((gfp_mask), 0)
-
 #define get_dma_pages(gfp_mask, order) \
 		get_free_pages((gfp_mask) | GFP_DMA, (order))
 
Signature · 1 line
2.1.4
author maintainer
#87 lore raw

PATCH 76/83 turn empty_zero_page into pointer

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/mips/include/asm/pgtable.h  | 4 ++--
 arch/mips/mm/init.c              | 7 ++++---
 arch/s390/include/asm/pgtable.h  | 6 +++---
 arch/s390/mm/init.c              | 7 ++++---
 arch/score/include/asm/pgtable.h | 6 +++---
 arch/score/mm/init.c             | 6 +++---
 6 files changed, 19 insertions(+), 17 deletions(-)
arch/mips/include/asm/pgtable.h +2 -2
index 8957f15..f0e06c6 100644
@@ -75,11 +75,11 @@ extern unsigned long _page_cachable_default;
  * for zero-mapped memory areas etc..
  */
 
-extern unsigned long empty_zero_page;
+extern void *empty_zero_page;
 extern unsigned long zero_page_mask;
 
 #define ZERO_PAGE(vaddr) \
-	(virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
+	(virt_to_page((empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
 #define __HAVE_COLOR_ZERO_PAGE
 
 extern void paging_init(void);
arch/mips/mm/init.c +4 -3
index 8770e61..872e7a1 100644
@@ -53,7 +53,8 @@
  * any price.  Since page is never written to after the initialization we
  * don't have to care about aliases on other CPUs.
  */
-unsigned long empty_zero_page, zero_page_mask;
+void *empty_zero_page;
+unsigned long zero_page_mask;
 EXPORT_SYMBOL_GPL(empty_zero_page);
 EXPORT_SYMBOL(zero_page_mask);
 
@@ -70,11 +71,11 @@ void setup_zero_pages(void)
 	else
 		order = 0;
 
-	empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
+	empty_zero_page = get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 	if (!empty_zero_page)
 		panic("Oh boy, that early out of memory?");
 
-	page = virt_to_page((void *)empty_zero_page);
+	page = virt_to_page(empty_zero_page);
 	split_page(page, order);
 	for (i = 0; i < (1 << order); i++, page++)
 		mark_page_reserved(page);
arch/s390/include/asm/pgtable.h +3 -3
index 024f85f..f6fe409 100644
@@ -47,12 +47,12 @@ extern void vmem_map_init(void);
  * for zero-mapped memory areas etc..
  */
 
-extern unsigned long empty_zero_page;
+extern void *empty_zero_page;
 extern unsigned long zero_page_mask;
 
 #define ZERO_PAGE(vaddr) \
-	(virt_to_page((void *)(empty_zero_page + \
-	 (((unsigned long)(vaddr)) &zero_page_mask))))
+	(virt_to_page(empty_zero_page + \
+	 (((unsigned long)(vaddr)) &zero_page_mask)))
 #define __HAVE_COLOR_ZERO_PAGE
 
 /* TODO: s390 cannot support io_remap_pfn_range... */
arch/s390/mm/init.c +4 -3
index c722400..7c8190f 100644
@@ -42,7 +42,8 @@
 
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
 
-unsigned long empty_zero_page, zero_page_mask;
+void *empty_zero_page;
+unsigned long zero_page_mask;
 EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(zero_page_mask);
 
@@ -59,11 +60,11 @@ static void __init setup_zero_pages(void)
 	while (order > 2 && (totalram_pages >> 10) < (1UL << order))
 		order--;
 
-	empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
+	empty_zero_page = get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
 	if (!empty_zero_page)
 		panic("Out of memory in setup_zero_pages");
 
-	page = virt_to_page((void *) empty_zero_page);
+	page = virt_to_page(empty_zero_page);
 	split_page(page, order);
 	for (i = 1 << order; i > 0; i--) {
 		mark_page_reserved(page);
arch/score/include/asm/pgtable.h +3 -3
index 0553e5c..8f5b1be 100644
@@ -163,12 +163,12 @@ static inline pgprot_t pgprot_noncached(pgprot_t _prot)
 #define __swp_offset(x) 	((x).val >> 10)
 #define __swp_entry(type, offset) ((swp_entry_t){(type) | ((offset) << 10)})
 
-extern unsigned long empty_zero_page;
+extern void *empty_zero_page;
 extern unsigned long zero_page_mask;
 
 #define ZERO_PAGE(vaddr) \
-	(virt_to_page((void *)(empty_zero_page + \
-	 (((unsigned long)(vaddr)) & zero_page_mask))))
+	(virt_to_page(empty_zero_page + \
+	 (((unsigned long)(vaddr)) & zero_page_mask)))
 
 #define pgtable_cache_init()	do {} while (0)
 
arch/score/mm/init.c +3 -3
index 9fbce49..b4db012 100644
@@ -38,18 +38,18 @@
 #include <asm/sections.h>
 #include <asm/tlb.h>
 
-unsigned long empty_zero_page;
+void *empty_zero_page;
 EXPORT_SYMBOL_GPL(empty_zero_page);
 
 static void setup_zero_page(void)
 {
 	struct page *page;
 
-	empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, 0);
+	empty_zero_page = get_free_pages(GFP_KERNEL | __GFP_ZERO, 0);
 	if (!empty_zero_page)
 		panic("Oh boy, that early out of memory?");
 
-	page = virt_to_page((void *) empty_zero_page);
+	page = virt_to_page(empty_zero_page);
 	mark_page_reserved(page);
 }
 
Signature · 1 line
2.1.4
author maintainer
#88 lore raw

PATCH 77/83 sparc: switch to get_free_pages()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/sparc/kernel/irq_64.c | 3 +--
 arch/sparc/mm/iommu.c      | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
arch/sparc/kernel/irq_64.c +1 -2
index 8858bb0..54a55ce 100644
@@ -1019,9 +1019,8 @@ static void __init alloc_one_queue(unsigned long *pa_ptr, unsigned long qmask)
 {
 	unsigned long size = PAGE_ALIGN(qmask + 1);
 	unsigned long order = get_order(size);
-	unsigned long p;
+	void *p = get_free_pages(GFP_KERNEL, order);
 
-	p = __get_free_pages(GFP_KERNEL, order);
 	if (!p) {
 		prom_printf("SUN4V: Error, cannot allocate queue.\n");
 		prom_halt();
arch/sparc/mm/iommu.c +3 -3
index f9d30bd..113dabf 100644
@@ -60,7 +60,7 @@ static void __init sbus_iommu_init(struct platform_device *op)
 	unsigned long *bitmap;
 	unsigned long control;
 	unsigned long base;
-	unsigned long tmp;
+	iopte_t *tmp;
 
 	iommu = kmalloc(sizeof(struct iommu_struct), GFP_KERNEL);
 	if (!iommu) {
@@ -91,13 +91,13 @@ static void __init sbus_iommu_init(struct platform_device *op)
 	   We need 256K or 512K or 1M or 2M area aligned to
            its size and current gfp will fortunately give
            it to us. */
-        tmp = __get_free_pages(GFP_KERNEL, IOMMU_ORDER);
+        tmp = get_free_pages(GFP_KERNEL, IOMMU_ORDER);
 	if (!tmp) {
 		prom_printf("Unable to allocate iommu table [0x%lx]\n",
 			    IOMMU_NPTES * sizeof(iopte_t));
 		prom_halt();
 	}
-	iommu->page_table = (iopte_t *)tmp;
+	iommu->page_table = tmp;
 
 	/* Initialize new table. */
 	memset(iommu->page_table, 0, IOMMU_NPTES*sizeof(iopte_t));
Signature · 1 line
2.1.4
author maintainer
#89 lore raw

PATCH 78/83 x86: switch to get_free_pages()

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/x86/kernel/tce_64.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/tce_64.c +3 -3
index ab40954..c6d5208 100644
@@ -98,7 +98,7 @@ static inline unsigned int table_size_to_number_of_entries(unsigned char size)
 static int tce_table_setparms(struct pci_dev *dev, struct iommu_table *tbl)
 {
 	unsigned int bitmapsz;
-	unsigned long bmppages;
+	unsigned long *bmppages;
 	int ret;
 
 	tbl->it_busno = dev->bus->number;
@@ -111,14 +111,14 @@ static int tce_table_setparms(struct pci_dev *dev, struct iommu_table *tbl)
 	 * entries; we need one bit per entry
 	 */
 	bitmapsz = tbl->it_size / BITS_PER_BYTE;
-	bmppages = __get_free_pages(GFP_KERNEL, get_order(bitmapsz));
+	bmppages = get_free_pages(GFP_KERNEL, get_order(bitmapsz));
 	if (!bmppages) {
 		printk(KERN_ERR "Calgary: cannot allocate bitmap\n");
 		ret = -ENOMEM;
 		goto done;
 	}
 
-	tbl->it_map = (unsigned long*)bmppages;
+	tbl->it_map = bmppages;
 
 	memset(tbl->it_map, 0, bitmapsz);
 
Signature · 1 line
2.1.4
author maintainer
#90 lore raw

PATCH 79/83 s390: turn suspend_zero_pages into a pointer

In reply to Al Viro

From: Al Viro <[email protected]>

---
 arch/s390/kernel/entry.h   | 2 +-
 arch/s390/kernel/suspend.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/s390/kernel/entry.h +1 -1
index b7019ab..612b35c 100644
@@ -7,7 +7,7 @@
 #include <asm/idle.h>
 
 extern void *restart_stack;
-extern unsigned long suspend_zero_pages;
+extern void *suspend_zero_pages;
 
 void system_call(void);
 void pgm_check_handler(void);
arch/s390/kernel/suspend.c +3 -3
index c40bdca..4ce1cc3 100644
@@ -41,7 +41,7 @@ struct page_key_data {
 static struct page_key_data *page_key_data;
 static struct page_key_data *page_key_rp, *page_key_wp;
 static unsigned long page_key_rx, page_key_wx;
-unsigned long suspend_zero_pages;
+void *suspend_zero_pages;
 
 /*
  * For each page in the hibernation image one additional byte is
@@ -163,13 +163,13 @@ static int suspend_pm_cb(struct notifier_block *nb, unsigned long action,
 	switch (action) {
 	case PM_SUSPEND_PREPARE:
 	case PM_HIBERNATION_PREPARE:
-		suspend_zero_pages = __get_free_pages(GFP_KERNEL, LC_ORDER);
+		suspend_zero_pages = get_free_pages(GFP_KERNEL, LC_ORDER);
 		if (!suspend_zero_pages)
 			return NOTIFY_BAD;
 		break;
 	case PM_POST_SUSPEND:
 	case PM_POST_HIBERNATION:
-		free_pages((void *)suspend_zero_pages, LC_ORDER);
+		free_pages(suspend_zero_pages, LC_ORDER);
 		break;
 	default:
 		return NOTIFY_DONE;
Signature · 1 line
2.1.4
author maintainer
#91 lore raw

PATCH 80/83 try to sort dvma types out

In reply to Al Viro

From: Al Viro <[email protected]>

[I've pretty much zero confidence in that one - if anything, it would need to be split]

---
 arch/m68k/include/asm/dvma.h             | 21 +++++--------
 arch/m68k/sun3/dvma.c                    | 31 ++++++++-----------
 arch/m68k/sun3/sun3dvma.c                | 52 ++++++++++++++------------------
 arch/m68k/sun3x/dvma.c                   | 15 +++------
 drivers/net/ethernet/i825xx/sun3_82586.c | 13 ++++----
 drivers/scsi/sun3_scsi.c                 | 23 ++++++--------
 6 files changed, 64 insertions(+), 91 deletions(-)
arch/m68k/include/asm/dvma.h +8 -13
index 890bbf7..1fa85e5 100644
@@ -16,18 +16,16 @@
 #define DVMA_PAGE_ALIGN(addr)	ALIGN(addr, DVMA_PAGE_SIZE)
 
 extern void dvma_init(void);
-extern int dvma_map_iommu(unsigned long kaddr, unsigned long baddr,
-			  int len);
+extern int dvma_map_iommu(void *kaddr, unsigned long baddr, int len);
 
 #define dvma_malloc(x) dvma_malloc_align(x, 0)
 #define dvma_map(x, y) dvma_map_align(x, y, 0)
 #define dvma_map_vme(x, y) (dvma_map(x, y) & 0xfffff)
 #define dvma_map_align_vme(x, y, z) (dvma_map_align (x, y, z) & 0xfffff)
-extern unsigned long dvma_map_align(unsigned long kaddr, int len,
-			    int align);
+extern unsigned long dvma_map_align(void *kaddr, int len, int align);
 extern void *dvma_malloc_align(unsigned long len, unsigned long align);
 
-extern void dvma_unmap(void *baddr);
+extern void dvma_unmap(unsigned long);
 extern void dvma_free(void *vaddr);
 
 
@@ -51,14 +49,13 @@ extern void dvma_free(void *vaddr);
 
 /* virt <-> phys conversions */
 #define dvma_vtop(x) ((unsigned long)(x) & 0xffffff)
-#define dvma_ptov(x) ((unsigned long)(x) | 0xf000000)
+#define dvma_ptov(x) ((void *)((unsigned long)(x) | 0xf000000))
 #define dvma_vtovme(x) ((unsigned long)(x) & 0x00fffff)
-#define dvma_vmetov(x) ((unsigned long)(x) | 0xff00000)
+#define dvma_vmetov(x) ((void*)((unsigned long)(x) | 0xff00000))
 #define dvma_vtob(x) dvma_vtop(x)
 #define dvma_btov(x) dvma_ptov(x)
 
-static inline int dvma_map_cpu(unsigned long kaddr, unsigned long vaddr,
-			       int len)
+static inline int dvma_map_cpu(void *kaddr, void *vaddr, int len)
 {
 	return 0;
 }
@@ -75,11 +72,9 @@ static inline int dvma_map_cpu(unsigned long kaddr, unsigned long vaddr,
 #define IOMMU_ENTRIES              (IOMMU_TOTAL_ENTRIES - 0x80)
 
 #define dvma_vtob(x) ((unsigned long)(x) & 0x00ffffff)
-#define dvma_btov(x) ((unsigned long)(x) | 0xff000000)
-
-extern int dvma_map_cpu(unsigned long kaddr, unsigned long vaddr, int len);
-
+#define dvma_btov(x) ((void *)((unsigned long)(x) | 0xff000000))
 
+extern int dvma_map_cpu(void *kaddr, void *vaddr, int len);
 
 /* everything below this line is specific to dma used for the onboard
    ESP scsi on sun3x */
arch/m68k/sun3/dvma.c +13 -18
index d95506e..0b0d352 100644
@@ -20,47 +20,42 @@
 
 static unsigned long ptelist[120];
 
-static unsigned long dvma_page(unsigned long kaddr, unsigned long vaddr)
+static void *dvma_page(void *kaddr, void *vaddr)
 {
 	unsigned long pte;
 	unsigned long j;
 	pte_t ptep;
+	int idx;
 
 	j = *(volatile unsigned long *)kaddr;
 	*(volatile unsigned long *)kaddr = j;
 
 	ptep = pfn_pte(virt_to_pfn(kaddr), PAGE_KERNEL);
 	pte = pte_val(ptep);
-//		printk("dvma_remap: addr %lx -> %lx pte %08lx len %x\n",
+//		printk("dvma_remap: addr %p -> %lx pte %08lx len %x\n",
 //		       kaddr, vaddr, pte, len);
-	if(ptelist[(vaddr & 0xff000) >> PAGE_SHIFT] != pte) {
-		sun3_put_pte(vaddr, pte);
-		ptelist[(vaddr & 0xff000) >> PAGE_SHIFT] = pte;
-	}
+	idx = ((unsigned long)vaddr & 0xff000) >> PAGE_SHIFT;
 
-	return (vaddr + (kaddr & ~PAGE_MASK));
+	if (ptelist[idx] != pte) {
+		sun3_put_pte((unsigned long)vaddr, pte);
+		ptelist[idx] = pte;
+	}
 
+	return vaddr + offset_in_page(kaddr);
 }
 
-int dvma_map_iommu(unsigned long kaddr, unsigned long baddr,
-			      int len)
+int dvma_map_iommu(void *kaddr, unsigned long baddr, int len)
 {
+	void *vaddr = dvma_btov(baddr);
+	void *end = vaddr + len;
 
-	unsigned long end;
-	unsigned long vaddr;
-
-	vaddr = dvma_btov(baddr);
-
-	end = vaddr + len;
-
-	while(vaddr < end) {
+	while (vaddr < end) {
 		dvma_page(kaddr, vaddr);
 		kaddr += PAGE_SIZE;
 		vaddr += PAGE_SIZE;
 	}
 
 	return 0;
-
 }
 
 void __init sun3_dvma_init(void)
arch/m68k/sun3/sun3dvma.c +23 -29

116 lines not on this page · raw message

arch/m68k/sun3x/dvma.c +5 -10
index d5ddcda..a85faa5 100644
@@ -79,18 +79,14 @@ void dvma_print (unsigned long dvma_addr)
 
 /* create a virtual mapping for a page assigned within the IOMMU
    so that the cpu can reach it easily */
-inline int dvma_map_cpu(unsigned long kaddr,
-			       unsigned long vaddr, int len)
+int dvma_map_cpu(void *k, void *v, int len)
 {
 	pgd_t *pgd;
-	unsigned long end;
+	unsigned long kaddr = (unsigned long)k & PAGE_MASK;
+	unsigned long vaddr = (unsigned long)v & PAGE_MASK;
+	unsigned long end = PAGE_ALIGN(vaddr + len);
 	int ret = 0;
 
-	kaddr &= PAGE_MASK;
-	vaddr &= PAGE_MASK;
-
-	end = PAGE_ALIGN(vaddr + len);
-
 #ifdef DEBUG
 	printk("dvma: mapping kern %08lx to virt %08lx\n",
 	       kaddr, vaddr);
@@ -148,8 +144,7 @@ inline int dvma_map_cpu(unsigned long kaddr,
 }
 
 
-inline int dvma_map_iommu(unsigned long kaddr, unsigned long baddr,
-				 int len)
+int dvma_map_iommu(void *kaddr, unsigned long baddr, int len)
 {
 	unsigned long end, index;
 
drivers/net/ethernet/i825xx/sun3_82586.c +6 -7
index 353f57f6..a9a279f 100644
@@ -131,7 +131,7 @@ static void    sun3_82586_dump(struct net_device *,void *);
 
 /* helper-functions */
 static int     init586(struct net_device *dev);
-static int     check586(struct net_device *dev,char *where,unsigned size);
+static int     check586(struct net_device *dev,unsigned long where,unsigned size);
 static void    alloc586(struct net_device *dev);
 static void    startrecv586(struct net_device *dev);
 static void   *alloc_rfa(struct net_device *dev,void *ptr);
@@ -203,7 +203,7 @@ static int sun3_82586_open(struct net_device *dev)
 /**********************************************
  * Check to see if there's an 82586 out there.
  */
-static int check586(struct net_device *dev,char *where,unsigned size)
+static int check586(struct net_device *dev,unsigned long where,unsigned size)
 {
 	struct priv pb;
 	struct priv *p = &pb;
@@ -211,7 +211,7 @@ static int check586(struct net_device *dev,char *where,unsigned size)
 	int i;
 
 	p->base = (unsigned long) dvma_btov(0);
-	p->memtop = (char *)dvma_btov((unsigned long)where);
+	p->memtop = dvma_btov(where);
 	p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
 	memset((char *)p->scp,0, sizeof(struct scp_struct));
 	for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
@@ -221,7 +221,7 @@ static int check586(struct net_device *dev,char *where,unsigned size)
 	if(p->scp->sysbus != SYSBUSVAL)
 		return 0;
 
-	iscp_addr = (char *)dvma_btov((unsigned long)where);
+	iscp_addr = dvma_btov(where);
 
 	p->iscp = (struct iscp_struct *) iscp_addr;
 	memset((char *)p->iscp,0, sizeof(struct iscp_struct));
@@ -366,14 +366,13 @@ static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
 		retval = -ENODEV;
 		goto out;
 	}
-	if(!check586(dev,(char *) dev->mem_start,size)) {
+	if(!check586(dev, dev->mem_start,size)) {
 		printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
 		retval = -ENODEV;
 		goto out;
 	}
 
-	((struct priv *)netdev_priv(dev))->memtop =
-					(char *)dvma_btov(dev->mem_start);
+	((struct priv *)netdev_priv(dev))->memtop = dvma_btov(dev->mem_start);
 	((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
 	alloc586(dev);
 
drivers/scsi/sun3_scsi.c +9 -14
index 22a4283..5cfc634 100644
@@ -100,7 +100,7 @@ static struct scsi_cmnd *sun3_dma_setup_done;
 static unsigned char *sun3_scsi_regp;
 static volatile struct sun3_dma_regs *dregs;
 static struct sun3_udc_regs *udc_regs;
-static unsigned char *sun3_dma_orig_addr = NULL;
+static unsigned long sun3_dma_orig_addr;
 static unsigned long sun3_dma_orig_count = 0;
 static int sun3_dma_active = 0;
 static unsigned long last_residual = 0;
@@ -237,15 +237,15 @@ void sun3_sun3_debug (void)
 /* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */
 static unsigned long sun3scsi_dma_setup(void *data, unsigned long count, int write_flag)
 {
-	void *addr;
+	unsigned long addr;
 
-	if(sun3_dma_orig_addr != NULL)
+	if (sun3_dma_orig_addr)
 		dvma_unmap(sun3_dma_orig_addr);
 
 #ifdef SUN3_SCSI_VME
-	addr = (void *)dvma_map_vme((unsigned long) data, count);
+	addr = dvma_map_vme(data, count);
 #else
-	addr = (void *)dvma_map((unsigned long) data, count);
+	addr = dvma_map(data, count);
 #endif
 		
 	sun3_dma_orig_addr = addr;
@@ -399,9 +399,7 @@ static int sun3scsi_dma_finish(int write_flag)
 	last_residual = fifo;
 	/* empty bytes from the fifo which didn't make it */
 	if ((!write_flag) && (dregs->csr & CSR_LEFT)) {
-		unsigned char *vaddr;
-
-		vaddr = (unsigned char *)dvma_vmetov(sun3_dma_orig_addr);
+		unsigned char *vaddr = dvma_vmetov(sun3_dma_orig_addr);
 
 		vaddr += (sun3_dma_orig_count - fifo);
 		vaddr--;
@@ -444,11 +442,8 @@ static int sun3scsi_dma_finish(int write_flag)
 
 	/* empty bytes from the fifo which didn't make it */
 	if((!write_flag) && (count - fifo) == 2) {
-		unsigned short data;
-		unsigned char *vaddr;
-
-		data = dregs->fifo_data;
-		vaddr = (unsigned char *)dvma_btov(sun3_dma_orig_addr);
+		unsigned short data = dregs->fifo_data;
+		unsigned char *vaddr = dvma_btov(sun3_dma_orig_addr);
 		
 		vaddr += (sun3_dma_orig_count - fifo);
 
@@ -458,7 +453,7 @@ static int sun3scsi_dma_finish(int write_flag)
 #endif
 
 	dvma_unmap(sun3_dma_orig_addr);
-	sun3_dma_orig_addr = NULL;
+	sun3_dma_orig_addr = 0;
 
 #ifdef SUN3_SCSI_VME
 	dregs->dma_addr_hi = 0;
Signature · 1 line
2.1.4
author maintainer
#92 lore raw

PATCH 81/83 sba_iommu: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

---
 drivers/parisc/sba_iommu.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/parisc/sba_iommu.c +14 -14
index 10ca71d..a6e76ba 100644
@@ -1113,11 +1113,11 @@ PAT_MOD(mod)->mod_info.ioc         = PAT_GET_IOC(temp);
 static void *
 sba_alloc_pdir(unsigned int pdir_size)
 {
-        unsigned long pdir_base;
+        void *pdir_base;
 	unsigned long pdir_order = get_order(pdir_size);
 
-	pdir_base = __get_free_pages(GFP_KERNEL, pdir_order);
-	if (NULL == (void *) pdir_base)	{
+	pdir_base = get_free_pages(GFP_KERNEL, pdir_order);
+	if (!pdir_base)	{
 		panic("%s() could not allocate I/O Page Table\n",
 			__func__);
 	}
@@ -1131,7 +1131,7 @@ sba_alloc_pdir(unsigned int pdir_size)
 	if ( ((boot_cpu_data.pdc.cpuid >> 5) & 0x7f) != 0x13
 			|| (boot_cpu_data.pdc.versions > 0x202)
 			|| (boot_cpu_data.pdc.capabilities & 0x08L) )
-		return (void *) pdir_base;
+		return pdir_base;
 
 	/*
 	 * PA8700 (PCX-W2, aka piranha) silent data corruption fix
@@ -1154,16 +1154,16 @@ sba_alloc_pdir(unsigned int pdir_size)
 	if (pdir_order <= (19-12)) {
 		if (((virt_to_phys(pdir_base)+pdir_size-1) & PIRANHA_ADDR_MASK) == PIRANHA_ADDR_VAL) {
 			/* allocate a new one on 512k alignment */
-			unsigned long new_pdir = __get_free_pages(GFP_KERNEL, (19-12));
+			void *new_pdir = get_free_pages(GFP_KERNEL, (19-12));
 			/* release original */
-			free_pages((void *)pdir_base, pdir_order);
+			free_pages(pdir_base, pdir_order);
 
 			pdir_base = new_pdir;
 
 			/* release excess */
 			while (pdir_order < (19-12)) {
 				new_pdir += pdir_size;
-				free_pages((void *)new_pdir, pdir_order);
+				free_pages(new_pdir, pdir_order);
 				pdir_order +=1;
 				pdir_size <<=1;
 			}
@@ -1173,13 +1173,13 @@ sba_alloc_pdir(unsigned int pdir_size)
 		** 1MB or 2MB Pdir
 		** Needs to be aligned on an "odd" 1MB boundary.
 		*/
-		unsigned long new_pdir = __get_free_pages(GFP_KERNEL, pdir_order+1); /* 2 or 4MB */
+		void *new_pdir = get_free_pages(GFP_KERNEL, pdir_order+1); /* 2 or 4MB */
 
 		/* release original */
-		free_pages((void *)pdir_base, pdir_order);
+		free_pages(pdir_base, pdir_order);
 
 		/* release first 1MB */
-		free_pages((void *)new_pdir, 20-12);
+		free_pages(new_pdir, 20-12);
 
 		pdir_base = new_pdir + 1024*1024;
 
@@ -1194,17 +1194,17 @@ sba_alloc_pdir(unsigned int pdir_size)
 
 			new_pdir += 3*1024*1024;
 			/* release last 1MB */
-			free_pages((void *)new_pdir, 20-12);
+			free_pages(new_pdir, 20-12);
 
 			/* release unusable 128KB */
-			free_pages((void *)new_pdir - 128*1024 , 17-12);
+			free_pages(new_pdir - 128*1024 , 17-12);
 
 			pdir_size -= 128*1024;
 		}
 	}
 
-	memset((void *) pdir_base, 0, pdir_size);
-	return (void *) pdir_base;
+	memset(pdir_base, 0, pdir_size);
+	return pdir_base;
 }
 
 struct ibase_data_struct {
Signature · 1 line
2.1.4
author maintainer
#93 lore raw

PATCH 82/83 media/platform/omap: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

Keep ->smsshado_virt_addrp[] and ->buf_virt_addr[] as pointers. Note that this stuff is 32bit-only, so both unsigned int and unsigned long are pointer-sized...

---
 drivers/media/platform/omap/omap_vout.c      | 26 ++++++++++++++------------
 drivers/media/platform/omap/omap_vout_vrfb.c |  6 +++---
 drivers/media/platform/omap/omap_voutdef.h   |  4 ++--
 drivers/media/platform/omap/omap_voutlib.c   | 15 +++++++--------
 drivers/media/platform/omap/omap_voutlib.h   |  4 ++--
 5 files changed, 28 insertions(+), 27 deletions(-)
drivers/media/platform/omap/omap_vout.c +14 -12
index 70c28d1..3e298d8 100644
@@ -240,7 +240,7 @@ void omap_vout_free_buffers(struct omap_vout_device *vout)
 		omap_vout_free_buffer(vout->buf_virt_addr[i],
 				vout->buffer_size);
 		vout->buf_phy_addr[i] = 0;
-		vout->buf_virt_addr[i] = 0;
+		vout->buf_virt_addr[i] = NULL;
 	}
 }
 
@@ -656,7 +656,8 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
 			  unsigned int *size)
 {
 	int startindex = 0, i, j;
-	u32 phy_addr = 0, virt_addr = 0;
+	u32 phy_addr = 0;
+	void *virt_addr = NULL;
 	struct omap_vout_device *vout = q->priv_data;
 	struct omapvideo_info *ovid = &vout->vid_info;
 	int vid_max_buf_size;
@@ -712,7 +713,7 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
 				omap_vout_free_buffer(
 						vout->smsshado_virt_addr[j],
 						vout->smsshado_size);
-				vout->smsshado_virt_addr[j] = 0;
+				vout->smsshado_virt_addr[j] = NULL;
 				vout->smsshado_phy_addr[j] = 0;
 				}
 			}
@@ -741,7 +742,7 @@ static void omap_vout_free_extra_buffers(struct omap_vout_device *vout)
 			omap_vout_free_buffer(vout->buf_virt_addr[i],
 					vout->buffer_size);
 
-		vout->buf_virt_addr[i] = 0;
+		vout->buf_virt_addr[i] = NULL;
 		vout->buf_phy_addr[i] = 0;
 	}
 	vout->buffer_allocated = num_buffers;
@@ -782,13 +783,14 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
 		if (ret < 0)
 			return ret;
 	} else {
-		unsigned long addr, dma_addr;
+		void *addr;
+		unsigned long dma_addr;
 		unsigned long size;
 
-		addr = (unsigned long) vout->buf_virt_addr[vb->i];
+		addr = vout->buf_virt_addr[vb->i];
 		size = (unsigned long) vb->size;
 
-		dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr,
+		dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, addr,
 				size, DMA_TO_DEVICE);
 		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
 			v4l2_err(&vout->vid_dev->v4l2_dev, "dma_map_single failed\n");
@@ -913,11 +915,11 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma)
 	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
 	vma->vm_ops = &omap_vout_vm_ops;
 	vma->vm_private_data = (void *) vout;
-	pos = (void *)vout->buf_virt_addr[i];
-	vma->vm_pgoff = virt_to_phys((void *)pos) >> PAGE_SHIFT;
+	pos = vout->buf_virt_addr[i];
+	vma->vm_pgoff = virt_to_phys(pos) >> PAGE_SHIFT;
 	while (size > 0) {
 		unsigned long pfn;
-		pfn = virt_to_phys((void *) pos) >> PAGE_SHIFT;
+		pfn = virt_to_phys(pos) >> PAGE_SHIFT;
 		if (remap_pfn_range(vma, start, pfn, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 		start += PAGE_SIZE;
@@ -1501,7 +1503,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 		for (i = num_buffers; i < vout->buffer_allocated; i++) {
 			omap_vout_free_buffer(vout->buf_virt_addr[i],
 					vout->buffer_size);
-			vout->buf_virt_addr[i] = 0;
+			vout->buf_virt_addr[i] = NULL;
 			vout->buf_phy_addr[i] = 0;
 		}
 		vout->buffer_allocated = num_buffers;
@@ -1979,7 +1981,7 @@ free_buffers:
 	for (i = 0; i < numbuffers; i++) {
 		omap_vout_free_buffer(vout->buf_virt_addr[i],
 						vout->buffer_size);
-		vout->buf_virt_addr[i] = 0;
+		vout->buf_virt_addr[i] = NULL;
 		vout->buf_phy_addr[i] = 0;
 	}
 	return ret;
drivers/media/platform/omap/omap_vout_vrfb.c +3 -3
index c6e2527..1c89189 100644
@@ -48,13 +48,13 @@ static int omap_vout_allocate_vrfb_buffers(struct omap_vout_device *vout,
 				omap_vout_free_buffer(
 						vout->smsshado_virt_addr[j],
 						vout->smsshado_size);
-				vout->smsshado_virt_addr[j] = 0;
+				vout->smsshado_virt_addr[j] = NULL;
 				vout->smsshado_phy_addr[j] = 0;
 			}
 			*count = 0;
 			return -ENOMEM;
 		}
-		memset((void *) vout->smsshado_virt_addr[i], 0,
+		memset(vout->smsshado_virt_addr[i], 0,
 				vout->smsshado_size);
 	}
 	return 0;
@@ -81,7 +81,7 @@ void omap_vout_free_vrfb_buffers(struct omap_vout_device *vout)
 	for (j = 0; j < VRFB_NUM_BUFS; j++) {
 		omap_vout_free_buffer(vout->smsshado_virt_addr[j],
 				vout->smsshado_size);
-		vout->smsshado_virt_addr[j] = 0;
+		vout->smsshado_virt_addr[j] = NULL;
 		vout->smsshado_phy_addr[j] = 0;
 	}
 }
drivers/media/platform/omap/omap_voutdef.h +2 -2
index 9ccfe1f..d298d1a 100644
@@ -126,7 +126,7 @@ struct omap_vout_device {
 	/* allow to reuse previously allocated buffer which is big enough */
 	int buffer_size;
 	/* keep buffer info across opens */
-	unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
+	void *buf_virt_addr[VIDEO_MAX_FRAME];
 	unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
 	enum omap_color_mode dss_mode;
 
@@ -161,7 +161,7 @@ struct omap_vout_device {
 
 	struct vid_vrfb_dma vrfb_dma_tx;
 	unsigned int smsshado_phy_addr[MAC_VRFB_CTXS];
-	unsigned int smsshado_virt_addr[MAC_VRFB_CTXS];
+	void *smsshado_virt_addr[MAC_VRFB_CTXS];
 	struct vrfb vrfb_context[MAC_VRFB_CTXS];
 	bool vrfb_static_allocation;
 	unsigned int smsshado_size;
drivers/media/platform/omap/omap_voutlib.c +7 -8
index f8cf63a..afce476 100644
@@ -298,15 +298,14 @@ EXPORT_SYMBOL_GPL(omap_vout_new_format);
 /*
  * Allocate buffers
  */
-unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
+void *omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
 {
 	u32 order, size;
-	unsigned long virt_addr, addr;
+	void *virt_addr, *addr;
 
 	size = PAGE_ALIGN(buf_size);
 	order = get_order(size);
-	virt_addr = __get_free_pages(GFP_KERNEL, order);
-	addr = virt_addr;
+	addr = virt_addr = get_free_pages(GFP_KERNEL, order);
 
 	if (virt_addr) {
 		while (size > 0) {
@@ -315,17 +314,17 @@ unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr)
 			size -= PAGE_SIZE;
 		}
 	}
-	*phys_addr = (u32) virt_to_phys((void *) virt_addr);
+	*phys_addr = (u32) virt_to_phys(virt_addr);
 	return virt_addr;
 }
 
 /*
  * Free buffers
  */
-void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size)
+void omap_vout_free_buffer(void *virtaddr, u32 buf_size)
 {
 	u32 order, size;
-	unsigned long addr = virtaddr;
+	void *addr = virtaddr;
 
 	size = PAGE_ALIGN(buf_size);
 	order = get_order(size);
@@ -335,7 +334,7 @@ void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size)
 		addr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
-	free_pages((void *)virtaddr, order);
+	free_pages(virtaddr, order);
 }
 
 bool omap_vout_dss_omap24xx(void)
drivers/media/platform/omap/omap_voutlib.h +2 -2
index f9d1c07..c62894e 100644
@@ -30,8 +30,8 @@ int omap_vout_new_window(struct v4l2_rect *crop,
 void omap_vout_new_format(struct v4l2_pix_format *pix,
 		struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop,
 		struct v4l2_window *win);
-unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr);
-void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size);
+void *omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr);
+void omap_vout_free_buffer(void *virtaddr, u32 buf_size);
 
 bool omap_vout_dss_omap24xx(void);
 bool omap_vout_dss_omap34xx(void);
Signature · 1 line
2.1.4
author maintainer
#94 lore raw

PATCH 83/83 nios2: get rid of pointless casts

In reply to Al Viro

From: Al Viro <[email protected]>

flush_icache_range() really looks like a candidate for conversion to taking void * as arguments...

---
 arch/nios2/mm/init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/nios2/mm/init.c +4 -4
index e03a757..b76ad1d 100644
@@ -103,16 +103,16 @@ static int alloc_kuser_page(void)
 {
 	extern char __kuser_helper_start[], __kuser_helper_end[];
 	int kuser_sz = __kuser_helper_end - __kuser_helper_start;
-	unsigned long vpage;
+	void *vpage = get_zeroed_page(GFP_ATOMIC);
 
-	vpage = (unsigned long)get_zeroed_page(GFP_ATOMIC);
 	if (!vpage)
 		return -ENOMEM;
 
 	/* Copy kuser helpers */
-	memcpy((void *)vpage, __kuser_helper_start, kuser_sz);
+	memcpy(vpage, __kuser_helper_start, kuser_sz);
 
-	flush_icache_range(vpage, vpage + KUSER_SIZE);
+	flush_icache_range((unsigned long)vpage,
+			   (unsigned long)vpage + KUSER_SIZE);
 	kuser_page[0] = virt_to_page(vpage);
 
 	return 0;
Signature · 1 line
2.1.4