pass: Skip exit process for uninitialized resources 62/146162/5 accepted/tizen/4.0/unified/20170901.202640 accepted/tizen/unified/20170829.053236 submit/tizen/20170828.071557 submit/tizen_4.0/20170901.015952
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 25 Aug 2017 06:43:34 +0000 (15:43 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Mon, 28 Aug 2017 05:24:33 +0000 (14:24 +0900)
Even in the case that the resource is not initialized due to any
reason, pass tries to exit that resource during service stop, and
thus it causes failure on exit process. To resolve it, this patch
adds the state of resource and set UNUSED state to resource on error
case. After that, exit process for the resource in UNUSED state will
be skipped.

Change-Id: Id635471d39b3d19378613935666cfd911813baf3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/pass/pass.c
src/pass/pass.h

index 879408017fc93d305a770fdef0e14a8f430e9b41..cf3b43f4c8fcd804f847c31ae843b8ee5904ea49 100644 (file)
@@ -244,6 +244,8 @@ static int pass_init_done(void *data, void *user_data)
                if (ret < 0) {
                        _E("Cannot get the pass '%s' resource (%d)\n",
                                        cdata->res_name, ret);
+
+                       res->state = PASS_UNUSED;
                        continue;
                }
 
@@ -256,6 +258,8 @@ static int pass_init_done(void *data, void *user_data)
                        if (ret < 0)
                                _E("Cannot put the pass '%s' resource (%d)\n",
                                        cdata->res_name, ret);
+
+                       res->state = PASS_UNUSED;
                        continue;
                }
 
@@ -273,7 +277,12 @@ static int pass_init_done(void *data, void *user_data)
                        if (ret < 0)
                                _E("Cannot put the pass '%s' resource (%d)\n",
                                        cdata->res_name, ret);
+
+                       res->state = PASS_UNUSED;
+                       continue;
                }
+
+               res->state = PASS_ON;
        }
 
        return 0;
@@ -287,6 +296,9 @@ static int pass_exit_done(void)
                struct pass_resource *res = &g_pass.res[i];
                struct pass_conf_data *cdata = &g_pass.res[i].cdata;
 
+               if (res->state == PASS_UNUSED)
+                       continue;
+
                ret = pass_exit_resource(res);
                if (ret < 0)
                        _E("Cannot exit the pass '%s' resource (%d)\n",
@@ -302,6 +314,8 @@ static int pass_exit_done(void)
                        _E("Cannot put the pass '%s' resource (%d)\n",
                                        cdata->res_name, ret);
                }
+
+               res->state = PASS_OFF;
        }
 
        pass_put_resource_config(&g_pass);
index 85d177112fbcc5a920e6836e757788d97885c53d..ebb0274b97fe4af1ab604ec1f74425e060536f6b 100644 (file)
@@ -326,6 +326,7 @@ struct pass_resource_initdata {
 /*
  * struct pass_resource - Represent the each h/w resource.
  *
+ * @state: represents the state of the corresponding resource.
  * @cdata: the parsed data from configuration file (pass.conf).
  * @hal: the hal instance of each h/w resource from pass_get_hal_info().
  * - If res_type of cdata is PASS_RESOURCE_CPU_ID, hal.cpu will be used.
@@ -337,6 +338,7 @@ struct pass_resource_initdata {
  * @initdata: the initial data to restore when pass service is stopped
  */
 struct pass_resource {
+       enum pass_state state;
        struct pass_conf_data cdata;
        struct pass_policy policy;
        struct pass_resource_initdata initdata;