• Ganesh Mahendran's avatar
    mm/zsmalloc: adjust order of functions · 66cdef66
    Ganesh Mahendran authored
    Currently functions in zsmalloc.c does not arranged in a readable and
    reasonable sequence.  With the more and more functions added, we may
    meet below inconvenience.  For example:
    
    Current functions:
    
        void zs_init()
        {
        }
    
        static void get_maxobj_per_zspage()
        {
        }
    
    Then I want to add a func_1() which is called from zs_init(), and this
    new added function func_1() will used get_maxobj_per_zspage() which is
    defined below zs_init().
    
        void func_1()
        {
            get_maxobj_per_zspage()
        }
    
        void zs_init()
        {
            func_1()
        }
    
        static void get_maxobj_per_zspage()
        {
        }
    
    This will cause compiling issue. So we must add a declaration:
    
        static void get_maxobj_per_zspage();
    
    before func_1() if we do not put get_maxobj_per_zspage() before
    func_1().
    
    In addition, puting module_[init|exit] functions at the bottom of the
    file conforms to our habit.
    
    So, this patch ajusts function sequence as:
    
        /* helper functions */
        ...
        obj_location_to_handle()
        ...
    
        /* Some exported functions */
        ...
    
        zs_map_object()
        zs_unmap_object()
    
        zs_malloc()
        zs_free()
    
        zs_init()
        zs_exit()
    Signed-off-by: default avatarGanesh Mahendran <opensource.ganesh@gmail.com>
    Cc: Nitin Gupta <ngupta@vflare.org>
    Acked-by: default avatarMinchan Kim <minchan@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    66cdef66
zsmalloc.c 31.9 KB