Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1514424

[PATCH] drm/amd/powerplay: return false instead of -EINVAL

From Andrew Shadura <andrew.shadura@collabora.co.uk>
Newsgroups linux.kernel
Subject [PATCH] drm/amd/powerplay: return false instead of -EINVAL
Date 2016-11-03 11:10 +0100
Message-ID <szn85-2uf-15@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Returning -EINVAL from a bool-returning function
phm_check_smc_update_required_for_display_configuration has an unexpected
effect of returning true, which is probably not what was intended.
Replace -EINVAL by false.

The only place this function is called from is
psm_adjust_power_state_dynamic in
drivers/gpu/drm/amd/powerplay/eventmgr/psm.c:106:

	if (!equal || phm_check_smc_update_required_for_display_configuration(hwmgr)) {
		phm_apply_state_adjust_rules(hwmgr, requested, pcurrent);
		phm_set_power_state(hwmgr, &pcurrent->hardware, &requested->hardware);
		hwmgr->current_ps = requested;
	}

It seems to expect a boolean value here.

This issue has been found using the following Coccinelle semantic patch
written by Peter Senna Tschudin:
<smpl>
@@
identifier f;
constant C;
typedef bool;
@@
bool f (...){
<+...
* return -C;
...+>
}
</smpl>

Signed-off-by: Andrew Shadura <andrew.shadura@collabora.co.uk>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
index 789f98a..82038b08 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
@@ -306,7 +306,7 @@ bool phm_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hw
 	PHM_FUNC_CHECK(hwmgr);
 
 	if (hwmgr->hwmgr_func->check_smc_update_required_for_display_configuration == NULL)
-		return -EINVAL;
+		return false;
 
 	return hwmgr->hwmgr_func->check_smc_update_required_for_display_configuration(hwmgr);
 }
-- 
2.7.4

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] drm/amd/powerplay: return false instead of -EINVAL Andrew Shadura <andrew.shadura@collabora.co.uk> - 2016-11-03 11:10 +0100
  RE: [PATCH] drm/amd/powerplay: return false instead of -EINVAL "Deucher, Alexander" <Alexander.Deucher@amd.com> - 2016-11-03 17:50 +0100
  Re: [PATCH] drm/amd/powerplay: return false instead of -EINVAL Andrew Shadura <andrew.shadura@collabora.co.uk> - 2016-11-03 17:50 +0100
  RE: [PATCH] drm/amd/powerplay: return false instead of -EINVAL "Deucher, Alexander" <Alexander.Deucher@amd.com> - 2016-11-03 18:00 +0100

csiph-web