From: Chanwoo Choi Date: Sun, 6 Feb 2022 08:31:16 +0000 (+0900) Subject: pass: Add resource_device for each h/w resource X-Git-Tag: accepted/tizen/unified/20220302.131908~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0e947ab8bacc3f61421097ef07c1d8cf8ded774;p=platform%2Fcore%2Fsystem%2Fpass.git pass: Add resource_device for each h/w resource Change-Id: I1b124c8828f05103226d9d84558d45bb397cedba Signed-off-by: Chanwoo Choi --- diff --git a/src/pass/pass.c b/src/pass/pass.c index b0a56bd..ac70225 100644 --- a/src/pass/pass.c +++ b/src/pass/pass.c @@ -276,8 +276,32 @@ static int pass_init_resource(struct pass_resource *res) } } + /* Add resource_device according to h/w resource information */ + res->device = calloc(1, sizeof(*res->device)); + if (!res->device) { + ret = -ENOMEM; + goto err_res_dev; + } + + res->device->name = res->config_data.res_name; + res->device->type = res->config_data.res_type; + + ret = add_resource_device(res->device); + if (ret < 0) { + _E("cannot add resource device (res_name:%s, res_type%d)", + res->config_data.res_name, + res->config_data.res_type); + goto err; + } + return 0; +err: + free(res->device); +err_res_dev: + if (is_supported_module(res, PASS_MODULE_THERMAL)) + if (pass_thermal_exit(res) < 0) + _E("cannot exit PASS Thermal"); err_thermal: if (is_supported_module(res, PASS_MODULE_PMQOS)) if (pass_pmqos_exit(res) < 0) @@ -308,6 +332,11 @@ static int pass_exit_resource(struct pass_resource *res) { int ret; + /* Remove resource_device */ + remove_resource_device(res->device); + free(res->device); + res->device = NULL; + /* Put configuration of each resource from pass-resource*.conf */ pass_parser_put_each_resource_config(res); diff --git a/src/pass/pass.h b/src/pass/pass.h index dfb4c86..89b31d3 100644 --- a/src/pass/pass.h +++ b/src/pass/pass.h @@ -38,6 +38,7 @@ #include #include +#include #define PASS_LEVEL_COND_MAX 3 @@ -640,6 +641,9 @@ struct pass_resource { struct pass_pmqos pmqos; /** Instance of PASS_MODULE_THERMAL module */ struct pass_thermal thermal; + + /** Instance of resouce device containing h/w resource information */ + struct resource_device *device; }; /******************************************************