Commit b8e6aec1 authored by Mario Limonciello's avatar Mario Limonciello Committed by Alex Deucher
Browse files

drm/amd: Drop all hand-built MIN and MAX macros in the amdgpu base driver



Several files declare MIN() or MAX() macros that ignore the types of the
values being compared.  Drop these macros and switch to min() min_t(),
and max() from `linux/minmax.h`.

Suggested-by: default avatarHamza Mahfooz <Hamza.Mahfooz@amd.com>
Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 7752ccf8
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1328,8 +1328,6 @@ int emu_soc_asic_init(struct amdgpu_device *adev);
	for (i = ffs(inst_mask); i-- != 0; \
	     i = ffs(inst_mask & BIT_MASK_UPPER(i + 1)))

#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))

/* Common functions */
bool amdgpu_device_has_job_running(struct amdgpu_device *adev);
bool amdgpu_device_should_recover_gpu(struct amdgpu_device *adev);
+1 −1
Original line number Diff line number Diff line
@@ -6600,7 +6600,7 @@ static int si_dpm_get_fan_speed_pwm(void *handle,

	tmp64 = (u64)duty * 255;
	do_div(tmp64, duty100);
	*speed = MIN((u32)tmp64, 255);
	*speed = min_t(u32, tmp64, 255);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ int smu7_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr,

	tmp64 = (uint64_t)duty * 255;
	do_div(tmp64, duty100);
	*speed = MIN((uint32_t)tmp64, 255);
	*speed = min_t(uint32_t, tmp64, 255);

	return 0;
}
@@ -210,7 +210,7 @@ int smu7_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr,
	if (hwmgr->thermal_controller.fanInfo.bNoFan)
		return 0;

	speed = MIN(speed, 255);
	speed = min_t(uint32_t, speed, 255);

	if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl))
		smu7_fan_ctrl_stop_smc_fan_control(hwmgr);
+2 −2
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ int vega10_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr,

	tmp64 = (uint64_t)duty * 255;
	do_div(tmp64, duty100);
	*speed = MIN((uint32_t)tmp64, 255);
	*speed = min_t(uint32_t, tmp64, 255);

	return 0;
}
@@ -255,7 +255,7 @@ int vega10_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr,
	if (hwmgr->thermal_controller.fanInfo.bNoFan)
		return 0;

	speed = MIN(speed, 255);
	speed = min_t(uint32_t, speed, 255);

	if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl))
		vega10_fan_ctrl_stop_smc_fan_control(hwmgr);
+2 −2
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ int vega20_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr,

	tmp64 = (uint64_t)duty * 255;
	do_div(tmp64, duty100);
	*speed = MIN((uint32_t)tmp64, 255);
	*speed = min_t(uint32_t, tmp64, 255);

	return 0;
}
@@ -144,7 +144,7 @@ int vega20_fan_ctrl_set_fan_speed_pwm(struct pp_hwmgr *hwmgr,
	uint32_t duty;
	uint64_t tmp64;

	speed = MIN(speed, 255);
	speed = min_t(uint32_t, speed, 255);

	if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl))
		vega20_fan_ctrl_stop_smc_fan_control(hwmgr);
Loading