History

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 33dd4e0ec911 "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.

Ian Campbell committed 15 years ago

Commit aa462ab1 parent f9918792 files · +4 −4Browse files

Unified · Split

2 files
  1. include/asm-generic/memory_model.h +2 −2
  2. include/linux/mm.h +2 −2
include/asm-generic/memory_model.h+2−2
@@ -39,7 +39,7 @@ · 38 unmodified lines
39})39})
40 40
41#define __page_to_pfn(pg) \41#define __page_to_pfn(pg) \
42({ struct page *__pg = (pg); \42({ const struct page *__pg = (pg); \
43 struct pglist_data *__pgdat = NODE_DATA(page_to_nid(__pg)); \43 struct pglist_data *__pgdat = NODE_DATA(page_to_nid(__pg)); \
44 (unsigned long)(__pg - __pgdat->node_mem_map) + \44 (unsigned long)(__pg - __pgdat->node_mem_map) + \
45 __pgdat->node_start_pfn; \45 __pgdat->node_start_pfn; \
@@ -57,7 +57,7 @@ · 11 unmodified lines
57 * section[i].section_mem_map == mem_map's address - start_pfn;57 * section[i].section_mem_map == mem_map's address - start_pfn;
58 */58 */
59#define __page_to_pfn(pg) \59#define __page_to_pfn(pg) \
60({ struct page *__pg = (pg); \60({ const struct page *__pg = (pg); \
61 int __sec = page_to_section(__pg); \61 int __sec = page_to_section(__pg); \
62 (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); \62 (unsigned long)(__pg - __section_mem_map_addr(__nr_to_section(__sec))); \
63})63})
include/linux/mm.h+2−2
@@ -685,7 +685,7 @@ static inline void set_page_section(struct page *page, unsigned long section) · 684 unmodified lines
685 page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;685 page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT;
686}686}
687 687
688static inline unsigned long page_to_section(struct page *page)688static inline unsigned long page_to_section(const struct page *page)
689{689{
690 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;690 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
691}691}
@@ -720,7 +720,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, · 28 unmodified lines
720 720
721static __always_inline void *lowmem_page_address(const struct page *page)721static __always_inline void *lowmem_page_address(const struct page *page)
722{722{
723 return __va(PFN_PHYS(page_to_pfn((struct page *)page)));723 return __va(PFN_PHYS(page_to_pfn(page)));
724}724}
725 725
726#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)726#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)