From: Wook Song Date: Tue, 28 Mar 2017 08:08:36 +0000 (+0900) Subject: pass: hal: Add a function for putting resource X-Git-Tag: submit/tizen/20170426.080126~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e20a19059e26c0b74db76320f74046ac56ce4c4;p=platform%2Fcore%2Fsystem%2Fpass.git pass: hal: Add a function for putting resource This patch adds the pass_put_resource function, which is paired up with pass_get_resource(). When the main daemon is terminated, every hardware resources resources (which are opened by pass_get_resource()) are closed via HAL by this function. Change-Id: I454d931979c5753ad070c44e58e9256429e6f7f7 Signed-off-by: Wook Song Reviewed-by: Chanwoo Choi --- diff --git a/src/pass/pass-hal.c b/src/pass/pass-hal.c index 129d025..8b1f3b1 100644 --- a/src/pass/pass-hal.c +++ b/src/pass/pass-hal.c @@ -533,6 +533,47 @@ int pass_get_resource(struct pass *pass) return 0; } +int pass_put_resource(struct pass *pass) +{ + struct pass_resource_common *common; + struct pass_resource_info *info; + int i, ret; + + for (i = 0; i < pass->num_resources; i++) { + struct pass_resource *pass_res = &pass->res[i]; + struct pass_conf_data *cdata = &pass_res->cdata; + int res_type = cdata->res_type; + + switch (res_type) { + case PASS_RESOURCE_CPU_ID: + common = (struct pass_resource_common*)pass_res->hal.cpu; + info = pass_res->hal.cpu->common.info; + ret = info->close(common); + break; + case PASS_RESOURCE_BUS_ID: + common = (struct pass_resource_common*)pass_res->hal.bus; + info = pass_res->hal.bus->common.info; + ret = info->close(common); + break; + case PASS_RESOURCE_GPU_ID: + common = (struct pass_resource_common*)pass_res->hal.gpu; + info = pass_res->hal.gpu->common.info; + ret = info->close(common); + break; + default: + return -EINVAL; + }; + + if (ret < 0) { + _E("Failed to close %s h/w resource\n", info->name); + return -EINVAL; + } + + _D("Complete the closing for %s h/w resource\n", info->name); + } + + return 0; +} /* * FXIME: Following function is not standard interface. * Following functions will be altered by the standard interface on later. diff --git a/src/pass/pass-hal.h b/src/pass/pass-hal.h index 09eb879..6700eea 100644 --- a/src/pass/pass-hal.h +++ b/src/pass/pass-hal.h @@ -55,8 +55,9 @@ int pass_set_online_max_num(struct pass_resource *res, int num); int pass_get_temp(struct pass_resource *res); int pass_get_policy(struct pass_resource *res, char *policy); -/* Load the h/w resource. */ +/* Get and put the h/w resource. */ int pass_get_resource(struct pass *pass); +int pass_put_resource(struct pass *pass); /* * FXIME: Following function is not standard interface. diff --git a/src/pass/pass.c b/src/pass/pass.c index 40ae215..33e08f3 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -268,7 +268,6 @@ static int pass_exit_done(void) { int i, ret; - ret = 0; for (i = 0; i < g_pass.num_resources; i++) { struct pass_resource *pass_res = &g_pass.res[i]; struct pass_policy *policy = &pass_res->policy; @@ -276,10 +275,15 @@ static int pass_exit_done(void) ret = pass_resource_exit(policy); if (ret < 0) { _E("failed to clean up the pass resource #%d\n", i); - break; + goto exit; } } + ret = pass_put_resource(&g_pass); + if (ret < 0) + _E("cannot put the pass resource\n"); + +exit: return ret; }