]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
amdgpu/pm: handle return value for get_power_limit
authorDarren Powell <darren.powell@amd.com>
Wed, 26 May 2021 22:47:10 +0000 (18:47 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 8 Jun 2021 16:14:03 +0000 (12:14 -0400)
Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/amdgpu_pm.c

index 0a788cb38ee2705638dd43df658f5b642068193d..b2335a1d3f98afea4e11759dbc8a2c5552504bb9 100644 (file)
@@ -2924,13 +2924,16 @@ static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
                return r;
        }
 
-       if (pp_funcs && pp_funcs->get_power_limit) {
-               pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit,
-                                         pp_limit_level, power_type);
+       if (pp_funcs && pp_funcs->get_power_limit)
+               r = pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit,
+                                             pp_limit_level, power_type);
+       else
+               r = -ENODATA;
+
+       if (!r)
                size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
-       } else {
+       else
                size = snprintf(buf, PAGE_SIZE, "\n");
-       }
 
        pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
        pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -2961,13 +2964,16 @@ static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,
                return r;
        }
 
-       if (pp_funcs && pp_funcs->get_power_limit) {
-               pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit,
-                                         pp_limit_level, power_type);
+       if (pp_funcs && pp_funcs->get_power_limit)
+               r = pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit,
+                                             pp_limit_level, power_type);
+       else
+               r = -ENODATA;
+
+       if (!r)
                size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
-       } else {
+       else
                size = snprintf(buf, PAGE_SIZE, "\n");
-       }
 
        pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
        pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -2998,13 +3004,16 @@ static ssize_t amdgpu_hwmon_show_power_cap_default(struct device *dev,
                return r;
        }
 
-       if (pp_funcs && pp_funcs->get_power_limit) {
-               pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit,
-                                         pp_limit_level, power_type);
+       if (pp_funcs && pp_funcs->get_power_limit)
+               r = pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit,
+                                             pp_limit_level, power_type);
+       else
+               r = -ENODATA;
+
+       if (!r)
                size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
-       } else {
+       else
                size = snprintf(buf, PAGE_SIZE, "\n");
-       }
 
        pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
        pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);