got_patcher: use new dentry manipulation interface 31/191031/2
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 1 Oct 2018 09:01:43 +0000 (12:01 +0300)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 11 Oct 2018 18:54:03 +0000 (21:54 +0300)
Change-Id: I7dbc355c8ef6c3e82582118c015ecfcb3f128a9a
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
modules/got_patcher/gt_module.c

index 3d9b2e6..32e48c1 100644 (file)
@@ -10,7 +10,7 @@
 #include <us_manager/sspt/sspt_file.h>
 #include <us_manager/sspt/sspt_ip.h>
 #include <us_manager/probes/probe_info_new.h>
-#include <us_manager/us_common_file.h>
+#include <us_manager/swap_dcache.h>
 #include <loader/loader.h>
 #include <master/swap_initializer.h>
 #include "gt.h"
@@ -485,7 +485,7 @@ static void _destroy_linker_probe_el_no_lock(struct l_probe_el *l_probe)
                put_pf_group(l_probe->pfg);
 
        if (l_probe->task_id == GT_SET_BY_DENTRY && l_probe->dentry != NULL)
-               swap_put_dentry(l_probe->dentry);
+               swap_dput(l_probe->dentry);
 
        if (l_probe->task_id == GT_SET_BY_ID && l_probe->id != NULL)
                kfree(l_probe->id);
@@ -665,21 +665,17 @@ int gtm_set_linker_path(char *path)
 {
        struct dentry *dentry;
 
-       dentry = swap_get_dentry(path);
+       dentry = swap_dget_by_path(path);
        if (dentry == NULL)
                return -EINVAL;
 
-       /* We use get_dentry only once, so use put dentry also only once */
-       if (_linker_fixup.dentry != NULL ||
-           _linker_reloc.dentry != NULL) {
-               if (_linker_fixup.dentry != NULL)
-                       swap_put_dentry(_linker_fixup.dentry);
-               else
-                       swap_put_dentry(_linker_reloc.dentry);
-       }
-
+       /* update fixup dentry */
+       swap_dput(_linker_fixup.dentry);
        _linker_fixup.dentry = dentry;
-       _linker_reloc.dentry = dentry;
+
+       /* update reloc dentry */
+       swap_dput(_linker_reloc.dentry);
+       _linker_reloc.dentry = swap_dget(dentry);
 
        return 0;
 }
@@ -728,7 +724,7 @@ int gtm_add_by_path(char *path)
        struct l_probe_el *l_probe;
        int ret;
 
-       dentry = swap_get_dentry(path);
+       dentry = swap_dget_by_path(path);
        if (dentry == NULL)
                return -EINVAL;
 
@@ -761,7 +757,7 @@ add_by_path_put_pfg:
        put_pf_group(pfg);
 
 add_by_path_put_dentry:
-       swap_put_dentry(dentry);
+       swap_dput(dentry);
 
        return ret;
 }
@@ -855,7 +851,7 @@ int gtm_del_by_path(char *path)
        struct dentry *dentry;
        int ret = 0;
 
-       dentry = swap_get_dentry(path);
+       dentry = swap_dget_by_path(path);
        if (dentry == NULL)
                return -EINVAL;
 
@@ -939,19 +935,17 @@ int gtm_set_handler_path(char *path)
        struct dentry *dentry;
        int ret;
 
-       /* We use get_dentry only once, so use put dentry also only once */
-       dentry = swap_get_dentry(path);
+       dentry = swap_dget_by_path(path);
        if (dentry == NULL)
                return -EINVAL;
 
-       if (_handler_fixup.dentry)
-               swap_put_dentry(_handler_fixup.dentry);
-
-       if (_handler_reloc.dentry)
-               swap_put_dentry(_handler_reloc.dentry);
-
+       /* update fixup dentry */
+       swap_dput(_handler_fixup.dentry);
        _handler_fixup.dentry = dentry;
-       _handler_reloc.dentry = dentry;
+
+       /* update reloc dentry */
+       swap_dput(_handler_reloc.dentry);
+       _handler_reloc.dentry = swap_dget(dentry);
 
        /* TODO Do smth with this:
         * make interface for loader to remove handlers
@@ -980,13 +974,11 @@ int gtm_set_pthread_path(char *path)
 {
        struct dentry *dentry;
 
-       dentry = swap_get_dentry(path);
+       dentry = swap_dget_by_path(path);
        if (dentry == NULL)
                return -EINVAL;
 
-       if (_pthread_init.dentry != NULL)
-               swap_put_dentry(_pthread_init.dentry);
-
+       swap_dput(_pthread_init.dentry);
        _pthread_init.dentry = dentry;
 
        return 0;
@@ -1027,16 +1019,11 @@ static void gtm_exit(void)
 
        _clean_linker_probes();
 
-       /* We use get_dentry only once, so use put dentry also only once */
-       if (_handler_fixup.dentry != NULL ||
-           _handler_reloc.dentry != NULL) {
-               if (_handler_fixup.dentry != NULL)
-                       swap_put_dentry(_handler_fixup.dentry);
-               else
-                       swap_put_dentry(_handler_reloc.dentry);
-               _handler_reloc.dentry = NULL;
-               _handler_fixup.dentry = NULL;
-       }
+       swap_dput(_handler_fixup.dentry);
+       _handler_fixup.dentry = NULL;
+
+       swap_dput(_handler_reloc.dentry);
+       _handler_reloc.dentry = NULL;
 }
 
 SWAP_LIGHT_INIT_MODULE(NULL, gtm_init, gtm_exit, NULL, NULL);