tbm_bufmgr: move copy functions for module information to tbm_bufmgr 05/259705/1
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 10 Jun 2021 23:56:31 +0000 (08:56 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 11 Jun 2021 00:50:04 +0000 (09:50 +0900)
The copy function for module information is moved from tbm_module to
tbm_bufmgr.

Change-Id: I99d0910042020839ce7efd728a5cb7127bd9f6f8

src/tbm_bufmgr.c
src/tbm_module.c

index d455e0a..ec13191 100644 (file)
@@ -168,6 +168,41 @@ _tbm_util_get_appname_from_pid(long pid, char *str)
        snprintf(str, sizeof(cmdline), "%s", cmdline);
 }
 
+static void
+_tbm_bufmgr_copy_module_data(tbm_bufmgr bufmgr, tbm_module *module, int reset)
+{
+       if (!reset) {
+               bufmgr->module_data = module->module_data;
+               bufmgr->backend = module->backend;
+
+               bufmgr->backend_module_data = module->backend_module_data;
+               bufmgr->bufmgr_data = module->bufmgr_data;
+               bufmgr->bufmgr_func = module->bufmgr_func;
+               bufmgr->bo_func = module->bo_func;
+
+               bufmgr->use_hal_tbm = module->use_hal_tbm;
+               bufmgr->auth_wl_socket_created = module->auth_wl_socket_created;
+               bufmgr->auth_fd = module->auth_fd;
+               bufmgr->hal_backend = module->hal_backend;
+               bufmgr->hal_bufmgr = module->hal_bufmgr;
+       } else {
+               bufmgr->module_data = NULL;
+               bufmgr->backend = NULL;
+
+               bufmgr->backend_module_data = NULL;
+               bufmgr->bufmgr_data = NULL;
+               bufmgr->bufmgr_func = NULL;
+               bufmgr->bo_func = NULL;
+
+               bufmgr->use_hal_tbm = 0;
+               bufmgr->auth_wl_socket_created = 0;
+               bufmgr->auth_fd = -1;
+               bufmgr->hal_backend = NULL;
+               bufmgr->hal_bufmgr = NULL;
+       }
+}
+
+
 /* LCOV_EXCL_STOP */
 
 static tbm_bufmgr
@@ -244,6 +279,9 @@ _tbm_bufmgr_init(int fd, int server)
 
        }
 
+       // TODO: this is temporary. it will be removed after finishing refactoring the tbm_module.
+       _tbm_bufmgr_copy_module_data(gBufMgr, gBufMgr->module, 0);
+
        /* check the essential capabilities of tbm_module */
        gBufMgr->capabilities = tbm_module_bufmgr_get_capabilities(gBufMgr->module);
        if (gBufMgr->capabilities == HAL_TBM_BUFMGR_CAPABILITY_NONE) {
@@ -369,6 +407,9 @@ tbm_bufmgr_deinit(tbm_bufmgr bufmgr)
 
        tbm_module_unload(bufmgr->module);
 
+       // TODO: this is temporary. it will be removed after finishing refactoring the tbm_module.
+       _tbm_bufmgr_copy_module_data(bufmgr, bufmgr->module, 1);
+
        if (bufmgr->fd > 0)
                close(bufmgr->fd);
 
index 10e7eff..2644f82 100644 (file)
@@ -53,40 +53,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* LCOV_EXCL_START */
 
-static void
-_tbm_module_copy_data_to_bufmgr(tbm_module *module, tbm_bufmgr bufmgr, int reset)
-{
-       if (!reset) {
-               bufmgr->module_data = module->module_data;
-               bufmgr->backend = module->backend;
-
-               bufmgr->backend_module_data = module->backend_module_data;
-               bufmgr->bufmgr_data = module->bufmgr_data;
-               bufmgr->bufmgr_func = module->bufmgr_func;
-               bufmgr->bo_func = module->bo_func;
-
-               bufmgr->use_hal_tbm = module->use_hal_tbm;
-               bufmgr->auth_wl_socket_created = module->auth_wl_socket_created;
-               bufmgr->auth_fd = module->auth_fd;
-               bufmgr->hal_backend = module->hal_backend;
-               bufmgr->hal_bufmgr = module->hal_bufmgr;
-       } else {
-               bufmgr->module_data = NULL;
-               bufmgr->backend = NULL;
-
-               bufmgr->backend_module_data = NULL;
-               bufmgr->bufmgr_data = NULL;
-               bufmgr->bufmgr_func = NULL;
-               bufmgr->bo_func = NULL;
-
-               bufmgr->use_hal_tbm = 0;
-               bufmgr->auth_wl_socket_created = 0;
-               bufmgr->auth_fd = -1;
-               bufmgr->hal_backend = NULL;
-               bufmgr->hal_bufmgr = NULL;
-       }
-}
-
 static int
 _tbm_backend_load_hal_tbm(tbm_module *module)
 {
@@ -447,9 +413,6 @@ tbm_module_load(tbm_bufmgr bufmgr, int fd)
        }
 
 done:
-       if (module)
-               _tbm_module_copy_data_to_bufmgr(module, module->bufmgr, 0);
-
        return module;
 }
 
@@ -492,7 +455,6 @@ tbm_module_unload(tbm_module *module)
                break;
        }
 
-       _tbm_module_copy_data_to_bufmgr(module, module->bufmgr, 1);
        module->bufmgr = NULL;
 
        free(module);