Skip to content

Commit aa462ab

Browse files
Ian Campbelltorvalds
authored andcommitted
mm: fix __page_to_pfn for a const struct page argument
This allows the cast in lowmem_page_address (introduced as a warning fixup to 33dd4e0 "mm: make some struct page's const") to be removed. Propagate const'ness to page_to_section() as well since it is required by __page_to_pfn. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Rik van Riel <riel@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Michel Lespinasse <walken@google.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f991879 commit aa462ab

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎include/asm-generic/memory_model.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
})
4040

4141
#define __page_to_pfn(pg) \
42-
({ struct page *__pg = (pg); \
42+
({ const struct page *__pg = (pg); \
4343
struct pglist_data *__pgdat = NODE_DATA(page_to_nid(__pg)); \
4444
(unsigned long)(__pg - __pgdat->node_mem_map) + \
4545
__pgdat->node_start_pfn; \
@@ -57,7 +57,7 @@
5757
* section[i].section_mem_map == mem_map's address - start_pfn;
5858
*/
5959
#define __page_to_pfn(pg) \
60-
({ struct page *__pg = (pg); \
60+
({ const struct page *__pg = (pg); \
6161
int __sec = page_to_section(__pg); \
6262
(unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); \
6363
})

‎include/linux/mm.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ static inline void set_page_section(struct page *page, unsigned long section)
685685
page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
686686
}
687687

688-
static inline unsigned long page_to_section(struct page *page)
688+
static inline unsigned long page_to_section(const struct page *page)
689689
{
690690
return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
691691
}
@@ -720,7 +720,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
720720

721721
static __always_inline void *lowmem_page_address(const struct page *page)
722722
{
723-
return __va(PFN_PHYS(page_to_pfn((struct page *)page)));
723+
return __va(PFN_PHYS(page_to_pfn(page)));
724724
}
725725

726726
#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)

0 commit comments

Comments
 (0)