display: Fix plugin api error handling 69/312869/1
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 13 Jun 2024 06:32:17 +0000 (15:32 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 17 Jun 2024 04:59:35 +0000 (13:59 +0900)
The deviced plugin api has changed to return two special error case.
 1. -ENOTSUP
    : It specifies loading fail of plugin backend
 2. -EOPNOTSUPP
    : It succeeded backend loading but the loaded backend has no
      implemented operation.
Both cases take alternative fallback - the predefined default routine
by the deviced. Other nagative values are considered as error of
backend implementation itself so it won't take the default routine.

Change-Id: I854cb9ea5403e163a5acb425f5d98bb61d8c968e
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/display/display-panel.c
src/display/setting.c

index e73ce662e2e38f864e2880d0cf7440db28bd83ca..18ceec1d41d9ee1970e6a009f2207c8541e11d21 100644 (file)
@@ -239,11 +239,16 @@ void display_panel_lcd_on_procedure(int state, enum deviced_event reason)
        int ret;
 
        ret = syscommon_plugin_deviced_display_lcd_on_procedure(state, reason);
-       if (ret == 0)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return;
-
-       if (ret != -EOPNOTSUPP)
+       } else {
                return;
+       }
 
        /*
         * Display on procedure
@@ -293,11 +298,16 @@ void display_panel_lcd_off_procedure(enum deviced_event reason)
        int ret;
 
        ret = syscommon_plugin_deviced_display_lcd_off_procedure(reason);
-       if (ret == 0)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return;
-
-       if (ret != -EOPNOTSUPP)
+       } else {
                return;
+       }
        /*
         * Display off procedure
         * step 0. enhance mode off using nofity (e.g mdnie, HBM, LBM)
@@ -376,11 +386,16 @@ int display_panel_custom_lcd_on(int timeout)
        int ret;
 
        ret = syscommon_plugin_deviced_display_custom_lcd_on(timeout);
-       if (ret == 0)
-               return 0;
-
-       if (ret != -EOPNOTSUPP)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return ret;
+       } else {
+               return 0;
+       }
 
        if (timeout <= 0)
                return -EINVAL;
@@ -404,11 +419,16 @@ int display_panel_custom_lcd_off(enum deviced_event reason)
        int ret;
 
        ret = syscommon_plugin_deviced_display_custom_lcd_off(reason);
-       if (ret == 0)
-               return 0;
-
-       if (ret != -EOPNOTSUPP)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return ret;
+       } else {
+               return 0;
+       }
 
        /* check holdkey block flag in lock node */
        if (display_lock_is_state_locked(SYSCOMMON_DEVICED_DISPLAY_STATE_ON) || display_lock_is_state_locked(SYSCOMMON_DEVICED_DISPLAY_STATE_DIM)) {
@@ -448,11 +468,16 @@ int display_panel_display_turn_on_by_reason(const char *reason, int timeout)
        int ret;
 
        ret = syscommon_plugin_deviced_display_on_by_reason(reason, timeout);
-       if (ret == 0)
-               return 0;
-
-       if (ret != -EOPNOTSUPP)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return ret;
+       } else {
+               return 0;
+       }
 
        if (!reason)
                return -EINVAL;
@@ -492,11 +517,16 @@ int display_panel_display_turn_off_by_reason(const char *reason)
        int ret;
 
        ret = syscommon_plugin_deviced_display_off_by_reason(reason);
-       if (ret == 0)
-               return 0;
-
-       if (ret != -EOPNOTSUPP)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return ret;
+       } else {
+               return 0;
+       }
 
        if (!reason)
                return -EINVAL;
index 4269d105ecff3d26a4ee650e71f83216407a2359..072f7ca120ceacf55430fafaf4415553012b8e60 100644 (file)
@@ -289,11 +289,16 @@ int display_setting_update_pm_setting(int key_idx, int val)
        enum syscommon_deviced_display_state current;
 
        ret = syscommon_plugin_deviced_display_notify_setting_value_changed(key_idx, val);
-       if (ret == 0)
-               return 0;
-
-       if (ret != -EOPNOTSUPP)
+       if (ret == -ENOTSUP) {
+               _D("Take default operation as there is no found plugin backend");
+       } else if (ret == -EOPNOTSUPP) {
+               _D("Take default operation as there is no found plugin backend operation");
+       } else if (ret < 0) {
+               _E("Failed to plugin operation, ret=%d", ret);
                return ret;
+       } else {
+               return 0;
+       }
 
        ret = display_state_get_current(&current);
        if (ret < 0)