lkml.org 
[lkml]   [2010]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
On Mon, 1 Feb 2010 09:52:35 am Siarhei Liakh wrote:
> +/*
> + * Given BASE and SIZE this macro calculates the number of pages the
> + * memory regions occupies
> + */
> +#define NUMBER_OF_PAGES(BASE, SIZE) ((SIZE > 0) ? \
> + (PFN_DOWN((unsigned long)BASE + SIZE - 1) - \
> + PFN_DOWN((unsigned long)BASE) + 1) \
> + : (0UL))

Needs more brackets around arguments, otherwise someone calling it with
a complex expression will get very upset.

Or just replace with a static inline function?

> + if ((mod->module_core) && (mod->core_text_size > 0)) {

The core_text_size test should be enough here.

> + begin_pfn = PFN_DOWN((unsigned long)mod->module_core);
> + end_pfn = PFN_DOWN((unsigned long)mod->module_core +
> + mod->core_text_size);
> + if (end_pfn > begin_pfn)
> + set_memory_rw(begin_pfn << PAGE_SHIFT,
> + end_pfn - begin_pfn);

Much of this code might be neater if you created a helper:

void set_page_attributes(void *start, void *end,
void (*set)(unsigned long start, unsigned long num_pages))
{
unsigned long begin_pfn = PFN_DOWN((unsigned long)start);
unsigned long end_pfn = PFN_DOWN((unsigned long)end);
if (end_pfn > begin_pfn)
set(begin_pfn << PAGE_SHIFT, end_pfn - begin_pfn);
}

But these are minor: patch looks good!

Thanks,
Rusty.


\
 
 \ /
  Last update: 2010-02-01 02:40    [W:0.031 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site