diff options
author | SooChan Lim <sc1.lim@samsung.com> | 2021-02-03 16:13:15 +0900 |
---|---|---|
committer | SooChan Lim <sc1.lim@samsung.com> | 2021-02-03 16:14:26 +0900 |
commit | fdc82a6aae3ba980502b48050e9c1e58e768f6d2 (patch) | |
tree | f849245764d40623b49c600fd89a9fe2b588ea10 | |
parent | 845fb2de67923e3f69d08efe4af0bd4163489c3e (diff) | |
download | tbm-fdc82a6aae3ba980502b48050e9c1e58e768f6d2.tar.gz tbm-fdc82a6aae3ba980502b48050e9c1e58e768f6d2.tar.bz2 tbm-fdc82a6aae3ba980502b48050e9c1e58e768f6d2.zip |
change the function signature of hal_tbm_get_backend and hal_tbm_put_backend
hal_tbm_error hal_tbm_get_backend(hal_tbm_backend_data *backend_data);
void hal_tbm_put_backend(void);
Change-Id: I5d4f11eeb62d967c6a77cfb2a5a6dfb3f82e3885
-rw-r--r-- | include/hal-tbm.h | 6 | ||||
-rw-r--r-- | src/hal-api-tbm.c | 43 |
2 files changed, 32 insertions, 17 deletions
diff --git a/include/hal-tbm.h b/include/hal-tbm.h index db590a5..158e180 100644 --- a/include/hal-tbm.h +++ b/include/hal-tbm.h @@ -39,9 +39,9 @@ extern "C" { #include <hal-tbm-types.h> -hal_tbm_error hal_tbm_get_backend(hal_tbm_backend_data *backend_data); -void hal_tbm_put_backend(void); -hal_tbm_bufmgr_data *hal_tbm_get_bufmgr_data(hal_tbm_backend_data *backend_data); +hal_tbm_backend_data *hal_tbm_get_backend(hal_tbm_error *error); +hal_tbm_error hal_tbm_put_backend(hal_tbm_backend_data *backend_data); +hal_tbm_bufmgr_data *hal_tbm_get_bufmgr_data(hal_tbm_backend_data *backend_data); /* hal_tbm_bufmgr_funcs */ hal_tbm_bufmgr_capability hal_tbm_bufmgr_get_capabilities(hal_tbm_bufmgr_data *bufmgr_data, hal_tbm_error *error); diff --git a/src/hal-api-tbm.c b/src/hal-api-tbm.c index dc20672..43be719 100644 --- a/src/hal-api-tbm.c +++ b/src/hal-api-tbm.c @@ -110,40 +110,55 @@ static hal_tbm_backend_data *g_hal_tbm_backend_data = NULL; -EXTERN hal_tbm_error -hal_tbm_get_backend(hal_tbm_backend_data *backend_data) +EXTERN hal_tbm_backend_data * +hal_tbm_get_backend(hal_tbm_error *error) { + hal_tbm_backend_data *backend_data; int ret; - if (g_hal_tbm_backend_data) - return HAL_TBM_ERROR_INVALID_OPERATION; + if (g_hal_tbm_backend_data) { + if (error) + *error = HAL_TBM_ERROR_INVALID_OPERATION; + return NULL; + } ret = hal_common_get_backend(HAL_MODULE_TBM, (void **)&backend_data); if (ret < 0) { _E("Failed to get backend\n"); - free(g_hal_tbm_backend_data); - g_hal_tbm_backend_data = NULL; - return HAL_TBM_ERROR_NOT_SUPPORTED; + if (error) + *error = HAL_TBM_ERROR_INVALID_OPERATION; + return NULL; } - g_hal_tbm_backend_data = (hal_tbm_backend_data *)backend_data; + g_hal_tbm_backend_data = backend_data; + + if (error) + *error = HAL_TBM_ERROR_NONE; _I("hal_tbm_get_backend"); - return HAL_TBM_ERROR_NONE; + return backend_data; } -EXTERN void -hal_tbm_put_backend(void) +EXTERN hal_tbm_error +hal_tbm_put_backend(hal_tbm_backend_data *backend_data) { + int ret; + if (!g_hal_tbm_backend_data) - return; + return HAL_TBM_ERROR_INVALID_OPERATION; + + ret = hal_common_put_backend(HAL_MODULE_TBM, NULL); + if (ret < 0) { + _E("Failed to put backend\n"); + return HAL_TBM_ERROR_INVALID_OPERATION; + } - hal_common_put_backend(HAL_MODULE_TBM, NULL); - free(g_hal_tbm_backend_data); g_hal_tbm_backend_data = NULL; _I("hal_tbm_put_backend"); + + return HAL_TBM_ERROR_NONE; } EXTERN hal_tbm_bufmgr_data * |