• Andrew Shadura's avatar
    drm/amd/powerplay: return false instead of -EINVAL · f20024d8
    Andrew Shadura authored
    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>
    Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    Signed-off-by: default avatarAndrew Shadura <andrew.shadura@collabora.co.uk>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    f20024d8
hardwaremanager.c 12.1 KB