pass: Add resource_device for each h/w resource 02/270602/6
authorChanwoo Choi <cw00.choi@samsung.com>
Sun, 6 Feb 2022 08:31:16 +0000 (17:31 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 7 Feb 2022 05:35:32 +0000 (14:35 +0900)
Change-Id: I1b124c8828f05103226d9d84558d45bb397cedba
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass.c
src/pass/pass.h

index b0a56bd..ac70225 100644 (file)
@@ -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);
 
index dfb4c86..89b31d3 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <util/common.h>
 #include <util/log.h>
+#include <util/resource.h>
 
 #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;
 };
 
 /******************************************************