Commit 09b6744c authored by Darren Powell's avatar Darren Powell Committed by Alex Deucher
Browse files

amdgpu/pm: replaced snprintf usage in amdgpu_pm.c with sysfs_emit



 replaced snprintf usage in amdgpu_pm.c with sysfs_emit
 fixed warning on comparing int with uint32_t in amdgpu_get_pp_num_states()

== Test ==
AMDGPU_PCI_ADDR=`lspci -nn | grep "VGA\|Display" | cut -d " " -f 1`
AMDGPU_HWMON=`ls -la /sys/class/hwmon | grep $AMDGPU_PCI_ADDR | cut -d " " -f 10`
HWMON_DIR=/sys/class/hwmon/${AMDGPU_HWMON}

lspci -nn | grep "VGA\|Display"  > scnprintf.test.log
FILES="pp_num_states
pp_od_clk_voltage
pp_features
pp_dpm_sclk
pp_dpm_mclk
pp_dpm_socclk
pp_dpm_fclk
pp_dpm_vclk
pp_dpm_dclk
pp_dpm_dcefclk
pp_power_profile_mode "

for f in $FILES
do
  echo === $f === >> scnprintf.test.log
  cat $HWMON_DIR/device/$f >> scnprintf.test.log
done

Signed-off-by: default avatarDarren Powell <darren.powell@amd.com>
Reviewed-by: default avatarKevin Wang <kevin1.wang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c9cfbf7f
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -411,7 +411,8 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
	struct amdgpu_device *adev = drm_to_adev(ddev);
	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
	struct pp_states_info data;
	int i, buf_len, ret;
	uint32_t i;
	int buf_len, ret;

	if (amdgpu_in_reset(adev))
		return -EPERM;
@@ -433,9 +434,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
	pm_runtime_mark_last_busy(ddev->dev);
	pm_runtime_put_autosuspend(ddev->dev);

	buf_len = snprintf(buf, PAGE_SIZE, "states: %d\n", data.nums);
	buf_len = sysfs_emit(buf, "states: %d\n", data.nums);
	for (i = 0; i < data.nums; i++)
		buf_len += snprintf(buf + buf_len, PAGE_SIZE, "%d %s\n", i,
		buf_len += sysfs_emit_at(buf, buf_len, "%d %s\n", i,
				(data.states[i] == POWER_STATE_TYPE_INTERNAL_BOOT) ? "boot" :
				(data.states[i] == POWER_STATE_TYPE_BATTERY) ? "battery" :
				(data.states[i] == POWER_STATE_TYPE_BALANCED) ? "balanced" :
@@ -923,7 +924,7 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
		size += amdgpu_dpm_print_clock_levels(adev, OD_RANGE, buf+size);
		size += amdgpu_dpm_print_clock_levels(adev, OD_CCLK, buf+size);
	} else {
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");
	}
	pm_runtime_mark_last_busy(ddev->dev);
	pm_runtime_put_autosuspend(ddev->dev);
@@ -1009,7 +1010,7 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
	if (adev->powerplay.pp_funcs->get_ppfeature_status)
		size = amdgpu_dpm_get_ppfeature_status(adev, buf);
	else
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");

	pm_runtime_mark_last_busy(ddev->dev);
	pm_runtime_put_autosuspend(ddev->dev);
@@ -1070,7 +1071,7 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,
	if (adev->powerplay.pp_funcs->print_clock_levels)
		size = amdgpu_dpm_print_clock_levels(adev, type, buf);
	else
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");

	pm_runtime_mark_last_busy(ddev->dev);
	pm_runtime_put_autosuspend(ddev->dev);
@@ -1469,7 +1470,7 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,
	if (adev->powerplay.pp_funcs->get_power_profile_mode)
		size = amdgpu_dpm_get_power_profile_mode(adev, buf);
	else
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");

	pm_runtime_mark_last_busy(ddev->dev);
	pm_runtime_put_autosuspend(ddev->dev);
@@ -2931,9 +2932,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,
		r = -ENODATA;

	if (!r)
		size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
		size = sysfs_emit(buf, "%u\n", limit * 1000000);
	else
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");

	pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
	pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -2971,9 +2972,9 @@ static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,
		r = -ENODATA;

	if (!r)
		size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
		size = sysfs_emit(buf, "%u\n", limit * 1000000);
	else
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");

	pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
	pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
@@ -3011,9 +3012,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_default(struct device *dev,
		r = -ENODATA;

	if (!r)
		size = snprintf(buf, PAGE_SIZE, "%u\n", limit * 1000000);
		size = sysfs_emit(buf, "%u\n", limit * 1000000);
	else
		size = snprintf(buf, PAGE_SIZE, "\n");
		size = sysfs_emit(buf, "\n");

	pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
	pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);