lkml.org 
[lkml]   [2002]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch] vmalloc_to_page() backport for 2.4
      Hi,

    This is a 2.4.x backport of the new 2.5.x vmalloc_to_page() function.
    I'd like to see that function in 2.4.x too because it makes driver
    maintaining easier.

    Gerd

    ==============================[ cut here ]==============================
    --- linux-2.4.19-pre3/include/linux/mm.h Tue Mar 12 09:59:02 2002
    +++ linux/include/linux/mm.h Tue Mar 12 18:15:02 2002
    @@ -670,6 +670,8 @@

    extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);

    +extern struct page * vmalloc_to_page(void *addr);
    +
    #endif /* __KERNEL__ */

    #endif
    --- linux-2.4.19-pre3/kernel/ksyms.c Tue Mar 12 10:00:44 2002
    +++ linux/kernel/ksyms.c Tue Mar 12 10:00:44 2002
    @@ -108,6 +108,7 @@
    EXPORT_SYMBOL(kfree);
    EXPORT_SYMBOL(vfree);
    EXPORT_SYMBOL(__vmalloc);
    +EXPORT_SYMBOL_GPL(vmalloc_to_page);
    EXPORT_SYMBOL(mem_map);
    EXPORT_SYMBOL(remap_page_range);
    EXPORT_SYMBOL(max_mapnr);
    --- linux-2.4.19-pre3/mm/memory.c Tue Mar 12 09:59:02 2002
    +++ linux/mm/memory.c Tue Mar 12 10:00:44 2002
    @@ -1471,3 +1471,24 @@
    len, write, 0, NULL, NULL);
    return ret == len ? 0 : -1;
    }
    +
    +struct page * vmalloc_to_page(void * vmalloc_addr)
    +{
    + unsigned long addr = (unsigned long) vmalloc_addr;
    + struct page *page = NULL;
    + pmd_t *pmd;
    + pte_t *pte;
    + pgd_t *pgd;
    +
    + pgd = pgd_offset_k(addr);
    + if (!pgd_none(*pgd)) {
    + pmd = pmd_offset(pgd, addr);
    + if (!pmd_none(*pmd)) {
    + pte = pte_offset(pmd, addr);
    + if (pte_present(*pte)) {
    + page = pte_page(*pte);
    + }
    + }
    + }
    + return page;
    +}
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2005-03-22 13:21    [W:0.021 / U:31.672 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site