pass: hal: Fix error number from EINVAL to EPERM/ENODEV 13/184813/2
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 20 Jul 2018 04:23:11 +0000 (13:23 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 23 Jul 2018 09:45:36 +0000 (18:45 +0900)
All HAL functions return '-EINVAL' error number when error happen.
It is necessary to return more correct error value. Return -EPERM value
if HAL(Hardware Abstract Layer) function is not supported according to
h/w resource type and return -ENODEV value if HAL function is not implemented
on HAL package.

Change-Id: I0b0da7429f38aa0362293275849a713e6020a763
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-hal.c

index 3694326b0c04221c85a76d7bf7f7212516429b5d..1df19127f15675fb7e012876b04c22d14a81dc5a 100644 (file)
@@ -95,10 +95,10 @@ int pass_get_curr_governor(struct pass_resource *res, char *governor)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_curr_governor)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_curr_governor(res->config_data.res_name, governor);
 }
@@ -112,10 +112,10 @@ int pass_set_curr_governor(struct pass_resource *res, char *governor)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->set_curr_governor)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->set_curr_governor(res->config_data.res_name, governor);
 }
@@ -130,10 +130,10 @@ int pass_get_curr_freq(struct pass_resource *res)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_curr_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_curr_freq(res->config_data.res_name);
 }
@@ -148,10 +148,10 @@ int pass_get_min_freq(struct pass_resource *res)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_min_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_min_freq(res->config_data.res_name);
 }
@@ -165,10 +165,10 @@ int pass_set_min_freq(struct pass_resource *res, int freq)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->set_min_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->set_min_freq(res->config_data.res_name, freq);
 }
@@ -182,10 +182,10 @@ int pass_get_max_freq(struct pass_resource *res)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_max_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_max_freq(res->config_data.res_name);
 }
@@ -199,10 +199,10 @@ int pass_set_max_freq(struct pass_resource *res, int freq)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->set_max_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->set_max_freq(res->config_data.res_name, freq);
 }
@@ -217,10 +217,10 @@ int pass_get_available_min_freq(struct pass_resource *res)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_available_min_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_available_min_freq(res->config_data.res_name);
 }
@@ -234,10 +234,10 @@ int pass_get_available_max_freq(struct pass_resource *res)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_available_max_freq)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_available_max_freq(res->config_data.res_name);
 }
@@ -252,10 +252,10 @@ int pass_get_up_threshold(struct pass_resource *res)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->get_up_threshold)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->get_up_threshold(res->config_data.res_name);
 }
@@ -269,10 +269,10 @@ int pass_set_up_threshold(struct pass_resource *res, int up_threshold)
 
        dvfs = get_dvfs(res, res->config_data.res_type);
        if (!dvfs)
-               return -EINVAL;
+               return -EPERM;
 
        if (!dvfs->set_up_threshold)
-               return -EINVAL;
+               return -ENODEV;
 
        return dvfs->set_up_threshold(res->config_data.res_name, up_threshold);
 }
@@ -287,10 +287,10 @@ int pass_get_online_state(struct pass_resource *res, int cpu)
 
        hotplug = get_hotplug(res, res->config_data.res_type);
        if (!hotplug)
-               return -EINVAL;
+               return -EPERM;
 
        if (!hotplug->get_online_state)
-               return -EINVAL;
+               return -ENODEV;
 
        return hotplug->get_online_state(res->config_data.res_name, cpu);
 }
@@ -304,10 +304,10 @@ int pass_set_online_state(struct pass_resource *res, int cpu, int on)
 
        hotplug = get_hotplug(res, res->config_data.res_type);
        if (!hotplug)
-               return -EINVAL;
+               return -EPERM;
 
        if (!hotplug->set_online_state)
-               return -EINVAL;
+               return -ENODEV;
 
        return hotplug->set_online_state(res->config_data.res_name, cpu, on);
 }
@@ -321,10 +321,10 @@ int pass_get_online_min_num(struct pass_resource *res)
 
        hotplug = get_hotplug(res, res->config_data.res_type);
        if (!hotplug)
-               return -EINVAL;
+               return -EPERM;
 
        if (!hotplug->get_online_min_num)
-               return -EINVAL;
+               return -ENODEV;
 
        return hotplug->get_online_min_num(res->config_data.res_name);
 }
@@ -338,10 +338,10 @@ int pass_set_online_min_num(struct pass_resource *res, int num)
 
        hotplug = get_hotplug(res, res->config_data.res_type);
        if (!hotplug)
-               return -EINVAL;
+               return -EPERM;
 
        if (!hotplug->set_online_min_num)
-               return -EINVAL;
+               return -ENODEV;
 
        return hotplug->set_online_min_num(res->config_data.res_name, num);
 }
@@ -355,10 +355,10 @@ int pass_get_online_max_num(struct pass_resource *res)
 
        hotplug = get_hotplug(res, res->config_data.res_type);
        if (!hotplug)
-               return -EINVAL;
+               return -EPERM;
 
        if (!hotplug->get_online_max_num)
-               return -EINVAL;
+               return -ENODEV;
 
        return hotplug->get_online_max_num(res->config_data.res_name);
 }
@@ -372,10 +372,10 @@ int pass_set_online_max_num(struct pass_resource *res, int num)
 
        hotplug = get_hotplug(res, res->config_data.res_type);
        if (!hotplug)
-               return -EINVAL;
+               return -EPERM;
 
        if (!hotplug->set_online_max_num)
-               return -EINVAL;
+               return -ENODEV;
 
        return hotplug->set_online_max_num(res->config_data.res_name, num);
 }
@@ -390,10 +390,10 @@ int pass_get_temp(struct pass_resource *res)
 
        tmu = get_tmu(res, res->config_data.res_type);
        if (!tmu)
-               return -EINVAL;
+               return -EPERM;
 
        if (!tmu->get_temp)
-               return -EINVAL;
+               return -ENODEV;
 
        /*
         * In the case of the HAL TMU ops, res_thermal_name is used
@@ -411,10 +411,10 @@ int pass_get_tmu_policy(struct pass_resource *res, char *policy)
 
        tmu = get_tmu(res, res->config_data.res_type);
        if (!tmu)
-               return -EINVAL;
+               return -EPERM;
 
        if (!tmu->get_policy)
-               return -EINVAL;
+               return -ENODEV;
 
        /*
         * In the case of the HAL TMU ops, res_thermal_name is used
@@ -436,11 +436,11 @@ int pass_set_fault_around_bytes(struct pass_resource *res,
                memory = res->hal.memory;
                break;
        default:
-               return -EINVAL;
+               return -EPERM;
        }
 
        if (!memory->set_fault_around_bytes)
-               return -EINVAL;
+               return -ENODEV;
 
        return memory->set_fault_around_bytes(res->config_data.res_name, fault_around_bytes);
 }
@@ -457,11 +457,11 @@ int pass_get_fault_around_bytes(struct pass_resource *res)
                memory = res->hal.memory;
                break;
        default:
-               return -EINVAL;
+               return -EPERM;
        }
 
        if (!memory->get_fault_around_bytes)
-               return -EINVAL;
+               return -ENODEV;
 
        return memory->get_fault_around_bytes(res->config_data.res_name);
 }
@@ -470,7 +470,7 @@ int pass_set_pmqos_data(struct pass_resource *res, void *data)
 {
        struct pass_resource_nonstandard *nonstandard = NULL;
 
-       if (!res)
+       if (!res || !data)
                return -EINVAL;
 
        switch (res->config_data.res_type) {
@@ -478,11 +478,11 @@ int pass_set_pmqos_data(struct pass_resource *res, void *data)
                nonstandard  = (res->hal.nonstandard);
                break;
        default:
-               return -EINVAL;
+               return -EPERM;
        }
 
-       if (!nonstandard->set_pmqos_data || !data)
-               return -EINVAL;
+       if (!nonstandard->set_pmqos_data)
+               return -ENODEV;
 
        return nonstandard->set_pmqos_data(res->config_data.res_name, data);
 }