master: add modules initialization errors to kernel log 50/170150/6 submit/tizen/20180219.090508
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Tue, 13 Feb 2018 18:12:03 +0000 (21:12 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 15 Feb 2018 14:59:22 +0000 (17:59 +0300)
Change-Id: I796e23c1e5ef933a8f0e043d5c5d8e1e3548217e
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
modules/master/swap_initializer.c
modules/master/swap_initializer.h

index a7ea8c356715fb999892a25fb70161159a5309b1..f8f562657ec2f755ee31a6b134430fa53a39babd 100644 (file)
  */
 
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+
+#include <linux/bug.h>
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
@@ -34,6 +38,19 @@ enum init_level {
        IL_FS
 };
 
+static const char *level_name(enum init_level level)
+{
+       switch (level) {
+       case IL_CORE:
+               return "core";
+       case IL_FS:
+               return "fs";
+       }
+
+       BUG();
+}
+
+
 static swap_init_t sis_get_fn_init(struct swap_init_struct *init,
                                   enum init_level level)
 {
@@ -94,8 +111,11 @@ static int sis_once(struct swap_init_struct *init)
                int ret;
 
                ret = once();
-               if (ret)
+               if (ret) {
+                       pr_err("Cannot init %s.once(), ret=%d, %pS\n",
+                              init->name, ret, once);
                        return ret;
+               }
 
                init->once_flag = true;
        }
@@ -108,14 +128,20 @@ static int sis_init_level(struct swap_init_struct *init, enum init_level level)
        int ret;
        swap_init_t fn;
 
-       if (sis_get_flag(init, level))
+       if (sis_get_flag(init, level)) {
+               pr_err("Module %s:%s already init\n",
+                      init->name, level_name(level));
                return -EPERM;
+       }
 
        fn = sis_get_fn_init(init, level);
        if (fn) {
                ret = fn();
-               if (ret)
+               if (ret) {
+                       pr_err("Cannot init %s:%s_init(), ret=%d %pS\n",
+                              init->name, level_name(level), ret, fn);
                        return ret;
+               }
        }
 
        sis_set_flag(init, level, true);
index 6e6f047f2db6eba907181d37a5dba0301761729a..1ae1c5bf77a35f338961d3c186edc200726bf76a 100644 (file)
@@ -53,6 +53,7 @@ struct swap_init_struct {
        swap_uninit_t fs_uninit;
 
        /* private fields */
+       const char *name;
        struct list_head list;
        unsigned once_flag:1;
        unsigned core_flag:1;
@@ -80,6 +81,7 @@ void swap_init_unregister(struct swap_init_struct *init);
                .core_uninit = _uninit,                                 \
                .fs_init = _fs_init,                                    \
                .fs_uninit = _fs_uninit,                                \
+               .name = KBUILD_MODNAME,                                 \
                .list = LIST_HEAD_INIT(__init_struct.list),             \
                .once_flag = false,                                     \
                .core_flag = false,                                     \